Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/browser/chromeos/mtp/media_transfer_protocol_manager.h

Issue 10854048: ChromeOS: Implement MediaTransferProtocolManager. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_MTP_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_MTP_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "chromeos/dbus/media_transfer_protocol_daemon_client.h"
12
13 namespace chromeos {
14 namespace mtp {
15
16 // This class handles the interaction with mtpd.
17 // Other classes can add themselves as observers.
18 class MediaTransferProtocolManager {
19 public:
20 // A callback to handle the result of OpenStorage.
21 // The first argument is the returned handle.
22 // The second argument is true if there was an error.
23 typedef base::Callback<void(const std::string& handle,
24 bool error)> OpenStorageCallback;
25
26 // A callback to handle the result of CloseStorage.
27 // The argument is true if there was an error.
28 typedef base::Callback<void(bool error)> CloseStorageCallback;
29
30 // A callback to handle the result of ReadDirectoryByPath/Id.
31 // The first argument is a vector of file entries.
32 // The second argument is true if there was an error.
33 typedef base::Callback<void(const std::vector<FileEntry>& file_entries,
34 bool error)> ReadDirectoryCallback;
35
36 // A callback to handle the result of ReadFileByPath/Id.
37 // The first argument is a string containing the file data.
38 // The second argument is true if there was an error.
39 // TODO(thestig) Consider using a file descriptor instead of the data.
40 typedef base::Callback<void(const std::string& data,
41 bool error)> ReadFileCallback;
42
43 // A callback to handle the result of GetFileInfoByPath/Id.
44 // The first argument is a file entry.
45 // The second argument is true if there was an error.
46 typedef base::Callback<void(const FileEntry& file_entry,
47 bool error)> GetFileInfoCallback;
48
49 // Implement this interface to be notified about MTP storage
50 // attachment / detachment events.
51 class Observer {
52 public:
53 virtual ~Observer() {}
54
55 // A function called after a MTP storage has been attached / detached.
56 virtual void StorageChanged(bool is_attached,
57 const std::string& storage_name) = 0;
58 };
59
60 virtual ~MediaTransferProtocolManager() {}
61
62 // Adds an observer.
63 virtual void AddObserver(Observer* observer) = 0;
64
65 // Removes an observer.
66 virtual void RemoveObserver(Observer* observer) = 0;
67
68 // Returns a vector of available MTP storages.
69 virtual const std::vector<std::string> GetStorages() const = 0;
70
71 // On success, returns the the metadata for |storage_name|.
72 // Otherwise returns NULL.
73 virtual const StorageInfo* GetStorageInfo(
74 const std::string& storage_name) const = 0;
75
76 // Opens |storage_name| in |mode| and runs |callback|.
77 virtual void OpenStorage(const std::string& storage_name,
78 OpenStorageMode mode,
79 const OpenStorageCallback& callback) = 0;
80
81 // Close |storage_handle| and runs |callback|.
82 virtual void CloseStorage(const std::string& storage_handle,
83 const CloseStorageCallback& callback) = 0;
84
85 // Reads directory entries from |path| on |storage_handle| and runs
86 // |callback|.
87 virtual void ReadDirectoryByPath(const std::string& storage_handle,
88 const std::string& path,
89 const ReadDirectoryCallback& callback) = 0;
90
91 // Reads directory entries from |file_id| on |storage_handle| and runs
92 // |callback|.
93 virtual void ReadDirectoryById(const std::string& storage_handle,
94 uint32 file_id,
95 const ReadDirectoryCallback& callback) = 0;
96
97 // Reads file data from |path| on |storage_handle| and runs |callback|.
98 virtual void ReadFileByPath(const std::string& storage_handle,
99 const std::string& path,
100 const ReadFileCallback& callback) = 0;
101
102 // Reads file data from |file_id| on |storage_handle| and runs |callback|.
103 virtual void ReadFileById(const std::string& storage_handle,
104 uint32 file_id,
105 const ReadFileCallback& callback) = 0;
106
107 // Gets the file metadata for |path| on |storage_handle| and runs |callback|.
108 virtual void GetFileInfoByPath(const std::string& storage_handle,
109 const std::string& path,
110 const GetFileInfoCallback& callback) = 0;
111
112 // Gets the file metadata for |file_id| on |storage_handle| and runs
113 // |callback|.
114 virtual void GetFileInfoById(const std::string& storage_handle,
115 uint32 file_id,
116 const GetFileInfoCallback& callback) = 0;
117
118 // Creates the global MediaTransferProtocolManager instance.
119 static void Initialize();
120
121 // Destroys the global MediaTransferProtocolManager instance if it exists.
122 static void Shutdown();
123
124 // Returns a pointer to the global MediaTransferProtocolManager instance.
125 // Initialize() should already have been called.
126 static MediaTransferProtocolManager* GetInstance();
127 };
128
129 } // namespace mtp
130 } // namespace chromeos
131
132 #endif // CHROME_BROWSER_CHROMEOS_MTP_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698