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) { ...@@ -1892,7 +1892,8 @@ void MTPDeviceDelegateImplLinux::EvictCachedPathToId(uint32_t id) {
void CreateMTPDeviceAsyncDelegate( void CreateMTPDeviceAsyncDelegate(
const std::string& device_location, const std::string& device_location,
const bool read_only, const bool read_only,
const CreateMTPDeviceAsyncDelegateCallback& callback) { CreateMTPDeviceAsyncDelegateCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 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 { ...@@ -39,7 +39,7 @@ class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate {
friend void CreateMTPDeviceAsyncDelegate( friend void CreateMTPDeviceAsyncDelegate(
const std::string&, const std::string&,
const bool read_only, const bool read_only,
const CreateMTPDeviceAsyncDelegateCallback&); CreateMTPDeviceAsyncDelegateCallback);
enum InitializationState { enum InitializationState {
UNINITIALIZED = 0, UNINITIALIZED = 0,
......
...@@ -213,12 +213,12 @@ class MTPDeviceAsyncDelegate { ...@@ -213,12 +213,12 @@ class MTPDeviceAsyncDelegate {
virtual ~MTPDeviceAsyncDelegate() {} virtual ~MTPDeviceAsyncDelegate() {}
}; };
typedef base::Callback<void(MTPDeviceAsyncDelegate*)> typedef base::OnceCallback<void(MTPDeviceAsyncDelegate*)>
CreateMTPDeviceAsyncDelegateCallback; CreateMTPDeviceAsyncDelegateCallback;
void CreateMTPDeviceAsyncDelegate( void CreateMTPDeviceAsyncDelegate(
const base::FilePath::StringType& device_location, const base::FilePath::StringType& device_location,
const bool read_only, const bool read_only,
const CreateMTPDeviceAsyncDelegateCallback& callback); CreateMTPDeviceAsyncDelegateCallback callback);
#endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_ #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_
...@@ -41,8 +41,8 @@ void MTPDeviceMapService::RegisterMTPFileSystem( ...@@ -41,8 +41,8 @@ void MTPDeviceMapService::RegisterMTPFileSystem(
// to be created before use of it expects it to be there. // to be created before use of it expects it to be there.
CreateMTPDeviceAsyncDelegate( CreateMTPDeviceAsyncDelegate(
device_location, read_only, device_location, read_only,
base::Bind(&MTPDeviceMapService::AddAsyncDelegate, base::BindOnce(&MTPDeviceMapService::AddAsyncDelegate,
base::Unretained(this), device_location, read_only)); base::Unretained(this), device_location, read_only));
mtp_device_usage_map_[key] = 0; mtp_device_usage_map_[key] = 0;
} }
......
...@@ -558,7 +558,7 @@ MTPDeviceDelegateImplMac::ReadDirectoryRequest::~ReadDirectoryRequest() {} ...@@ -558,7 +558,7 @@ MTPDeviceDelegateImplMac::ReadDirectoryRequest::~ReadDirectoryRequest() {}
void CreateMTPDeviceAsyncDelegate( void CreateMTPDeviceAsyncDelegate(
const base::FilePath::StringType& device_location, const base::FilePath::StringType& device_location,
const bool read_only, const bool read_only,
const CreateMTPDeviceAsyncDelegateCallback& cb) { CreateMTPDeviceAsyncDelegateCallback cb) {
// Write operation is not supported on Mac. // Write operation is not supported on Mac.
DCHECK(read_only); DCHECK(read_only);
...@@ -570,5 +570,5 @@ void CreateMTPDeviceAsyncDelegate( ...@@ -570,5 +570,5 @@ void CreateMTPDeviceAsyncDelegate(
DCHECK(cracked); DCHECK(cracked);
DCHECK_EQ(storage_monitor::StorageInfo::MAC_IMAGE_CAPTURE, type); 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( ...@@ -294,7 +294,7 @@ void DeletePortableDeviceOnBlockingPoolThread(
// delegate on the IO thread. // delegate on the IO thread.
void OnGetStorageInfoCreateDelegate( void OnGetStorageInfoCreateDelegate(
const base::string16& device_location, const base::string16& device_location,
const CreateMTPDeviceAsyncDelegateCallback& callback, CreateMTPDeviceAsyncDelegateCallback callback,
base::string16* pnp_device_id, base::string16* pnp_device_id,
base::string16* storage_object_id, base::string16* storage_object_id,
bool succeeded) { bool succeeded) {
...@@ -303,15 +303,14 @@ void OnGetStorageInfoCreateDelegate( ...@@ -303,15 +303,14 @@ void OnGetStorageInfoCreateDelegate(
DCHECK(storage_object_id); DCHECK(storage_object_id);
if (!succeeded) if (!succeeded)
return; return;
callback.Run(new MTPDeviceDelegateImplWin(device_location, std::move(callback).Run(new MTPDeviceDelegateImplWin(
*pnp_device_id, device_location, *pnp_device_id, *storage_object_id));
*storage_object_id));
} }
void CreateMTPDeviceAsyncDelegate( void CreateMTPDeviceAsyncDelegate(
const base::string16& device_location, const base::string16& device_location,
const bool read_only, const bool read_only,
const CreateMTPDeviceAsyncDelegateCallback& callback) { CreateMTPDeviceAsyncDelegateCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO); DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
// Write operation is not supported on Windows. // Write operation is not supported on Windows.
...@@ -325,8 +324,8 @@ void CreateMTPDeviceAsyncDelegate( ...@@ -325,8 +324,8 @@ void CreateMTPDeviceAsyncDelegate(
base::BindOnce(&GetStorageInfoOnUIThread, device_location, base::BindOnce(&GetStorageInfoOnUIThread, device_location,
base::Unretained(pnp_device_id), base::Unretained(pnp_device_id),
base::Unretained(storage_object_id)), base::Unretained(storage_object_id)),
base::BindOnce(&OnGetStorageInfoCreateDelegate, device_location, callback, base::BindOnce(&OnGetStorageInfoCreateDelegate, device_location,
base::Owned(pnp_device_id), std::move(callback), base::Owned(pnp_device_id),
base::Owned(storage_object_id))); base::Owned(storage_object_id)));
} }
......
...@@ -60,7 +60,7 @@ class MTPDeviceDelegateImplWin : public MTPDeviceAsyncDelegate { ...@@ -60,7 +60,7 @@ class MTPDeviceDelegateImplWin : public MTPDeviceAsyncDelegate {
private: private:
friend void OnGetStorageInfoCreateDelegate( friend void OnGetStorageInfoCreateDelegate(
const base::string16& device_location, const base::string16& device_location,
const CreateMTPDeviceAsyncDelegateCallback& callback, CreateMTPDeviceAsyncDelegateCallback callback,
base::string16* pnp_device_id, base::string16* pnp_device_id,
base::string16* storage_object_id, base::string16* storage_object_id,
bool succeeded); 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