chore: convert session base::Bind instances (#18038)
Convert instances of base::Bind to base::BindOnce and base::BindRepeating as applicable in the session module as well as in Autofill popups.
This commit is contained in:
parent
61effac72a
commit
f316c8470c
4 changed files with 24 additions and 25 deletions
|
@ -350,9 +350,8 @@ v8::Local<v8::Promise> Session::ResolveProxy(mate::Arguments* args) {
|
||||||
args->GetNext(&url);
|
args->GetNext(&url);
|
||||||
|
|
||||||
browser_context_->GetResolveProxyHelper()->ResolveProxy(
|
browser_context_->GetResolveProxyHelper()->ResolveProxy(
|
||||||
url,
|
url, base::BindOnce(util::Promise::ResolvePromise<std::string>,
|
||||||
base::Bind(util::CopyablePromise::ResolveCopyablePromise<std::string>,
|
std::move(promise)));
|
||||||
util::CopyablePromise(promise)));
|
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
@ -413,8 +412,7 @@ v8::Local<v8::Promise> Session::ClearStorageData(mate::Arguments* args) {
|
||||||
storage_partition->ClearData(
|
storage_partition->ClearData(
|
||||||
options.storage_types, options.quota_types, options.origin, base::Time(),
|
options.storage_types, options.quota_types, options.origin, base::Time(),
|
||||||
base::Time::Max(),
|
base::Time::Max(),
|
||||||
base::Bind(util::CopyablePromise::ResolveEmptyCopyablePromise,
|
base::BindOnce(util::Promise::ResolveEmptyPromise, std::move(promise)));
|
||||||
util::CopyablePromise(promise)));
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,17 +494,18 @@ void Session::DisableNetworkEmulation() {
|
||||||
network_emulation_token_, network::mojom::NetworkConditions::New());
|
network_emulation_token_, network::mojom::NetworkConditions::New());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WrapVerifyProc(base::Callback<void(const VerifyRequestParams& request,
|
void WrapVerifyProc(
|
||||||
base::Callback<void(int)>)> proc,
|
base::RepeatingCallback<void(const VerifyRequestParams& request,
|
||||||
const VerifyRequestParams& request,
|
base::RepeatingCallback<void(int)>)> proc,
|
||||||
base::OnceCallback<void(int)> cb) {
|
const VerifyRequestParams& request,
|
||||||
|
base::OnceCallback<void(int)> cb) {
|
||||||
proc.Run(request, base::AdaptCallbackForRepeating(std::move(cb)));
|
proc.Run(request, base::AdaptCallbackForRepeating(std::move(cb)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
|
void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
base::Callback<void(const VerifyRequestParams& request,
|
base::RepeatingCallback<void(const VerifyRequestParams& request,
|
||||||
base::Callback<void(int)>)>
|
base::RepeatingCallback<void(int)>)>
|
||||||
proc;
|
proc;
|
||||||
if (!(val->IsNull() || mate::ConvertFromV8(args->isolate(), val, &proc))) {
|
if (!(val->IsNull() || mate::ConvertFromV8(args->isolate(), val, &proc))) {
|
||||||
args->ThrowError("Must pass null or function");
|
args->ThrowError("Must pass null or function");
|
||||||
|
@ -517,7 +516,7 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
|
||||||
FROM_HERE, {BrowserThread::IO},
|
FROM_HERE, {BrowserThread::IO},
|
||||||
base::BindOnce(&SetCertVerifyProcInIO,
|
base::BindOnce(&SetCertVerifyProcInIO,
|
||||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||||
base::Bind(&WrapVerifyProc, proc)));
|
base::BindRepeating(&WrapVerifyProc, proc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
||||||
|
@ -645,7 +644,7 @@ void Session::CreateInterruptedDownload(const mate::Dictionary& options) {
|
||||||
}
|
}
|
||||||
auto* download_manager =
|
auto* download_manager =
|
||||||
content::BrowserContext::GetDownloadManager(browser_context());
|
content::BrowserContext::GetDownloadManager(browser_context());
|
||||||
download_manager->GetDelegate()->GetNextId(base::Bind(
|
download_manager->GetDelegate()->GetNextId(base::BindRepeating(
|
||||||
&DownloadIdCallback, download_manager, path, url_chain, mime_type, offset,
|
&DownloadIdCallback, download_manager, path, url_chain, mime_type, offset,
|
||||||
length, last_modified, etag, base::Time::FromDoubleT(start_time)));
|
length, last_modified, etag, base::Time::FromDoubleT(start_time)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,10 @@ ResolveProxyHelper::~ResolveProxyHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResolveProxyHelper::ResolveProxy(const GURL& url,
|
void ResolveProxyHelper::ResolveProxy(const GURL& url,
|
||||||
const ResolveProxyCallback& callback) {
|
ResolveProxyCallback callback) {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||||
// Enqueue the pending request.
|
// Enqueue the pending request.
|
||||||
pending_requests_.push_back(PendingRequest(url, callback));
|
pending_requests_.push_back(PendingRequest(url, std::move(callback)));
|
||||||
|
|
||||||
// If nothing is in progress, start.
|
// If nothing is in progress, start.
|
||||||
if (!binding_.is_bound()) {
|
if (!binding_.is_bound()) {
|
||||||
|
@ -76,7 +76,7 @@ void ResolveProxyHelper::OnProxyLookupComplete(
|
||||||
proxy = proxy_info->ToPacString();
|
proxy = proxy_info->ToPacString();
|
||||||
|
|
||||||
if (!completed_request.callback.is_null())
|
if (!completed_request.callback.is_null())
|
||||||
completed_request.callback.Run(proxy);
|
std::move(completed_request.callback).Run(proxy);
|
||||||
|
|
||||||
// Start the next request.
|
// Start the next request.
|
||||||
if (!pending_requests_.empty())
|
if (!pending_requests_.empty())
|
||||||
|
@ -85,8 +85,8 @@ void ResolveProxyHelper::OnProxyLookupComplete(
|
||||||
|
|
||||||
ResolveProxyHelper::PendingRequest::PendingRequest(
|
ResolveProxyHelper::PendingRequest::PendingRequest(
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
const ResolveProxyCallback& callback)
|
ResolveProxyCallback callback)
|
||||||
: url(url), callback(callback) {}
|
: url(url), callback(std::move(callback)) {}
|
||||||
|
|
||||||
ResolveProxyHelper::PendingRequest::PendingRequest(
|
ResolveProxyHelper::PendingRequest::PendingRequest(
|
||||||
ResolveProxyHelper::PendingRequest&& pending_request) = default;
|
ResolveProxyHelper::PendingRequest&& pending_request) = default;
|
||||||
|
|
|
@ -22,11 +22,11 @@ class ResolveProxyHelper
|
||||||
: public base::RefCountedThreadSafe<ResolveProxyHelper>,
|
: public base::RefCountedThreadSafe<ResolveProxyHelper>,
|
||||||
network::mojom::ProxyLookupClient {
|
network::mojom::ProxyLookupClient {
|
||||||
public:
|
public:
|
||||||
using ResolveProxyCallback = base::Callback<void(std::string)>;
|
using ResolveProxyCallback = base::OnceCallback<void(std::string)>;
|
||||||
|
|
||||||
explicit ResolveProxyHelper(AtomBrowserContext* browser_context);
|
explicit ResolveProxyHelper(AtomBrowserContext* browser_context);
|
||||||
|
|
||||||
void ResolveProxy(const GURL& url, const ResolveProxyCallback& callback);
|
void ResolveProxy(const GURL& url, ResolveProxyCallback callback);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~ResolveProxyHelper() override;
|
~ResolveProxyHelper() override;
|
||||||
|
@ -36,7 +36,7 @@ class ResolveProxyHelper
|
||||||
// A PendingRequest is a resolve request that is in progress, or queued.
|
// A PendingRequest is a resolve request that is in progress, or queued.
|
||||||
struct PendingRequest {
|
struct PendingRequest {
|
||||||
public:
|
public:
|
||||||
PendingRequest(const GURL& url, const ResolveProxyCallback& callback);
|
PendingRequest(const GURL& url, ResolveProxyCallback callback);
|
||||||
PendingRequest(PendingRequest&& pending_request) noexcept;
|
PendingRequest(PendingRequest&& pending_request) noexcept;
|
||||||
~PendingRequest();
|
~PendingRequest();
|
||||||
|
|
||||||
|
|
|
@ -93,8 +93,8 @@ void AutofillPopupView::Show() {
|
||||||
if (initialize_widget)
|
if (initialize_widget)
|
||||||
views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this);
|
views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this);
|
||||||
|
|
||||||
keypress_callback_ = base::Bind(&AutofillPopupView::HandleKeyPressEvent,
|
keypress_callback_ = base::BindRepeating(
|
||||||
base::Unretained(this));
|
&AutofillPopupView::HandleKeyPressEvent, base::Unretained(this));
|
||||||
auto* host = popup_->frame_host_->GetRenderViewHost()->GetWidget();
|
auto* host = popup_->frame_host_->GetRenderViewHost()->GetWidget();
|
||||||
host->AddKeyPressEventCallback(keypress_callback_);
|
host->AddKeyPressEventCallback(keypress_callback_);
|
||||||
|
|
||||||
|
@ -294,8 +294,8 @@ void AutofillPopupView::OnMouseExited(const ui::MouseEvent& event) {
|
||||||
// OnMouseExited event. Pressing return should activate the current selection
|
// OnMouseExited event. Pressing return should activate the current selection
|
||||||
// via AcceleratorPressed, so we need to let that run first.
|
// via AcceleratorPressed, so we need to let that run first.
|
||||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||||
FROM_HERE, base::Bind(&AutofillPopupView::ClearSelection,
|
FROM_HERE, base::BindOnce(&AutofillPopupView::ClearSelection,
|
||||||
weak_ptr_factory_.GetWeakPtr()));
|
weak_ptr_factory_.GetWeakPtr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutofillPopupView::OnMouseMoved(const ui::MouseEvent& event) {
|
void AutofillPopupView::OnMouseMoved(const ui::MouseEvent& event) {
|
||||||
|
|
Loading…
Reference in a new issue