wrapper: Convert usage of base::Bind to Once or Repeating (see issue #3140)
This commit is contained in:
parent
cc2759d07e
commit
ed1840ddb5
|
@ -83,7 +83,8 @@ struct CefDeleteOnThread {
|
|||
if (CefCurrentlyOn(thread)) {
|
||||
delete x;
|
||||
} else {
|
||||
CefPostTask(thread, base::Bind(&CefDeleteOnThread<thread>::Destruct<T>,
|
||||
CefPostTask(thread,
|
||||
base::BindOnce(&CefDeleteOnThread<thread>::Destruct<T>,
|
||||
base::Unretained(x)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,14 +66,15 @@ class CefResourceManager
|
|||
// file extension. |url| will be fully qualified and may contain query or
|
||||
// fragment components.
|
||||
///
|
||||
typedef base::Callback<std::string(const std::string& /*url*/)> UrlFilter;
|
||||
using UrlFilter =
|
||||
base::RepeatingCallback<std::string(const std::string& /*url*/)>;
|
||||
|
||||
///
|
||||
// Used to resolve mime types for URLs, usually based on the file extension.
|
||||
// |url| will be fully qualified and may contain query or fragment components.
|
||||
///
|
||||
typedef base::Callback<std::string(const std::string& /*url*/)>
|
||||
MimeTypeResolver;
|
||||
using MimeTypeResolver =
|
||||
base::RepeatingCallback<std::string(const std::string& /*url*/)>;
|
||||
|
||||
private:
|
||||
// Values that stay with a request as it moves between providers.
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include "include/base/cef_bind.h"
|
||||
#include "include/base/cef_callback.h"
|
||||
#include "include/base/cef_macros.h"
|
||||
#include "include/cef_task.h"
|
||||
|
@ -86,14 +85,15 @@ class CefMessageRouterBrowserSideImpl : public CefMessageRouterBrowserSide {
|
|||
void Success(const CefString& response) override {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
// Must execute on the UI thread to access member variables.
|
||||
CefPostTask(TID_UI, base::Bind(&CallbackImpl::Success, this, response));
|
||||
CefPostTask(TID_UI,
|
||||
base::BindOnce(&CallbackImpl::Success, this, response));
|
||||
return;
|
||||
}
|
||||
|
||||
if (router_) {
|
||||
CefPostTask(
|
||||
TID_UI,
|
||||
base::Bind(&CefMessageRouterBrowserSideImpl::OnCallbackSuccess,
|
||||
base::BindOnce(&CefMessageRouterBrowserSideImpl::OnCallbackSuccess,
|
||||
router_.get(), browser_id_, query_id_, response));
|
||||
|
||||
if (!persistent_) {
|
||||
|
@ -106,15 +106,15 @@ class CefMessageRouterBrowserSideImpl : public CefMessageRouterBrowserSide {
|
|||
void Failure(int error_code, const CefString& error_message) override {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
// Must execute on the UI thread to access member variables.
|
||||
CefPostTask(TID_UI, base::Bind(&CallbackImpl::Failure, this, error_code,
|
||||
error_message));
|
||||
CefPostTask(TID_UI, base::BindOnce(&CallbackImpl::Failure, this,
|
||||
error_code, error_message));
|
||||
return;
|
||||
}
|
||||
|
||||
if (router_) {
|
||||
CefPostTask(
|
||||
TID_UI,
|
||||
base::Bind(&CefMessageRouterBrowserSideImpl::OnCallbackFailure,
|
||||
base::BindOnce(&CefMessageRouterBrowserSideImpl::OnCallbackFailure,
|
||||
router_.get(), browser_id_, query_id_, error_code,
|
||||
error_message));
|
||||
|
||||
|
@ -483,8 +483,9 @@ class CefMessageRouterBrowserSideImpl : public CefMessageRouterBrowserSide {
|
|||
bool notify_renderer) {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
// Must execute on the UI thread.
|
||||
CefPostTask(TID_UI,
|
||||
base::Bind(&CefMessageRouterBrowserSideImpl::CancelPendingFor,
|
||||
CefPostTask(
|
||||
TID_UI,
|
||||
base::BindOnce(&CefMessageRouterBrowserSideImpl::CancelPendingFor,
|
||||
this, browser, handler, notify_renderer));
|
||||
return;
|
||||
}
|
||||
|
@ -819,7 +820,7 @@ class CefMessageRouterRendererSideImpl : public CefMessageRouterRendererSide {
|
|||
const CefString& response = args->GetString(3);
|
||||
CefPostTask(
|
||||
TID_RENDERER,
|
||||
base::Bind(
|
||||
base::BindOnce(
|
||||
&CefMessageRouterRendererSideImpl::ExecuteSuccessCallback, this,
|
||||
browser->GetIdentifier(), context_id, request_id, response));
|
||||
} else {
|
||||
|
@ -828,7 +829,7 @@ class CefMessageRouterRendererSideImpl : public CefMessageRouterRendererSide {
|
|||
const CefString& error_message = args->GetString(4);
|
||||
CefPostTask(
|
||||
TID_RENDERER,
|
||||
base::Bind(
|
||||
base::BindOnce(
|
||||
&CefMessageRouterRendererSideImpl::ExecuteFailureCallback, this,
|
||||
browser->GetIdentifier(), context_id, request_id, error_code,
|
||||
error_message));
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "include/base/cef_callback.h"
|
||||
#include "include/base/cef_macros.h"
|
||||
#include "include/base/cef_weak_ptr.h"
|
||||
#include "include/cef_parser.h"
|
||||
|
@ -116,9 +117,9 @@ class DirectoryProvider : public CefResourceManager::Provider {
|
|||
const std::string& file_path = GetFilePath(url);
|
||||
|
||||
// Open |file_path| on the FILE thread.
|
||||
CefPostTask(
|
||||
TID_FILE_USER_BLOCKING,
|
||||
base::Bind(&DirectoryProvider::OpenOnFileThread, file_path, request));
|
||||
CefPostTask(TID_FILE_USER_BLOCKING,
|
||||
base::BindOnce(&DirectoryProvider::OpenOnFileThread, file_path,
|
||||
request));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -141,7 +142,8 @@ class DirectoryProvider : public CefResourceManager::Provider {
|
|||
CefStreamReader::CreateForFile(file_path);
|
||||
|
||||
// Continue loading on the IO thread.
|
||||
CefPostTask(TID_IO, base::Bind(&DirectoryProvider::ContinueOpenOnIOThread,
|
||||
CefPostTask(TID_IO,
|
||||
base::BindOnce(&DirectoryProvider::ContinueOpenOnIOThread,
|
||||
request, stream));
|
||||
}
|
||||
|
||||
|
@ -199,10 +201,10 @@ class ArchiveProvider : public CefResourceManager::Provider {
|
|||
pending_requests_.push_back(request);
|
||||
|
||||
// Load the archive file on the FILE thread.
|
||||
CefPostTask(
|
||||
TID_FILE_USER_BLOCKING,
|
||||
base::Bind(&ArchiveProvider::LoadOnFileThread,
|
||||
weak_ptr_factory_.GetWeakPtr(), archive_path_, password_));
|
||||
CefPostTask(TID_FILE_USER_BLOCKING,
|
||||
base::BindOnce(&ArchiveProvider::LoadOnFileThread,
|
||||
weak_ptr_factory_.GetWeakPtr(), archive_path_,
|
||||
password_));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -236,8 +238,8 @@ class ArchiveProvider : public CefResourceManager::Provider {
|
|||
DLOG(WARNING) << "Failed to load archive file: " << archive_path;
|
||||
}
|
||||
|
||||
CefPostTask(TID_IO,
|
||||
base::Bind(&ArchiveProvider::ContinueOnIOThread, ptr, archive));
|
||||
CefPostTask(TID_IO, base::BindOnce(&ArchiveProvider::ContinueOnIOThread,
|
||||
ptr, archive));
|
||||
}
|
||||
|
||||
void ContinueOnIOThread(CefRefPtr<CefZipArchive> archive) {
|
||||
|
@ -330,8 +332,8 @@ CefResourceManager::RequestState::~RequestState() {
|
|||
void CefResourceManager::Request::Continue(
|
||||
CefRefPtr<CefResourceHandler> handler) {
|
||||
if (!CefCurrentlyOn(TID_IO)) {
|
||||
CefPostTask(TID_IO, base::Bind(&CefResourceManager::Request::Continue, this,
|
||||
handler));
|
||||
CefPostTask(TID_IO, base::BindOnce(&CefResourceManager::Request::Continue,
|
||||
this, handler));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -342,13 +344,14 @@ void CefResourceManager::Request::Continue(
|
|||
// not called unexpectedly if Provider::OnRequest calls this method and then
|
||||
// calls CefResourceManager::Remove*.
|
||||
CefPostTask(TID_IO,
|
||||
base::Bind(&CefResourceManager::Request::ContinueOnIOThread,
|
||||
base::Passed(&state_), handler));
|
||||
base::BindOnce(&CefResourceManager::Request::ContinueOnIOThread,
|
||||
std::move(state_), handler));
|
||||
}
|
||||
|
||||
void CefResourceManager::Request::Stop() {
|
||||
if (!CefCurrentlyOn(TID_IO)) {
|
||||
CefPostTask(TID_IO, base::Bind(&CefResourceManager::Request::Stop, this));
|
||||
CefPostTask(TID_IO,
|
||||
base::BindOnce(&CefResourceManager::Request::Stop, this));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -358,8 +361,9 @@ void CefResourceManager::Request::Stop() {
|
|||
// Disassociate |state_| immediately so that Provider::OnRequestCanceled is
|
||||
// not called unexpectedly if Provider::OnRequest calls this method and then
|
||||
// calls CefResourceManager::Remove*.
|
||||
CefPostTask(TID_IO, base::Bind(&CefResourceManager::Request::StopOnIOThread,
|
||||
base::Passed(&state_)));
|
||||
CefPostTask(TID_IO,
|
||||
base::BindOnce(&CefResourceManager::Request::StopOnIOThread,
|
||||
std::move(state_)));
|
||||
}
|
||||
|
||||
CefResourceManager::Request::Request(std::unique_ptr<RequestState> state)
|
||||
|
@ -417,8 +421,8 @@ void CefResourceManager::Request::StopOnIOThread(
|
|||
// CefResourceManager implementation.
|
||||
|
||||
CefResourceManager::CefResourceManager()
|
||||
: url_filter_(base::Bind(GetFilteredUrl)),
|
||||
mime_type_resolver_(base::Bind(GetMimeType)) {}
|
||||
: url_filter_(base::BindRepeating(GetFilteredUrl)),
|
||||
mime_type_resolver_(base::BindRepeating(GetMimeType)) {}
|
||||
|
||||
CefResourceManager::~CefResourceManager() {
|
||||
CEF_REQUIRE_IO_THREAD();
|
||||
|
@ -467,7 +471,7 @@ void CefResourceManager::AddProvider(Provider* provider,
|
|||
return;
|
||||
|
||||
if (!CefCurrentlyOn(TID_IO)) {
|
||||
CefPostTask(TID_IO, base::Bind(&CefResourceManager::AddProvider, this,
|
||||
CefPostTask(TID_IO, base::BindOnce(&CefResourceManager::AddProvider, this,
|
||||
provider, order, identifier));
|
||||
return;
|
||||
}
|
||||
|
@ -492,8 +496,8 @@ void CefResourceManager::AddProvider(Provider* provider,
|
|||
|
||||
void CefResourceManager::RemoveProviders(const std::string& identifier) {
|
||||
if (!CefCurrentlyOn(TID_IO)) {
|
||||
CefPostTask(TID_IO, base::Bind(&CefResourceManager::RemoveProviders, this,
|
||||
identifier));
|
||||
CefPostTask(TID_IO, base::BindOnce(&CefResourceManager::RemoveProviders,
|
||||
this, identifier));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -512,7 +516,7 @@ void CefResourceManager::RemoveProviders(const std::string& identifier) {
|
|||
void CefResourceManager::RemoveAllProviders() {
|
||||
if (!CefCurrentlyOn(TID_IO)) {
|
||||
CefPostTask(TID_IO,
|
||||
base::Bind(&CefResourceManager::RemoveAllProviders, this));
|
||||
base::BindOnce(&CefResourceManager::RemoveAllProviders, this));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -526,7 +530,7 @@ void CefResourceManager::RemoveAllProviders() {
|
|||
|
||||
void CefResourceManager::SetMimeTypeResolver(const MimeTypeResolver& resolver) {
|
||||
if (!CefCurrentlyOn(TID_IO)) {
|
||||
CefPostTask(TID_IO, base::Bind(&CefResourceManager::SetMimeTypeResolver,
|
||||
CefPostTask(TID_IO, base::BindOnce(&CefResourceManager::SetMimeTypeResolver,
|
||||
this, resolver));
|
||||
return;
|
||||
}
|
||||
|
@ -534,20 +538,20 @@ void CefResourceManager::SetMimeTypeResolver(const MimeTypeResolver& resolver) {
|
|||
if (!resolver.is_null())
|
||||
mime_type_resolver_ = resolver;
|
||||
else
|
||||
mime_type_resolver_ = base::Bind(GetMimeType);
|
||||
mime_type_resolver_ = base::BindRepeating(GetMimeType);
|
||||
}
|
||||
|
||||
void CefResourceManager::SetUrlFilter(const UrlFilter& filter) {
|
||||
if (!CefCurrentlyOn(TID_IO)) {
|
||||
CefPostTask(TID_IO,
|
||||
base::Bind(&CefResourceManager::SetUrlFilter, this, filter));
|
||||
CefPostTask(TID_IO, base::BindOnce(&CefResourceManager::SetUrlFilter, this,
|
||||
filter));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!filter.is_null())
|
||||
url_filter_ = filter;
|
||||
else
|
||||
url_filter_ = base::Bind(GetFilteredUrl);
|
||||
url_filter_ = base::BindRepeating(GetFilteredUrl);
|
||||
}
|
||||
|
||||
cef_return_value_t CefResourceManager::OnBeforeResourceLoad(
|
||||
|
|
Loading…
Reference in New Issue