OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_MTP_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_MTP_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_MTP_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_MTP_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... | |
23 typedef base::Callback<void(const std::string& handle, | 23 typedef base::Callback<void(const std::string& handle, |
24 bool error)> OpenStorageCallback; | 24 bool error)> OpenStorageCallback; |
25 | 25 |
26 // A callback to handle the result of CloseStorage. | 26 // A callback to handle the result of CloseStorage. |
27 // The argument is true if there was an error. | 27 // The argument is true if there was an error. |
28 typedef base::Callback<void(bool error)> CloseStorageCallback; | 28 typedef base::Callback<void(bool error)> CloseStorageCallback; |
29 | 29 |
30 // A callback to handle the result of ReadDirectoryByPath/Id. | 30 // A callback to handle the result of ReadDirectoryByPath/Id. |
31 // The first argument is a vector of file entries. | 31 // The first argument is a vector of file entries. |
32 // The second argument is true if there was an error. | 32 // The second argument is true if there was an error. |
33 typedef base::Callback<void(const std::vector<FileEntry>& file_entries, | 33 typedef base::Callback<void(const std::vector<MtpFileEntry>& file_entries, |
Ryan Sleevi
2012/09/12 22:21:25
IWYU: Looks like you should be forward declaring t
Lei Zhang
2012/09/12 23:33:59
Done.
| |
34 bool error)> ReadDirectoryCallback; | 34 bool error)> ReadDirectoryCallback; |
35 | 35 |
36 // A callback to handle the result of ReadFileByPath/Id. | 36 // A callback to handle the result of ReadFileByPath/Id. |
37 // The first argument is a string containing the file data. | 37 // The first argument is a string containing the file data. |
38 // The second argument is true if there was an error. | 38 // The second argument is true if there was an error. |
39 // TODO(thestig) Consider using a file descriptor instead of the data. | 39 // TODO(thestig) Consider using a file descriptor instead of the data. |
40 typedef base::Callback<void(const std::string& data, | 40 typedef base::Callback<void(const std::string& data, |
41 bool error)> ReadFileCallback; | 41 bool error)> ReadFileCallback; |
42 | 42 |
43 // A callback to handle the result of GetFileInfoByPath/Id. | 43 // A callback to handle the result of GetFileInfoByPath/Id. |
44 // The first argument is a file entry. | 44 // The first argument is a file entry. |
45 // The second argument is true if there was an error. | 45 // The second argument is true if there was an error. |
46 typedef base::Callback<void(const FileEntry& file_entry, | 46 typedef base::Callback<void(const MtpFileEntry& file_entry, |
47 bool error)> GetFileInfoCallback; | 47 bool error)> GetFileInfoCallback; |
48 | 48 |
49 // Implement this interface to be notified about MTP storage | 49 // Implement this interface to be notified about MTP storage |
50 // attachment / detachment events. | 50 // attachment / detachment events. |
51 class Observer { | 51 class Observer { |
52 public: | 52 public: |
53 virtual ~Observer() {} | 53 virtual ~Observer() {} |
54 | 54 |
55 // A function called after a MTP storage has been attached / detached. | 55 // A function called after a MTP storage has been attached / detached. |
56 virtual void StorageChanged(bool is_attached, | 56 virtual void StorageChanged(bool is_attached, |
57 const std::string& storage_name) = 0; | 57 const std::string& storage_name) = 0; |
58 }; | 58 }; |
59 | 59 |
60 virtual ~MediaTransferProtocolManager() {} | 60 virtual ~MediaTransferProtocolManager() {} |
61 | 61 |
62 // Adds an observer. | 62 // Adds an observer. |
63 virtual void AddObserver(Observer* observer) = 0; | 63 virtual void AddObserver(Observer* observer) = 0; |
64 | 64 |
65 // Removes an observer. | 65 // Removes an observer. |
66 virtual void RemoveObserver(Observer* observer) = 0; | 66 virtual void RemoveObserver(Observer* observer) = 0; |
67 | 67 |
68 // Returns a vector of available MTP storages. | 68 // Returns a vector of available MTP storages. |
69 virtual const std::vector<std::string> GetStorages() const = 0; | 69 virtual const std::vector<std::string> GetStorages() const = 0; |
70 | 70 |
71 // On success, returns the the metadata for |storage_name|. | 71 // On success, returns the the metadata for |storage_name|. |
72 // Otherwise returns NULL. | 72 // Otherwise returns NULL. |
73 virtual const StorageInfo* GetStorageInfo( | 73 virtual const MtpStorageInfo* GetStorageInfo( |
74 const std::string& storage_name) const = 0; | 74 const std::string& storage_name) const = 0; |
75 | 75 |
76 // Opens |storage_name| in |mode| and runs |callback|. | 76 // Opens |storage_name| in |mode| and runs |callback|. |
77 virtual void OpenStorage(const std::string& storage_name, | 77 virtual void OpenStorage(const std::string& storage_name, |
78 OpenStorageMode mode, | 78 OpenStorageMode mode, |
79 const OpenStorageCallback& callback) = 0; | 79 const OpenStorageCallback& callback) = 0; |
80 | 80 |
81 // Close |storage_handle| and runs |callback|. | 81 // Close |storage_handle| and runs |callback|. |
82 virtual void CloseStorage(const std::string& storage_handle, | 82 virtual void CloseStorage(const std::string& storage_handle, |
83 const CloseStorageCallback& callback) = 0; | 83 const CloseStorageCallback& callback) = 0; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 | 123 |
124 // Returns a pointer to the global MediaTransferProtocolManager instance. | 124 // Returns a pointer to the global MediaTransferProtocolManager instance. |
125 // Initialize() should already have been called. | 125 // Initialize() should already have been called. |
126 static MediaTransferProtocolManager* GetInstance(); | 126 static MediaTransferProtocolManager* GetInstance(); |
127 }; | 127 }; |
128 | 128 |
129 } // namespace mtp | 129 } // namespace mtp |
130 } // namespace chromeos | 130 } // namespace chromeos |
131 | 131 |
132 #endif // CHROME_BROWSER_CHROMEOS_MTP_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ | 132 #endif // CHROME_BROWSER_CHROMEOS_MTP_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ |
OLD | NEW |