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 DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ | 5 #ifndef DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ |
6 #define DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ | 6 #define DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 // A callback to handle the result of OpenStorage. | 32 // A callback to handle the result of OpenStorage. |
33 // The first argument is the returned handle. | 33 // The first argument is the returned handle. |
34 // The second argument is true if there was an error. | 34 // The second argument is true if there was an error. |
35 typedef base::Callback<void(const std::string& handle, | 35 typedef base::Callback<void(const std::string& handle, |
36 bool error)> OpenStorageCallback; | 36 bool error)> OpenStorageCallback; |
37 | 37 |
38 // A callback to handle the result of CloseStorage. | 38 // A callback to handle the result of CloseStorage. |
39 // The argument is true if there was an error. | 39 // The argument is true if there was an error. |
40 typedef base::Callback<void(bool error)> CloseStorageCallback; | 40 typedef base::Callback<void(bool error)> CloseStorageCallback; |
41 | 41 |
42 // A callback to handle the result of ReadDirectoryByPath/Id. | 42 // A callback to handle the result of ReadDirectoryById. |
43 // The first argument is a vector of file entries. | 43 // The first argument is a vector of file entries. |
44 // The second argument is true if there was an error. | 44 // The second argument is true if there was an error. |
45 typedef base::Callback<void(const std::vector<MtpFileEntry>& file_entries, | 45 typedef base::Callback<void(const std::vector<MtpFileEntry>& file_entries, |
46 bool error)> ReadDirectoryCallback; | 46 bool error)> ReadDirectoryCallback; |
47 | 47 |
48 // A callback to handle the result of ReadFileChunkByPath/Id. | 48 // A callback to handle the result of ReadFileChunkById. |
49 // The first argument is a string containing the file data. | 49 // The first argument is a string containing the file data. |
50 // The second argument is true if there was an error. | 50 // The second argument is true if there was an error. |
51 typedef base::Callback<void(const std::string& data, | 51 typedef base::Callback<void(const std::string& data, |
52 bool error)> ReadFileCallback; | 52 bool error)> ReadFileCallback; |
53 | 53 |
54 // A callback to handle the result of GetFileInfoByPath/Id. | 54 // A callback to handle the result of GetFileInfoById. |
55 // The first argument is a file entry. | 55 // The first argument is a file entry. |
56 // The second argument is true if there was an error. | 56 // The second argument is true if there was an error. |
57 typedef base::Callback<void(const MtpFileEntry& file_entry, | 57 typedef base::Callback<void(const MtpFileEntry& file_entry, |
58 bool error)> GetFileInfoCallback; | 58 bool error)> GetFileInfoCallback; |
59 | 59 |
60 // Implement this interface to be notified about MTP storage | 60 // Implement this interface to be notified about MTP storage |
61 // attachment / detachment events. | 61 // attachment / detachment events. |
62 class Observer { | 62 class Observer { |
63 public: | 63 public: |
64 virtual ~Observer() {} | 64 virtual ~Observer() {} |
(...skipping 21 matching lines...) Expand all Loading... |
86 | 86 |
87 // Opens |storage_name| in |mode| and runs |callback|. | 87 // Opens |storage_name| in |mode| and runs |callback|. |
88 virtual void OpenStorage(const std::string& storage_name, | 88 virtual void OpenStorage(const std::string& storage_name, |
89 const std::string& mode, | 89 const std::string& mode, |
90 const OpenStorageCallback& callback) = 0; | 90 const OpenStorageCallback& callback) = 0; |
91 | 91 |
92 // Close |storage_handle| and runs |callback|. | 92 // Close |storage_handle| and runs |callback|. |
93 virtual void CloseStorage(const std::string& storage_handle, | 93 virtual void CloseStorage(const std::string& storage_handle, |
94 const CloseStorageCallback& callback) = 0; | 94 const CloseStorageCallback& callback) = 0; |
95 | 95 |
96 // Reads directory entries from |path| on |storage_handle| and runs | |
97 // |callback|. | |
98 virtual void ReadDirectoryByPath(const std::string& storage_handle, | |
99 const std::string& path, | |
100 const ReadDirectoryCallback& callback) = 0; | |
101 | |
102 // Reads directory entries from |file_id| on |storage_handle| and runs | 96 // Reads directory entries from |file_id| on |storage_handle| and runs |
103 // |callback|. | 97 // |callback|. |
104 virtual void ReadDirectoryById(const std::string& storage_handle, | 98 virtual void ReadDirectoryById(const std::string& storage_handle, |
105 uint32 file_id, | 99 uint32 file_id, |
106 const ReadDirectoryCallback& callback) = 0; | 100 const ReadDirectoryCallback& callback) = 0; |
107 | 101 |
108 // Reads file data from |path| on |storage_handle| and runs |callback|. | |
109 // Reads |count| bytes of data starting at |offset|. | |
110 virtual void ReadFileChunkByPath(const std::string& storage_handle, | |
111 const std::string& path, | |
112 uint32 offset, | |
113 uint32 count, | |
114 const ReadFileCallback& callback) = 0; | |
115 | |
116 // Reads file data from |file_id| on |storage_handle| and runs |callback|. | 102 // Reads file data from |file_id| on |storage_handle| and runs |callback|. |
117 // Reads |count| bytes of data starting at |offset|. | 103 // Reads |count| bytes of data starting at |offset|. |
118 virtual void ReadFileChunkById(const std::string& storage_handle, | 104 virtual void ReadFileChunkById(const std::string& storage_handle, |
119 uint32 file_id, | 105 uint32 file_id, |
120 uint32 offset, | 106 uint32 offset, |
121 uint32 count, | 107 uint32 count, |
122 const ReadFileCallback& callback) = 0; | 108 const ReadFileCallback& callback) = 0; |
123 | 109 |
124 // Gets the file metadata for |path| on |storage_handle| and runs |callback|. | |
125 virtual void GetFileInfoByPath(const std::string& storage_handle, | |
126 const std::string& path, | |
127 const GetFileInfoCallback& callback) = 0; | |
128 | |
129 // Gets the file metadata for |file_id| on |storage_handle| and runs | 110 // Gets the file metadata for |file_id| on |storage_handle| and runs |
130 // |callback|. | 111 // |callback|. |
131 virtual void GetFileInfoById(const std::string& storage_handle, | 112 virtual void GetFileInfoById(const std::string& storage_handle, |
132 uint32 file_id, | 113 uint32 file_id, |
133 const GetFileInfoCallback& callback) = 0; | 114 const GetFileInfoCallback& callback) = 0; |
134 | 115 |
135 // Creates and returns the global MediaTransferProtocolManager instance. | 116 // Creates and returns the global MediaTransferProtocolManager instance. |
136 // On Linux, |task_runner| specifies the task runner to process asynchronous | 117 // On Linux, |task_runner| specifies the task runner to process asynchronous |
137 // operations. | 118 // operations. |
138 // On ChromeOS, |task_runner| should just be set to NULL because ChromeOS | 119 // On ChromeOS, |task_runner| should just be set to NULL because ChromeOS |
139 // already has a dedicated message loop proxy. | 120 // already has a dedicated message loop proxy. |
140 static MediaTransferProtocolManager* Initialize( | 121 static MediaTransferProtocolManager* Initialize( |
141 scoped_refptr<base::SequencedTaskRunner> task_runner); | 122 scoped_refptr<base::SequencedTaskRunner> task_runner); |
142 }; | 123 }; |
143 | 124 |
144 } // namespace device | 125 } // namespace device |
145 | 126 |
146 #endif // DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ | 127 #endif // DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ |
OLD | NEW |