OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 // Dispatches the request to the MediaTransferProtocolManager to open the MTP | 44 // Dispatches the request to the MediaTransferProtocolManager to open the MTP |
45 // storage for communication. | 45 // storage for communication. |
46 // | 46 // |
47 // |storage_name| specifies the name of the storage device. | 47 // |storage_name| specifies the name of the storage device. |
48 // |callback| is called when the OpenStorage request completes. |callback| | 48 // |callback| is called when the OpenStorage request completes. |callback| |
49 // runs on the IO thread. | 49 // runs on the IO thread. |
50 void OpenStorage(const std::string& storage_name, | 50 void OpenStorage(const std::string& storage_name, |
51 const OpenStorageCallback& callback); | 51 const OpenStorageCallback& callback); |
52 | 52 |
53 // Dispatches the GetFileInfoById request to the | 53 // Dispatches the GetFileInfo request to the MediaTransferProtocolManager. |
54 // MediaTransferProtocolManager. | |
55 // | 54 // |
56 // |file_id| specifies the id of the file whose details are requested. | 55 // |file_id| specifies the id of the file whose details are requested. |
57 // | 56 // |
58 // If the file details are fetched successfully, |success_callback| is invoked | 57 // If the file details are fetched successfully, |success_callback| is invoked |
59 // on the IO thread to notify the caller about the file details. | 58 // on the IO thread to notify the caller about the file details. |
60 // | 59 // |
61 // If there is an error, |error_callback| is invoked on the IO thread to | 60 // If there is an error, |error_callback| is invoked on the IO thread to |
62 // notify the caller about the file error. | 61 // notify the caller about the file error. |
63 void GetFileInfoById( | 62 void GetFileInfo(uint32 file_id, |
64 uint32 file_id, | 63 const GetFileInfoSuccessCallback& success_callback, |
65 const GetFileInfoSuccessCallback& success_callback, | 64 const ErrorCallback& error_callback); |
66 const ErrorCallback& error_callback); | |
67 | 65 |
68 // Dispatches the read directory request to the MediaTransferProtocolManager. | 66 // Dispatches the read directory request to the MediaTransferProtocolManager. |
69 // | 67 // |
70 // |dir_id| specifies the directory id. | 68 // |dir_id| specifies the directory id. |
71 // | 69 // |
72 // If the directory file entries are enumerated successfully, | 70 // If the directory file entries are enumerated successfully, |
73 // |success_callback| is invoked on the IO thread to notify the caller about | 71 // |success_callback| is invoked on the IO thread to notify the caller about |
74 // the directory file entries. Please see the note in the | 72 // the directory file entries. Please see the note in the |
75 // ReadDirectorySuccessCallback typedef regarding the special treatment of | 73 // ReadDirectorySuccessCallback typedef regarding the special treatment of |
76 // file names. | 74 // file names. |
77 // | 75 // |
78 // If there is an error, |error_callback| is invoked on the IO thread to | 76 // If there is an error, |error_callback| is invoked on the IO thread to |
79 // notify the caller about the file error. | 77 // notify the caller about the file error. |
80 void ReadDirectoryById(uint32 dir_id, | 78 void ReadDirectory(uint32 dir_id, |
81 const ReadDirectorySuccessCallback& success_callback, | 79 const ReadDirectorySuccessCallback& success_callback, |
82 const ErrorCallback& error_callback); | 80 const ErrorCallback& error_callback); |
83 | 81 |
84 // Forwards the WriteDataIntoSnapshotFile request to the MTPReadFileWorker | 82 // Forwards the WriteDataIntoSnapshotFile request to the MTPReadFileWorker |
85 // object. | 83 // object. |
86 // | 84 // |
87 // |request_info| specifies the snapshot file request params. | 85 // |request_info| specifies the snapshot file request params. |
88 // |snapshot_file_info| specifies the metadata of the snapshot file. | 86 // |snapshot_file_info| specifies the metadata of the snapshot file. |
89 void WriteDataIntoSnapshotFile( | 87 void WriteDataIntoSnapshotFile( |
90 const SnapshotRequestInfo& request_info, | 88 const SnapshotRequestInfo& request_info, |
91 const base::File::Info& snapshot_file_info); | 89 const base::File::Info& snapshot_file_info); |
92 | 90 |
(...skipping 26 matching lines...) Expand all Loading... |
119 // |success_callback| is invoked on the IO thread to notify the caller. | 117 // |success_callback| is invoked on the IO thread to notify the caller. |
120 // | 118 // |
121 // If there is an error, |file_entry| is invalid and |error| is | 119 // If there is an error, |file_entry| is invalid and |error| is |
122 // set to true. |error_callback| is invoked on the IO thread to notify the | 120 // set to true. |error_callback| is invoked on the IO thread to notify the |
123 // caller. | 121 // caller. |
124 void OnGetFileInfo(const GetFileInfoSuccessCallback& success_callback, | 122 void OnGetFileInfo(const GetFileInfoSuccessCallback& success_callback, |
125 const ErrorCallback& error_callback, | 123 const ErrorCallback& error_callback, |
126 const MtpFileEntry& file_entry, | 124 const MtpFileEntry& file_entry, |
127 bool error) const; | 125 bool error) const; |
128 | 126 |
129 // Query callback for ReadDirectoryById(). | 127 // Query callback for ReadDirectory(). |
130 // | 128 // |
131 // If there is no error, |error| is set to false, |file_entries| has the | 129 // If there is no error, |error| is set to false, |file_entries| has the |
132 // directory file entries and |success_callback| is invoked on the IO thread | 130 // directory file entries and |success_callback| is invoked on the IO thread |
133 // to notify the caller. | 131 // to notify the caller. |
134 // | 132 // |
135 // If there is an error, |error| is set to true, |file_entries| is empty | 133 // If there is an error, |error| is set to true, |file_entries| is empty |
136 // and |error_callback| is invoked on the IO thread to notify the caller. | 134 // and |error_callback| is invoked on the IO thread to notify the caller. |
137 void OnDidReadDirectoryById( | 135 void OnDidReadDirectory(const ReadDirectorySuccessCallback& success_callback, |
138 const ReadDirectorySuccessCallback& success_callback, | 136 const ErrorCallback& error_callback, |
139 const ErrorCallback& error_callback, | 137 const std::vector<MtpFileEntry>& file_entries, |
140 const std::vector<MtpFileEntry>& file_entries, | 138 bool has_more, |
141 bool has_more, | 139 bool error) const; |
142 bool error) const; | |
143 | 140 |
144 // Intermediate step to finish a ReadBytes request. | 141 // Intermediate step to finish a ReadBytes request. |
145 void OnGetFileInfoToReadBytes( | 142 void OnGetFileInfoToReadBytes( |
146 const MTPDeviceAsyncDelegate::ReadBytesRequest& request, | 143 const MTPDeviceAsyncDelegate::ReadBytesRequest& request, |
147 const MtpFileEntry& file_entry, | 144 const MtpFileEntry& file_entry, |
148 bool error); | 145 bool error); |
149 | 146 |
150 // Query callback for ReadBytes(); | 147 // Query callback for ReadBytes(); |
151 // | 148 // |
152 // If there is no error, |error| is set to false, the buffer within |request| | 149 // If there is no error, |error| is set to false, the buffer within |request| |
(...skipping 22 matching lines...) Expand all Loading... |
175 // Used to handle WriteDataInfoSnapshotFile request. | 172 // Used to handle WriteDataInfoSnapshotFile request. |
176 scoped_ptr<MTPReadFileWorker> read_file_worker_; | 173 scoped_ptr<MTPReadFileWorker> read_file_worker_; |
177 | 174 |
178 // For callbacks that may run after destruction. | 175 // For callbacks that may run after destruction. |
179 base::WeakPtrFactory<MTPDeviceTaskHelper> weak_ptr_factory_; | 176 base::WeakPtrFactory<MTPDeviceTaskHelper> weak_ptr_factory_; |
180 | 177 |
181 DISALLOW_COPY_AND_ASSIGN(MTPDeviceTaskHelper); | 178 DISALLOW_COPY_AND_ASSIGN(MTPDeviceTaskHelper); |
182 }; | 179 }; |
183 | 180 |
184 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_ | 181 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_ |
OLD | NEW |