Commit 56432d95 authored by tzik's avatar tzik Committed by Commit bot

Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/policy

This is a generated CL by a clang refactoring tool at //tools/clang/base_bind_rewriters.
The tool rewrites base::Bind to base::BindOnce where the resulting Callback
is immediately converted to OnceCallback.
E.g.:
  base::PostTask(FROM_HERE, base::Bind(&Foo));
is rewritten to:
  base::PostTask(FROM_HERE, base::BindOnce(&Foo));

In terms of the behavior change after the rewrite, the OnceCallback
implementation moves out the bound argument to the target function, unlike
Callback.

BUG=554299

Review-Url: https://codereview.chromium.org/2826843004
Cr-Commit-Position: refs/heads/master@{#467242}
parent e169ccbe
......@@ -266,10 +266,9 @@ void CloudPolicyInvalidator::HandleInvalidation(
// Schedule the policy to be refreshed.
task_runner_->PostDelayedTask(
FROM_HERE,
base::Bind(
&CloudPolicyInvalidator::RefreshPolicy,
weak_factory_.GetWeakPtr(),
payload.empty() /* is_missing_payload */),
base::BindOnce(&CloudPolicyInvalidator::RefreshPolicy,
weak_factory_.GetWeakPtr(),
payload.empty() /* is_missing_payload */),
delay);
}
......
......@@ -232,8 +232,8 @@ net::URLRequestJob* TestRequestInterceptor::Delegate::MaybeInterceptRequest(
new std::vector<base::Closure>);
callbacks->swap(request_serviced_callbacks_);
io_task_runner_->PostTask(
FROM_HERE, base::Bind(&Delegate::InvokeRequestServicedCallbacks,
base::Passed(&callbacks)));
FROM_HERE, base::BindOnce(&Delegate::InvokeRequestServicedCallbacks,
base::Passed(&callbacks)));
}
JobCallback callback = pending_job_callbacks_.front();
......@@ -344,12 +344,9 @@ void TestRequestInterceptor::PostToIOAndWait(const base::Closure& task) {
io_task_runner_->PostTask(FROM_HERE, task);
base::RunLoop run_loop;
io_task_runner_->PostTask(
FROM_HERE,
base::Bind(
base::IgnoreResult(&base::TaskRunner::PostTask),
base::ThreadTaskRunnerHandle::Get(),
FROM_HERE,
run_loop.QuitClosure()));
FROM_HERE, base::BindOnce(base::IgnoreResult(&base::TaskRunner::PostTask),
base::ThreadTaskRunnerHandle::Get(), FROM_HERE,
run_loop.QuitClosure()));
run_loop.Run();
}
......
......@@ -120,7 +120,7 @@ void UserPolicySigninServiceBase::OnClientError(CloudPolicyClient* client) {
// the CloudPolicyClient, so queue up a task to do the shutdown.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(
base::BindOnce(
&UserPolicySigninServiceBase::ShutdownUserCloudPolicyManager,
weak_factory_.GetWeakPtr()));
} else {
......
......@@ -342,14 +342,15 @@ class MakeRequestFail {
// Sets up the filter on IO thread such that requests to |host| fail.
explicit MakeRequestFail(const std::string& host) : host_(host) {
BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE,
base::Bind(MakeRequestFailOnIO, host_),
base::BindOnce(MakeRequestFailOnIO, host_),
base::MessageLoop::QuitWhenIdleClosure());
content::RunMessageLoop();
}
~MakeRequestFail() {
BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE,
base::Bind(UndoMakeRequestFailOnIO, host_),
base::MessageLoop::QuitWhenIdleClosure());
BrowserThread::PostTaskAndReply(
BrowserThread::IO, FROM_HERE,
base::BindOnce(UndoMakeRequestFailOnIO, host_),
base::MessageLoop::QuitWhenIdleClosure());
content::RunMessageLoop();
}
......@@ -637,7 +638,7 @@ class PolicyTest : public InProcessBrowserTest {
void SetUpOnMainThread() override {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(chrome_browser_net::SetUrlRequestMocksEnabled, true));
base::BindOnce(chrome_browser_net::SetUrlRequestMocksEnabled, true));
if (extension_service()->updater()) {
extension_service()->updater()->SetExtensionCacheForTesting(
test_extension_cache_.get());
......@@ -651,8 +652,8 @@ class PolicyTest : public InProcessBrowserTest {
PathService::Get(content::DIR_TEST_DATA, &root_http);
BrowserThread::PostTaskAndReply(
BrowserThread::IO, FROM_HERE,
base::Bind(URLRequestMockHTTPJob::AddUrlHandlers, root_http,
make_scoped_refptr(BrowserThread::GetBlockingPool())),
base::BindOnce(URLRequestMockHTTPJob::AddUrlHandlers, root_http,
make_scoped_refptr(BrowserThread::GetBlockingPool())),
base::MessageLoop::current()->QuitWhenIdleClosure());
content::RunMessageLoop();
}
......@@ -1247,8 +1248,9 @@ bool GetPacHttpsUrlStrippingEnabled() {
base::RunLoop loop;
BrowserThread::PostTaskAndReply(
BrowserThread::IO, FROM_HERE,
base::Bind(&GetPacHttpsUrlStrippingEnabledOnIOThread,
g_browser_process->io_thread(), base::Unretained(&enabled)),
base::BindOnce(&GetPacHttpsUrlStrippingEnabledOnIOThread,
g_browser_process->io_thread(),
base::Unretained(&enabled)),
loop.QuitClosure());
loop.Run();
return enabled;
......@@ -2352,7 +2354,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, URLBlacklist) {
base::RunLoop loop;
BrowserThread::PostTaskAndReply(
BrowserThread::IO, FROM_HERE,
base::Bind(RedirectHostsToTestData, kURLS, arraysize(kURLS)),
base::BindOnce(RedirectHostsToTestData, kURLS, arraysize(kURLS)),
loop.QuitClosure());
loop.Run();
}
......@@ -2390,7 +2392,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, URLBlacklist) {
base::RunLoop loop;
BrowserThread::PostTaskAndReply(
BrowserThread::IO, FROM_HERE,
base::Bind(UndoRedirectHostsToTestData, kURLS, arraysize(kURLS)),
base::BindOnce(UndoRedirectHostsToTestData, kURLS, arraysize(kURLS)),
loop.QuitClosure());
loop.Run();
}
......@@ -2961,10 +2963,9 @@ class RestoreOnStartupPolicyTest
void SetUpOnMainThread() override {
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
base::Bind(
RedirectHostsToTestData, kRestoredURLs, arraysize(kRestoredURLs)));
BrowserThread::IO, FROM_HERE,
base::BindOnce(RedirectHostsToTestData, kRestoredURLs,
arraysize(kRestoredURLs)));
}
void ListOfURLs() {
......@@ -3272,11 +3273,12 @@ IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerBrowserTest,
content::BrowserThread::PostTaskAndReply(
content::BrowserThread::IO, FROM_HERE,
base::Bind(&MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices,
base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()),
audio_devices),
base::Bind(&MediaStreamDevicesControllerBrowserTest::FinishAudioTest,
base::Unretained(this)));
base::BindOnce(
&MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices,
base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()),
audio_devices),
base::BindOnce(&MediaStreamDevicesControllerBrowserTest::FinishAudioTest,
base::Unretained(this)));
base::RunLoop().Run();
}
......@@ -3304,11 +3306,11 @@ IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerBrowserTest,
content::BrowserThread::PostTaskAndReply(
content::BrowserThread::IO, FROM_HERE,
base::Bind(
base::BindOnce(
&MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices,
base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()),
audio_devices),
base::Bind(
base::BindOnce(
&MediaStreamDevicesControllerBrowserTest::FinishAudioTest,
base::Unretained(this)));
......@@ -3329,11 +3331,12 @@ IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerBrowserTest,
content::BrowserThread::PostTaskAndReply(
content::BrowserThread::IO, FROM_HERE,
base::Bind(&MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices,
base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()),
video_devices),
base::Bind(&MediaStreamDevicesControllerBrowserTest::FinishVideoTest,
base::Unretained(this)));
base::BindOnce(
&MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices,
base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()),
video_devices),
base::BindOnce(&MediaStreamDevicesControllerBrowserTest::FinishVideoTest,
base::Unretained(this)));
base::RunLoop().Run();
}
......@@ -3361,10 +3364,11 @@ IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerBrowserTest,
content::BrowserThread::PostTaskAndReply(
content::BrowserThread::IO, FROM_HERE,
base::Bind(&MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices,
base::BindOnce(
&MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices,
base::Unretained(MediaCaptureDevicesDispatcher::GetInstance()),
video_devices),
base::Bind(
base::BindOnce(
&MediaStreamDevicesControllerBrowserTest::FinishVideoTest,
base::Unretained(this)));
......@@ -3443,8 +3447,8 @@ IN_PROC_BROWSER_TEST_F(PolicyTest,
// Require CT for all hosts (in the absence of policy).
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(net::TransportSecurityState::SetShouldRequireCTForTesting,
base::Owned(new bool(true))));
base::BindOnce(net::TransportSecurityState::SetShouldRequireCTForTesting,
base::Owned(new bool(true))));
ui_test_utils::NavigateToURL(browser(), https_server_ok.GetURL("/"));
......@@ -3896,7 +3900,7 @@ void ComponentUpdaterPolicyTest::UpdateComponent(
void ComponentUpdaterPolicyTest::CallAsync(TestCaseAction action) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(action, base::Unretained(this)));
base::BindOnce(action, base::Unretained(this)));
}
void ComponentUpdaterPolicyTest::OnDemandComplete(update_client::Error error) {
......
......@@ -57,8 +57,8 @@ bool IsQuicEnabled(
bool is_quic_enabled = false;
content::BrowserThread::PostTaskAndReply(
content::BrowserThread::IO, FROM_HERE,
base::Bind(IsQuicEnabledOnIOThread, request_context_getter,
&is_quic_enabled),
base::BindOnce(IsQuicEnabledOnIOThread, request_context_getter,
&is_quic_enabled),
run_loop.QuitClosure());
run_loop.Run();
return is_quic_enabled;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment