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

Get existing GetStorageInfo method align with mojo format.

BUG=769630

Change-Id: I2a4317f0ca9f9cbd1ffd1bd3c1d12a8487651c40
Reviewed-on: https://chromium-review.googlesource.com/1069982
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@{#561362}
parent dc6ff4ef
......@@ -110,13 +110,14 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
}
// MediaTransferProtocolManager override.
void GetStorageInfo(const std::string& storage_name,
GetStorageInfoCallback callback) const override {
void GetStorageInfo(
const std::string& storage_name,
mojom::MtpManager::GetStorageInfoCallback callback) const override {
DCHECK(thread_checker_.CalledOnValidThread());
const auto it = storage_info_map_.find(storage_name);
const auto* storage_info =
it != storage_info_map_.end() ? &it->second : nullptr;
std::move(callback).Run(storage_info);
mojom::MtpStorageInfoPtr storage_info =
it != storage_info_map_.end() ? it->second.Clone() : nullptr;
std::move(callback).Run(std::move(storage_info));
}
// MediaTransferProtocolManager override.
......
......@@ -40,12 +40,6 @@ class MediaTransferProtocolManager {
using GetStoragesCallback =
base::OnceCallback<void(const std::vector<std::string>& storages)>;
// A callback to receive the result of GetStorageInfo().
// On success, the |storage_info| argument contains the storage metadata.
// Otherwise, |storage_info| is a nullptr.
using GetStorageInfoCallback =
base::OnceCallback<void(const mojom::MtpStorageInfo* storage_info)>;
// 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.
......@@ -119,9 +113,10 @@ class MediaTransferProtocolManager {
// Gets all available MTP storages and runs |callback|.
virtual void GetStorages(GetStoragesCallback callback) const = 0;
// Gets the metadata for |storage_name| and runs |callback| synchronously.
virtual void GetStorageInfo(const std::string& storage_name,
GetStorageInfoCallback callback) const = 0;
// Gets the metadata for |storage_name| and runs |callback|.
virtual void GetStorageInfo(
const std::string& storage_name,
mojom::MtpManager::GetStorageInfoCallback callback) const = 0;
// Read the metadata of |storage_name| from device and runs |callback|.
virtual void GetStorageInfoFromDevice(
......
......@@ -41,12 +41,6 @@ void EnumerateStorageCallbackWrapper(
std::move(callback).Run(std::move(storage_info_ptr_list));
}
void GetStorageInfoCallbackWrapper(
mojom::MtpManager::GetStorageInfoCallback callback,
const mojom::MtpStorageInfo* storage_info) {
std::move(callback).Run(storage_info->Clone());
}
void GetStorageInfoFromDeviceCallbackWrapper(
mojom::MtpManager::GetStorageInfoFromDeviceCallback callback,
const mojom::MtpStorageInfo& storage_info,
......@@ -95,9 +89,8 @@ void MtpDeviceManager::EnumerateStoragesAndSetClient(
void MtpDeviceManager::GetStorageInfo(const std::string& storage_name,
GetStorageInfoCallback callback) {
media_transfer_protocol_manager_->GetStorageInfo(
storage_name,
base::BindOnce(GetStorageInfoCallbackWrapper, std::move(callback)));
media_transfer_protocol_manager_->GetStorageInfo(storage_name,
std::move(callback));
}
void MtpDeviceManager::GetStorageInfoFromDevice(
......
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