Commit bc654169 authored by Donna Wu's avatar Donna Wu Committed by Commit Bot

Get existing GetStorageInfoFromDevice method align with mojo format.

BUG=769630

Change-Id: I1985c14b93872b887d14bbcd5697e431c845ba8b
Reviewed-on: https://chromium-review.googlesource.com/1069983
Commit-Queue: Donna Wu <donna.wu@intel.com>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561366}
parent 29bc0a30
...@@ -123,14 +123,13 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { ...@@ -123,14 +123,13 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
// MediaTransferProtocolManager override. // MediaTransferProtocolManager override.
void GetStorageInfoFromDevice( void GetStorageInfoFromDevice(
const std::string& storage_name, const std::string& storage_name,
const GetStorageInfoFromDeviceCallback& callback) override { mojom::MtpManager::GetStorageInfoFromDeviceCallback callback) override {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
if (!base::ContainsKey(storage_info_map_, storage_name) || !mtp_client_) { if (!base::ContainsKey(storage_info_map_, storage_name) || !mtp_client_) {
mojom::MtpStorageInfo info; std::move(callback).Run(nullptr, true /* error */);
callback.Run(info, true /* error */);
return; return;
} }
get_storage_info_from_device_callbacks_.push(callback); get_storage_info_from_device_callbacks_.push(std::move(callback));
mtp_client_->GetStorageInfoFromDevice( mtp_client_->GetStorageInfoFromDevice(
storage_name, storage_name,
base::Bind( base::Bind(
...@@ -316,7 +315,7 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { ...@@ -316,7 +315,7 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
private: private:
// Map of storage names to storage info. // Map of storage names to storage info.
using GetStorageInfoFromDeviceCallbackQueue = using GetStorageInfoFromDeviceCallbackQueue =
base::queue<GetStorageInfoFromDeviceCallback>; base::queue<mojom::MtpManager::GetStorageInfoFromDeviceCallback>;
// Callback queues - DBus communication is in-order, thus callbacks are // Callback queues - DBus communication is in-order, thus callbacks are
// received in the same order as the requests. // received in the same order as the requests.
using OpenStorageCallbackQueue = base::queue<OpenStorageCallback>; using OpenStorageCallbackQueue = base::queue<OpenStorageCallback>;
...@@ -397,14 +396,14 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager { ...@@ -397,14 +396,14 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
} }
void OnGetStorageInfoFromDevice(const mojom::MtpStorageInfo& storage_info) { void OnGetStorageInfoFromDevice(const mojom::MtpStorageInfo& storage_info) {
get_storage_info_from_device_callbacks_.front().Run(storage_info, std::move(get_storage_info_from_device_callbacks_.front())
false /* no error */); .Run(storage_info.Clone(), false /* no error */);
get_storage_info_from_device_callbacks_.pop(); get_storage_info_from_device_callbacks_.pop();
} }
void OnGetStorageInfoFromDeviceError() { void OnGetStorageInfoFromDeviceError() {
mojom::MtpStorageInfo info; std::move(get_storage_info_from_device_callbacks_.front())
get_storage_info_from_device_callbacks_.front().Run(info, true /* error */); .Run(nullptr, true /* error */);
get_storage_info_from_device_callbacks_.pop(); get_storage_info_from_device_callbacks_.pop();
} }
......
...@@ -40,13 +40,6 @@ class MediaTransferProtocolManager { ...@@ -40,13 +40,6 @@ class MediaTransferProtocolManager {
using GetStoragesCallback = using GetStoragesCallback =
base::OnceCallback<void(const std::vector<std::string>& storages)>; base::OnceCallback<void(const std::vector<std::string>& storages)>;
// A callback to handle the result of GetStorageInfoFromDevice.
// The first argument is the returned storage info.
// The second argument is true if there was an error.
using GetStorageInfoFromDeviceCallback =
base::Callback<void(const mojom::MtpStorageInfo& storage_info,
const bool error)>;
// A callback to handle the result of OpenStorage. // A callback to handle the result of OpenStorage.
// The first argument is the returned handle. // The first argument is the returned handle.
// The second argument is true if there was an error. // The second argument is true if there was an error.
...@@ -121,7 +114,7 @@ class MediaTransferProtocolManager { ...@@ -121,7 +114,7 @@ class MediaTransferProtocolManager {
// Read the metadata of |storage_name| from device and runs |callback|. // Read the metadata of |storage_name| from device and runs |callback|.
virtual void GetStorageInfoFromDevice( virtual void GetStorageInfoFromDevice(
const std::string& storage_name, const std::string& storage_name,
const GetStorageInfoFromDeviceCallback& callback) = 0; mojom::MtpManager::GetStorageInfoFromDeviceCallback callback) = 0;
// Opens |storage_name| in |mode| and runs |callback|. // Opens |storage_name| in |mode| and runs |callback|.
virtual void OpenStorage(const std::string& storage_name, virtual void OpenStorage(const std::string& storage_name,
......
...@@ -41,13 +41,6 @@ void EnumerateStorageCallbackWrapper( ...@@ -41,13 +41,6 @@ void EnumerateStorageCallbackWrapper(
std::move(callback).Run(std::move(storage_info_ptr_list)); std::move(callback).Run(std::move(storage_info_ptr_list));
} }
void GetStorageInfoFromDeviceCallbackWrapper(
mojom::MtpManager::GetStorageInfoFromDeviceCallback callback,
const mojom::MtpStorageInfo& storage_info,
bool error) {
std::move(callback).Run(storage_info.Clone(), error);
}
void ReadDirectoryCallbackWrapper( void ReadDirectoryCallbackWrapper(
mojom::MtpManager::ReadDirectoryCallback callback, mojom::MtpManager::ReadDirectoryCallback callback,
const std::vector<mojom::MtpFileEntry>& file_entries, const std::vector<mojom::MtpFileEntry>& file_entries,
...@@ -97,9 +90,7 @@ void MtpDeviceManager::GetStorageInfoFromDevice( ...@@ -97,9 +90,7 @@ void MtpDeviceManager::GetStorageInfoFromDevice(
const std::string& storage_name, const std::string& storage_name,
GetStorageInfoFromDeviceCallback callback) { GetStorageInfoFromDeviceCallback callback) {
media_transfer_protocol_manager_->GetStorageInfoFromDevice( media_transfer_protocol_manager_->GetStorageInfoFromDevice(
storage_name, storage_name, std::move(callback));
base::Bind(GetStorageInfoFromDeviceCallbackWrapper,
base::AdaptCallbackForRepeating(std::move(callback))));
} }
void MtpDeviceManager::OpenStorage(const std::string& storage_name, void MtpDeviceManager::OpenStorage(const std::string& storage_name,
......
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