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(
options->callback = callback;
options->disk = std::move(disk);
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
base::Bind(EjectDisk, options));
base::BindOnce(EjectDisk, options));
}
// static
......
......@@ -62,9 +62,9 @@ class StorageMonitorMacTest : public testing::Test {
void UpdateDisk(StorageInfo info, StorageMonitorMac::UpdateType update_type) {
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(&StorageMonitorMac::UpdateDisk,
base::Unretained(monitor_.get()), update_type,
base::Owned(new std::string("dummy_bsd_name")), info));
base::BindOnce(&StorageMonitorMac::UpdateDisk,
base::Unretained(monitor_.get()), update_type,
base::Owned(new std::string("dummy_bsd_name")), info));
base::RunLoop().RunUntilIdle();
}
......
......@@ -227,7 +227,7 @@ void EjectDeviceInThreadPool(
device != device.DirName()) {
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_FAILURE));
base::BindOnce(callback, StorageMonitor::EJECT_FAILURE));
return;
}
base::SStringPrintf(&volume_name, L"\\\\.\\%lc:", drive_letter);
......@@ -239,7 +239,7 @@ void EjectDeviceInThreadPool(
if (!volume_handle.IsValid()) {
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_FAILURE));
base::BindOnce(callback, StorageMonitor::EJECT_FAILURE));
return;
}
......@@ -269,7 +269,7 @@ void EjectDeviceInThreadPool(
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_IN_USE));
base::BindOnce(callback, StorageMonitor::EJECT_IN_USE));
return;
}
......@@ -285,8 +285,9 @@ void EjectDeviceInThreadPool(
if (!dismounted) {
DeviceIoControl(volume_handle.Get(), FSCTL_UNLOCK_VOLUME, nullptr, 0,
nullptr, 0, &bytes_returned, nullptr);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_OK));
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, StorageMonitor::EJECT_OK));
return;
}
......@@ -298,7 +299,7 @@ void EjectDeviceInThreadPool(
&bytes_returned, nullptr)) {
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_FAILURE));
base::BindOnce(callback, StorageMonitor::EJECT_FAILURE));
return;
}
......@@ -307,12 +308,12 @@ void EjectDeviceInThreadPool(
0, nullptr, 0, &bytes_returned, nullptr)) {
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_FAILURE));
base::BindOnce(callback, StorageMonitor::EJECT_FAILURE));
return;
}
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::Bind(callback, StorageMonitor::EJECT_OK));
base::BindOnce(callback, StorageMonitor::EJECT_OK));
}
} // namespace
......@@ -377,15 +378,15 @@ void VolumeMountWatcherWin::RetrieveInfoForDeviceAndAdd(
if (!get_device_details_callback.Run(device_path, &info)) {
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::Bind(&VolumeMountWatcherWin::DeviceCheckComplete, volume_watcher,
device_path));
base::BindOnce(&VolumeMountWatcherWin::DeviceCheckComplete,
volume_watcher, device_path));
return;
}
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::Bind(&VolumeMountWatcherWin::HandleDeviceAttachEventOnUIThread,
volume_watcher, device_path, info));
base::BindOnce(&VolumeMountWatcherWin::HandleDeviceAttachEventOnUIThread,
volume_watcher, device_path, info));
}
void VolumeMountWatcherWin::DeviceCheckComplete(
......
......@@ -61,8 +61,8 @@ void WebRestrictionsClient::SetAuthority(
// accessed from the IO thread.
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::Bind(&WebRestrictionsClient::SetAuthorityTask,
base::Unretained(this), content_provider_authority));
base::BindOnce(&WebRestrictionsClient::SetAuthorityTask,
base::Unretained(this), content_provider_authority));
}
void WebRestrictionsClient::SetAuthorityTask(
......@@ -136,9 +136,9 @@ void WebRestrictionsClient::RequestPermission(
void WebRestrictionsClient::OnWebRestrictionsChanged(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj) {
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::Bind(&WebRestrictionsClient::ClearCache, base::Unretained(this)));
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&WebRestrictionsClient::ClearCache,
base::Unretained(this)));
}
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