summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-13 02:27:52 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-13 02:27:52 +0000
commitc6ccf4205e05b3cee0b03b5774bd2cc828d012d4 (patch)
tree46b51909181f4b3d6de6a3ec32df7049d7181eb8 /chrome/browser
parentda5665eb65fdf7f8e781150b4b4200a1b9f2c7ac (diff)
downloadchromium_src-c6ccf4205e05b3cee0b03b5774bd2cc828d012d4.zip
chromium_src-c6ccf4205e05b3cee0b03b5774bd2cc828d012d4.tar.gz
chromium_src-c6ccf4205e05b3cee0b03b5774bd2cc828d012d4.tar.bz2
CrOS: Convert MediaTransferProtocolDaemonClient to use protobufs.
BUG=chromium-os:29557 Review URL: https://chromiumcodereview.appspot.com/10913048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156468 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/mtp/media_transfer_protocol_manager.cc24
-rw-r--r--chrome/browser/chromeos/mtp/media_transfer_protocol_manager.h10
2 files changed, 20 insertions, 14 deletions
diff --git a/chrome/browser/chromeos/mtp/media_transfer_protocol_manager.cc b/chrome/browser/chromeos/mtp/media_transfer_protocol_manager.cc
index 90a3f8e..03c6aa0 100644
--- a/chrome/browser/chromeos/mtp/media_transfer_protocol_manager.cc
+++ b/chrome/browser/chromeos/mtp/media_transfer_protocol_manager.cc
@@ -14,6 +14,8 @@
#include "base/observer_list.h"
#include "base/stl_util.h"
#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/mtp_file_entry.pb.h"
+#include "chromeos/dbus/mtp_storage_info.pb.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
@@ -68,7 +70,7 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
}
// MediaTransferProtocolManager override.
- virtual const StorageInfo* GetStorageInfo(
+ virtual const MtpStorageInfo* GetStorageInfo(
const std::string& storage_name) const OVERRIDE {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
StorageInfoMap::const_iterator it = storage_info_map_.find(storage_name);
@@ -120,7 +122,7 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
const ReadDirectoryCallback& callback) OVERRIDE {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!ContainsKey(handles_, storage_handle)) {
- callback.Run(std::vector<FileEntry>(), true);
+ callback.Run(std::vector<MtpFileEntry>(), true);
return;
}
read_directory_callbacks_.push(callback);
@@ -140,7 +142,7 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
const ReadDirectoryCallback& callback) OVERRIDE {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!ContainsKey(handles_, storage_handle)) {
- callback.Run(std::vector<FileEntry>(), true);
+ callback.Run(std::vector<MtpFileEntry>(), true);
return;
}
read_directory_callbacks_.push(callback);
@@ -196,7 +198,7 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
const GetFileInfoCallback& callback) OVERRIDE {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!ContainsKey(handles_, storage_handle)) {
- callback.Run(FileEntry(), true);
+ callback.Run(MtpFileEntry(), true);
return;
}
get_file_info_callbacks_.push(callback);
@@ -214,7 +216,7 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
const GetFileInfoCallback& callback) OVERRIDE {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!ContainsKey(handles_, storage_handle)) {
- callback.Run(FileEntry(), true);
+ callback.Run(MtpFileEntry(), true);
return;
}
get_file_info_callbacks_.push(callback);
@@ -229,7 +231,7 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
private:
// Map of storage names to storage info.
- typedef std::map<std::string, StorageInfo> StorageInfoMap;
+ typedef std::map<std::string, MtpStorageInfo> StorageInfoMap;
// Callback queues - DBus communication is in-order, thus callbacks are
// received in the same order as the requests.
typedef std::queue<OpenStorageCallback> OpenStorageCallbackQueue;
@@ -274,7 +276,7 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
}
}
- void OnGetStorageInfo(const StorageInfo& storage_info) {
+ void OnGetStorageInfo(const MtpStorageInfo& storage_info) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const std::string& storage_name = storage_info.storage_name();
if (ContainsKey(storage_info_map_, storage_name)) {
@@ -328,13 +330,13 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
close_storage_callbacks_.pop();
}
- void OnReadDirectory(const std::vector<FileEntry>& file_entries) {
+ void OnReadDirectory(const std::vector<MtpFileEntry>& file_entries) {
read_directory_callbacks_.front().Run(file_entries, false);
read_directory_callbacks_.pop();
}
void OnReadDirectoryError() {
- read_directory_callbacks_.front().Run(std::vector<FileEntry>(), true);
+ read_directory_callbacks_.front().Run(std::vector<MtpFileEntry>(), true);
read_directory_callbacks_.pop();
}
@@ -348,13 +350,13 @@ class MediaTransferProtocolManagerImpl : public MediaTransferProtocolManager {
read_file_callbacks_.pop();
}
- void OnGetFileInfo(const FileEntry& entry) {
+ void OnGetFileInfo(const MtpFileEntry& entry) {
get_file_info_callbacks_.front().Run(entry, false);
get_file_info_callbacks_.pop();
}
void OnGetFileInfoError() {
- get_file_info_callbacks_.front().Run(FileEntry(), true);
+ get_file_info_callbacks_.front().Run(MtpFileEntry(), true);
get_file_info_callbacks_.pop();
}
diff --git a/chrome/browser/chromeos/mtp/media_transfer_protocol_manager.h b/chrome/browser/chromeos/mtp/media_transfer_protocol_manager.h
index cad31e5..fd2256b 100644
--- a/chrome/browser/chromeos/mtp/media_transfer_protocol_manager.h
+++ b/chrome/browser/chromeos/mtp/media_transfer_protocol_manager.h
@@ -8,8 +8,12 @@
#include <string>
#include <vector>
+#include "base/callback.h"
#include "chromeos/dbus/media_transfer_protocol_daemon_client.h"
+class MtpFileEntry;
+class MtpStorageInfo;
+
namespace chromeos {
namespace mtp {
@@ -30,7 +34,7 @@ class MediaTransferProtocolManager {
// A callback to handle the result of ReadDirectoryByPath/Id.
// The first argument is a vector of file entries.
// The second argument is true if there was an error.
- typedef base::Callback<void(const std::vector<FileEntry>& file_entries,
+ typedef base::Callback<void(const std::vector<MtpFileEntry>& file_entries,
bool error)> ReadDirectoryCallback;
// A callback to handle the result of ReadFileByPath/Id.
@@ -43,7 +47,7 @@ class MediaTransferProtocolManager {
// A callback to handle the result of GetFileInfoByPath/Id.
// The first argument is a file entry.
// The second argument is true if there was an error.
- typedef base::Callback<void(const FileEntry& file_entry,
+ typedef base::Callback<void(const MtpFileEntry& file_entry,
bool error)> GetFileInfoCallback;
// Implement this interface to be notified about MTP storage
@@ -70,7 +74,7 @@ class MediaTransferProtocolManager {
// On success, returns the the metadata for |storage_name|.
// Otherwise returns NULL.
- virtual const StorageInfo* GetStorageInfo(
+ virtual const MtpStorageInfo* GetStorageInfo(
const std::string& storage_name) const = 0;
// Opens |storage_name| in |mode| and runs |callback|.