Commit 4cdba011 authored by Xida Chen's avatar Xida Chen Committed by Chromium LUCI CQ

[Code health] Convert base::Bind in mtp_device_map_service.cc

This CL converts the base::Bind in this file to base::BindOnce.
There should be no behaviour change.

Bug: 1152278
Change-Id: I7b3e30d51bd7d33de64458b163bb0fdbb14151fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2585819Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837053}
parent 951bbbb8
......@@ -1892,7 +1892,8 @@ void MTPDeviceDelegateImplLinux::EvictCachedPathToId(uint32_t id) {
void CreateMTPDeviceAsyncDelegate(
const std::string& device_location,
const bool read_only,
const CreateMTPDeviceAsyncDelegateCallback& callback) {
CreateMTPDeviceAsyncDelegateCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
callback.Run(new MTPDeviceDelegateImplLinux(device_location, read_only));
std::move(callback).Run(
new MTPDeviceDelegateImplLinux(device_location, read_only));
}
......@@ -39,7 +39,7 @@ class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate {
friend void CreateMTPDeviceAsyncDelegate(
const std::string&,
const bool read_only,
const CreateMTPDeviceAsyncDelegateCallback&);
CreateMTPDeviceAsyncDelegateCallback);
enum InitializationState {
UNINITIALIZED = 0,
......
......@@ -213,12 +213,12 @@ class MTPDeviceAsyncDelegate {
virtual ~MTPDeviceAsyncDelegate() {}
};
typedef base::Callback<void(MTPDeviceAsyncDelegate*)>
typedef base::OnceCallback<void(MTPDeviceAsyncDelegate*)>
CreateMTPDeviceAsyncDelegateCallback;
void CreateMTPDeviceAsyncDelegate(
const base::FilePath::StringType& device_location,
const bool read_only,
const CreateMTPDeviceAsyncDelegateCallback& callback);
CreateMTPDeviceAsyncDelegateCallback callback);
#endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_
......@@ -41,7 +41,7 @@ void MTPDeviceMapService::RegisterMTPFileSystem(
// to be created before use of it expects it to be there.
CreateMTPDeviceAsyncDelegate(
device_location, read_only,
base::Bind(&MTPDeviceMapService::AddAsyncDelegate,
base::BindOnce(&MTPDeviceMapService::AddAsyncDelegate,
base::Unretained(this), device_location, read_only));
mtp_device_usage_map_[key] = 0;
}
......
......@@ -558,7 +558,7 @@ MTPDeviceDelegateImplMac::ReadDirectoryRequest::~ReadDirectoryRequest() {}
void CreateMTPDeviceAsyncDelegate(
const base::FilePath::StringType& device_location,
const bool read_only,
const CreateMTPDeviceAsyncDelegateCallback& cb) {
CreateMTPDeviceAsyncDelegateCallback cb) {
// Write operation is not supported on Mac.
DCHECK(read_only);
......@@ -570,5 +570,5 @@ void CreateMTPDeviceAsyncDelegate(
DCHECK(cracked);
DCHECK_EQ(storage_monitor::StorageInfo::MAC_IMAGE_CAPTURE, type);
cb.Run(new MTPDeviceDelegateImplMac(device_id, device_location));
std::move(cb).Run(new MTPDeviceDelegateImplMac(device_id, device_location));
}
......@@ -294,7 +294,7 @@ void DeletePortableDeviceOnBlockingPoolThread(
// delegate on the IO thread.
void OnGetStorageInfoCreateDelegate(
const base::string16& device_location,
const CreateMTPDeviceAsyncDelegateCallback& callback,
CreateMTPDeviceAsyncDelegateCallback callback,
base::string16* pnp_device_id,
base::string16* storage_object_id,
bool succeeded) {
......@@ -303,15 +303,14 @@ void OnGetStorageInfoCreateDelegate(
DCHECK(storage_object_id);
if (!succeeded)
return;
callback.Run(new MTPDeviceDelegateImplWin(device_location,
*pnp_device_id,
*storage_object_id));
std::move(callback).Run(new MTPDeviceDelegateImplWin(
device_location, *pnp_device_id, *storage_object_id));
}
void CreateMTPDeviceAsyncDelegate(
const base::string16& device_location,
const bool read_only,
const CreateMTPDeviceAsyncDelegateCallback& callback) {
CreateMTPDeviceAsyncDelegateCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
// Write operation is not supported on Windows.
......@@ -325,8 +324,8 @@ void CreateMTPDeviceAsyncDelegate(
base::BindOnce(&GetStorageInfoOnUIThread, device_location,
base::Unretained(pnp_device_id),
base::Unretained(storage_object_id)),
base::BindOnce(&OnGetStorageInfoCreateDelegate, device_location, callback,
base::Owned(pnp_device_id),
base::BindOnce(&OnGetStorageInfoCreateDelegate, device_location,
std::move(callback), base::Owned(pnp_device_id),
base::Owned(storage_object_id)));
}
......
......@@ -60,7 +60,7 @@ class MTPDeviceDelegateImplWin : public MTPDeviceAsyncDelegate {
private:
friend void OnGetStorageInfoCreateDelegate(
const base::string16& device_location,
const CreateMTPDeviceAsyncDelegateCallback& callback,
CreateMTPDeviceAsyncDelegateCallback callback,
base::string16* pnp_device_id,
base::string16* storage_object_id,
bool succeeded);
......
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