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 ReadDirectoryById. | 42 // A callback to handle the result of ReadDirectory. |
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 are more file entries. | 44 // The second argument is true if there are more file entries. |
45 // The third argument is true if there was an error. | 45 // The third argument is true if there was an error. |
46 typedef base::Callback<void(const std::vector<MtpFileEntry>& file_entries, | 46 typedef base::Callback<void(const std::vector<MtpFileEntry>& file_entries, |
47 bool has_more, | 47 bool has_more, |
48 bool error)> ReadDirectoryCallback; | 48 bool error)> ReadDirectoryCallback; |
49 | 49 |
50 // A callback to handle the result of ReadFileChunkById. | 50 // A callback to handle the result of ReadFileChunk. |
51 // The first argument is a string containing the file data. | 51 // The first argument is a string containing the file data. |
52 // The second argument is true if there was an error. | 52 // The second argument is true if there was an error. |
53 typedef base::Callback<void(const std::string& data, | 53 typedef base::Callback<void(const std::string& data, |
54 bool error)> ReadFileCallback; | 54 bool error)> ReadFileCallback; |
55 | 55 |
56 // A callback to handle the result of GetFileInfoById. | 56 // A callback to handle the result of GetFileInfo. |
57 // The first argument is a file entry. | 57 // The first argument is a file entry. |
58 // The second argument is true if there was an error. | 58 // The second argument is true if there was an error. |
59 typedef base::Callback<void(const MtpFileEntry& file_entry, | 59 typedef base::Callback<void(const MtpFileEntry& file_entry, |
60 bool error)> GetFileInfoCallback; | 60 bool error)> GetFileInfoCallback; |
61 | 61 |
62 // Implement this interface to be notified about MTP storage | 62 // Implement this interface to be notified about MTP storage |
63 // attachment / detachment events. | 63 // attachment / detachment events. |
64 class Observer { | 64 class Observer { |
65 public: | 65 public: |
66 virtual ~Observer() {} | 66 virtual ~Observer() {} |
(...skipping 23 matching lines...) Expand all Loading... |
90 virtual void OpenStorage(const std::string& storage_name, | 90 virtual void OpenStorage(const std::string& storage_name, |
91 const std::string& mode, | 91 const std::string& mode, |
92 const OpenStorageCallback& callback) = 0; | 92 const OpenStorageCallback& callback) = 0; |
93 | 93 |
94 // Close |storage_handle| and runs |callback|. | 94 // Close |storage_handle| and runs |callback|. |
95 virtual void CloseStorage(const std::string& storage_handle, | 95 virtual void CloseStorage(const std::string& storage_handle, |
96 const CloseStorageCallback& callback) = 0; | 96 const CloseStorageCallback& callback) = 0; |
97 | 97 |
98 // Reads directory entries from |file_id| on |storage_handle| and runs | 98 // Reads directory entries from |file_id| on |storage_handle| and runs |
99 // |callback|. | 99 // |callback|. |
100 virtual void ReadDirectoryById(const std::string& storage_handle, | 100 virtual void ReadDirectory(const std::string& storage_handle, |
101 uint32 file_id, | 101 uint32 file_id, |
102 const ReadDirectoryCallback& callback) = 0; | 102 const ReadDirectoryCallback& callback) = 0; |
103 | 103 |
104 // Reads file data from |file_id| on |storage_handle| and runs |callback|. | 104 // Reads file data from |file_id| on |storage_handle| and runs |callback|. |
105 // Reads |count| bytes of data starting at |offset|. | 105 // Reads |count| bytes of data starting at |offset|. |
106 virtual void ReadFileChunkById(const std::string& storage_handle, | 106 virtual void ReadFileChunk(const std::string& storage_handle, |
107 uint32 file_id, | 107 uint32 file_id, |
108 uint32 offset, | 108 uint32 offset, |
109 uint32 count, | 109 uint32 count, |
110 const ReadFileCallback& callback) = 0; | 110 const ReadFileCallback& callback) = 0; |
111 | 111 |
112 // Gets the file metadata for |file_id| on |storage_handle| and runs | 112 // Gets the file metadata for |file_id| on |storage_handle| and runs |
113 // |callback|. | 113 // |callback|. |
114 virtual void GetFileInfoById(const std::string& storage_handle, | 114 virtual void GetFileInfo(const std::string& storage_handle, |
115 uint32 file_id, | 115 uint32 file_id, |
116 const GetFileInfoCallback& callback) = 0; | 116 const GetFileInfoCallback& callback) = 0; |
117 | 117 |
118 // Creates and returns the global MediaTransferProtocolManager instance. | 118 // Creates and returns the global MediaTransferProtocolManager instance. |
119 // On Linux, |task_runner| specifies the task runner to process asynchronous | 119 // On Linux, |task_runner| specifies the task runner to process asynchronous |
120 // operations. | 120 // operations. |
121 // On ChromeOS, |task_runner| should just be set to NULL because ChromeOS | 121 // On ChromeOS, |task_runner| should just be set to NULL because ChromeOS |
122 // already has a dedicated message loop proxy. | 122 // already has a dedicated message loop proxy. |
123 static MediaTransferProtocolManager* Initialize( | 123 static MediaTransferProtocolManager* Initialize( |
124 scoped_refptr<base::SequencedTaskRunner> task_runner); | 124 scoped_refptr<base::SequencedTaskRunner> task_runner); |
125 }; | 125 }; |
126 | 126 |
127 } // namespace device | 127 } // namespace device |
128 | 128 |
129 #endif // DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ | 129 #endif // DEVICE_MEDIA_TRANSFER_PROTOCOL_MEDIA_TRANSFER_PROTOCOL_MANAGER_H_ |
OLD | NEW |