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 {
// MediaTransferProtocolManager override.
void GetStorageInfoFromDevice(
const std::string& storage_name,
const GetStorageInfoFromDeviceCallback& callback) override {
mojom::MtpManager::GetStorageInfoFromDeviceCallback callback) override {
DCHECK(thread_checker_.CalledOnValidThread());
if (!base::ContainsKey(storage_info_map_, storage_name) || !mtp_client_) {
mojom::MtpStorageInfo info;
callback.Run(info, true /* error */);
std::move(callback).Run(nullptr, true /* error */);
return;
}
get_storage_info_from_device_callbacks_.push(callback);
get_storage_info_from_device_callbacks_.push(std::move(callback));
mtp_client_->GetStorageInfoFromDevice(
storage_name,
base::Bind(
......@@ -316,7 +315,7 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
private:
// Map of storage names to storage info.
using GetStorageInfoFromDeviceCallbackQueue =
base::queue<GetStorageInfoFromDeviceCallback>;
base::queue<mojom::MtpManager::GetStorageInfoFromDeviceCallback>;
// Callback queues - DBus communication is in-order, thus callbacks are
// received in the same order as the requests.
using OpenStorageCallbackQueue = base::queue<OpenStorageCallback>;
......@@ -397,14 +396,14 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
}
void OnGetStorageInfoFromDevice(const mojom::MtpStorageInfo& storage_info) {
get_storage_info_from_device_callbacks_.front().Run(storage_info,
false /* no error */);
std::move(get_storage_info_from_device_callbacks_.front())
.Run(storage_info.Clone(), false /* no error */);
get_storage_info_from_device_callbacks_.pop();
}
void OnGetStorageInfoFromDeviceError() {
mojom::MtpStorageInfo info;
get_storage_info_from_device_callbacks_.front().Run(info, true /* error */);
std::move(get_storage_info_from_device_callbacks_.front())
.Run(nullptr, true /* error */);
get_storage_info_from_device_callbacks_.pop();
}
......
......@@ -40,13 +40,6 @@ class MediaTransferProtocolManager {
using GetStoragesCallback =
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.
// The first argument is the returned handle.
// The second argument is true if there was an error.
......@@ -121,7 +114,7 @@ class MediaTransferProtocolManager {
// Read the metadata of |storage_name| from device and runs |callback|.
virtual void GetStorageInfoFromDevice(
const std::string& storage_name,
const GetStorageInfoFromDeviceCallback& callback) = 0;
mojom::MtpManager::GetStorageInfoFromDeviceCallback callback) = 0;
// Opens |storage_name| in |mode| and runs |callback|.
virtual void OpenStorage(const std::string& storage_name,
......
......@@ -41,13 +41,6 @@ void EnumerateStorageCallbackWrapper(
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(
mojom::MtpManager::ReadDirectoryCallback callback,
const std::vector<mojom::MtpFileEntry>& file_entries,
......@@ -97,9 +90,7 @@ void MtpDeviceManager::GetStorageInfoFromDevice(
const std::string& storage_name,
GetStorageInfoFromDeviceCallback callback) {
media_transfer_protocol_manager_->GetStorageInfoFromDevice(
storage_name,
base::Bind(GetStorageInfoFromDeviceCallbackWrapper,
base::AdaptCallbackForRepeating(std::move(callback))));
storage_name, std::move(callback));
}
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