Commit a44e5ade authored by kylechar's avatar kylechar Committed by Commit Bot

Use base::BindOnce for Post[Delayed]TaskWithTraits callbacks.

Post[Delayed]TaskWithTraits() takes a OnceCallback. Replace usage of
base::Bind(), which produces a RepeatingCallback, with base::BindOnce()
when the callback is created as a temporary inside of PostTask(). The
following regex was used to find instances that could be replaced:

(Post(?:Delayed)?TaskWithTraits)\((?:\n\s*)?FROM_HERE,\n?\s*(\{.*?\n?.*?\}),(?:\n)?\s*base::Bind\(

Also replace any usage of base::Passed(&var) with std::move(var) for
variables passed to base::BindOnce(). base::Passed() isn't needed for
move-only types with OnceCallbacks.

This CL was uploaded by git cl split.

R=blundell@chromium.org

Bug: 714018
Change-Id: I4268e80cb016b4a8958ea4803656396f66854f11
Reviewed-on: https://chromium-review.googlesource.com/c/1486611
Auto-Submit: kylechar <kylechar@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635452}
parent efd1e4cf
...@@ -306,7 +306,7 @@ void StorageMonitorMac::EjectDevice( ...@@ -306,7 +306,7 @@ void StorageMonitorMac::EjectDevice(
options->callback = callback; options->callback = callback;
options->disk = std::move(disk); options->disk = std::move(disk);
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
base::Bind(EjectDisk, options)); base::BindOnce(EjectDisk, options));
} }
// static // static
......
...@@ -62,7 +62,7 @@ class StorageMonitorMacTest : public testing::Test { ...@@ -62,7 +62,7 @@ class StorageMonitorMacTest : public testing::Test {
void UpdateDisk(StorageInfo info, StorageMonitorMac::UpdateType update_type) { void UpdateDisk(StorageInfo info, StorageMonitorMac::UpdateType update_type) {
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI}, FROM_HERE, {content::BrowserThread::UI},
base::Bind(&StorageMonitorMac::UpdateDisk, base::BindOnce(&StorageMonitorMac::UpdateDisk,
base::Unretained(monitor_.get()), update_type, base::Unretained(monitor_.get()), update_type,
base::Owned(new std::string("dummy_bsd_name")), info)); base::Owned(new std::string("dummy_bsd_name")), info));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
......
...@@ -227,7 +227,7 @@ void EjectDeviceInThreadPool( ...@@ -227,7 +227,7 @@ void EjectDeviceInThreadPool(
device != device.DirName()) { device != device.DirName()) {
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_FAILURE)); base::BindOnce(callback, StorageMonitor::EJECT_FAILURE));
return; return;
} }
base::SStringPrintf(&volume_name, L"\\\\.\\%lc:", drive_letter); base::SStringPrintf(&volume_name, L"\\\\.\\%lc:", drive_letter);
...@@ -239,7 +239,7 @@ void EjectDeviceInThreadPool( ...@@ -239,7 +239,7 @@ void EjectDeviceInThreadPool(
if (!volume_handle.IsValid()) { if (!volume_handle.IsValid()) {
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_FAILURE)); base::BindOnce(callback, StorageMonitor::EJECT_FAILURE));
return; return;
} }
...@@ -269,7 +269,7 @@ void EjectDeviceInThreadPool( ...@@ -269,7 +269,7 @@ void EjectDeviceInThreadPool(
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_IN_USE)); base::BindOnce(callback, StorageMonitor::EJECT_IN_USE));
return; return;
} }
...@@ -285,8 +285,9 @@ void EjectDeviceInThreadPool( ...@@ -285,8 +285,9 @@ void EjectDeviceInThreadPool(
if (!dismounted) { if (!dismounted) {
DeviceIoControl(volume_handle.Get(), FSCTL_UNLOCK_VOLUME, nullptr, 0, DeviceIoControl(volume_handle.Get(), FSCTL_UNLOCK_VOLUME, nullptr, 0,
nullptr, 0, &bytes_returned, nullptr); nullptr, 0, &bytes_returned, nullptr);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, base::PostTaskWithTraits(
base::Bind(callback, StorageMonitor::EJECT_OK)); FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, StorageMonitor::EJECT_OK));
return; return;
} }
...@@ -298,7 +299,7 @@ void EjectDeviceInThreadPool( ...@@ -298,7 +299,7 @@ void EjectDeviceInThreadPool(
&bytes_returned, nullptr)) { &bytes_returned, nullptr)) {
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_FAILURE)); base::BindOnce(callback, StorageMonitor::EJECT_FAILURE));
return; return;
} }
...@@ -307,12 +308,12 @@ void EjectDeviceInThreadPool( ...@@ -307,12 +308,12 @@ void EjectDeviceInThreadPool(
0, nullptr, 0, &bytes_returned, nullptr)) { 0, nullptr, 0, &bytes_returned, nullptr)) {
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_FAILURE)); base::BindOnce(callback, StorageMonitor::EJECT_FAILURE));
return; return;
} }
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_OK)); base::BindOnce(callback, StorageMonitor::EJECT_OK));
} }
} // namespace } // namespace
...@@ -377,14 +378,14 @@ void VolumeMountWatcherWin::RetrieveInfoForDeviceAndAdd( ...@@ -377,14 +378,14 @@ void VolumeMountWatcherWin::RetrieveInfoForDeviceAndAdd(
if (!get_device_details_callback.Run(device_path, &info)) { if (!get_device_details_callback.Run(device_path, &info)) {
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::Bind(&VolumeMountWatcherWin::DeviceCheckComplete, volume_watcher, base::BindOnce(&VolumeMountWatcherWin::DeviceCheckComplete,
device_path)); volume_watcher, device_path));
return; return;
} }
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::Bind(&VolumeMountWatcherWin::HandleDeviceAttachEventOnUIThread, base::BindOnce(&VolumeMountWatcherWin::HandleDeviceAttachEventOnUIThread,
volume_watcher, device_path, info)); volume_watcher, device_path, info));
} }
......
...@@ -61,7 +61,7 @@ void WebRestrictionsClient::SetAuthority( ...@@ -61,7 +61,7 @@ void WebRestrictionsClient::SetAuthority(
// accessed from the IO thread. // accessed from the IO thread.
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO}, FROM_HERE, {content::BrowserThread::IO},
base::Bind(&WebRestrictionsClient::SetAuthorityTask, base::BindOnce(&WebRestrictionsClient::SetAuthorityTask,
base::Unretained(this), content_provider_authority)); base::Unretained(this), content_provider_authority));
} }
...@@ -136,9 +136,9 @@ void WebRestrictionsClient::RequestPermission( ...@@ -136,9 +136,9 @@ void WebRestrictionsClient::RequestPermission(
void WebRestrictionsClient::OnWebRestrictionsChanged( void WebRestrictionsClient::OnWebRestrictionsChanged(
JNIEnv* env, JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj) { const base::android::JavaParamRef<jobject>& obj) {
base::PostTaskWithTraits( base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
FROM_HERE, {content::BrowserThread::IO}, base::BindOnce(&WebRestrictionsClient::ClearCache,
base::Bind(&WebRestrictionsClient::ClearCache, base::Unretained(this))); base::Unretained(this)));
} }
void WebRestrictionsClient::RecordURLAccess(const std::string& url) { void WebRestrictionsClient::RecordURLAccess(const std::string& url) {
......
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