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_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/containers/scoped_ptr_hash_map.h" | 14 #include "base/containers/scoped_ptr_hash_map.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" | 19 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "webkit/browser/fileapi/async_file_util.h" | 21 #include "storage/browser/fileapi/async_file_util.h" |
22 | 22 |
23 struct SnapshotRequestInfo; | 23 struct SnapshotRequestInfo; |
24 | 24 |
25 // MTPDeviceDelegateImplLinux communicates with the media transfer protocol | 25 // MTPDeviceDelegateImplLinux communicates with the media transfer protocol |
26 // (MTP) device to complete file system operations. These operations are | 26 // (MTP) device to complete file system operations. These operations are |
27 // performed asynchronously. Instantiate this class per MTP device storage. | 27 // performed asynchronously. Instantiate this class per MTP device storage. |
28 // MTPDeviceDelegateImplLinux lives on the IO thread. | 28 // MTPDeviceDelegateImplLinux lives on the IO thread. |
29 // MTPDeviceDelegateImplLinux does a call-and-reply to the UI thread | 29 // MTPDeviceDelegateImplLinux does a call-and-reply to the UI thread |
30 // to dispatch the requests to MediaTransferProtocolManager. | 30 // to dispatch the requests to MediaTransferProtocolManager. |
31 class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate { | 31 class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 // Called when ReadDirectory() succeeds. | 177 // Called when ReadDirectory() succeeds. |
178 // | 178 // |
179 // |dir_id| is the directory read. | 179 // |dir_id| is the directory read. |
180 // |success_callback| is invoked to notify the caller about the directory | 180 // |success_callback| is invoked to notify the caller about the directory |
181 // file entries. | 181 // file entries. |
182 // |file_list| contains the directory file entries with their file ids. | 182 // |file_list| contains the directory file entries with their file ids. |
183 // |has_more| is true if there are more file entries to read. | 183 // |has_more| is true if there are more file entries to read. |
184 void OnDidReadDirectory(uint32 dir_id, | 184 void OnDidReadDirectory(uint32 dir_id, |
185 const ReadDirectorySuccessCallback& success_callback, | 185 const ReadDirectorySuccessCallback& success_callback, |
186 const fileapi::AsyncFileUtil::EntryList& file_list, | 186 const storage::AsyncFileUtil::EntryList& file_list, |
187 bool has_more); | 187 bool has_more); |
188 | 188 |
189 // Called when WriteDataIntoSnapshotFile() succeeds. | 189 // Called when WriteDataIntoSnapshotFile() succeeds. |
190 // | 190 // |
191 // |snapshot_file_info| specifies the snapshot file metadata details. | 191 // |snapshot_file_info| specifies the snapshot file metadata details. |
192 // | 192 // |
193 // |current_snapshot_request_info_.success_callback| is invoked to notify the | 193 // |current_snapshot_request_info_.success_callback| is invoked to notify the |
194 // caller about |snapshot_file_info|. | 194 // caller about |snapshot_file_info|. |
195 void OnDidWriteDataIntoSnapshotFile( | 195 void OnDidWriteDataIntoSnapshotFile( |
196 const base::File::Info& snapshot_file_info, | 196 const base::File::Info& snapshot_file_info, |
197 const base::FilePath& snapshot_file_path); | 197 const base::FilePath& snapshot_file_path); |
198 | 198 |
199 // Called when WriteDataIntoSnapshotFile() fails. | 199 // Called when WriteDataIntoSnapshotFile() fails. |
200 // | 200 // |
201 // |error| specifies the file error code. | 201 // |error| specifies the file error code. |
202 // | 202 // |
203 // |current_snapshot_request_info_.error_callback| is invoked to notify the | 203 // |current_snapshot_request_info_.error_callback| is invoked to notify the |
204 // caller about |error|. | 204 // caller about |error|. |
205 void OnWriteDataIntoSnapshotFileError(base::File::Error error); | 205 void OnWriteDataIntoSnapshotFileError(base::File::Error error); |
206 | 206 |
207 // Called when ReadBytes() succeeds. | 207 // Called when ReadBytes() succeeds. |
208 // | 208 // |
209 // |success_callback| is invoked to notify the caller about the read bytes. | 209 // |success_callback| is invoked to notify the caller about the read bytes. |
210 // |bytes_read| is the number of bytes read. | 210 // |bytes_read| is the number of bytes read. |
211 void OnDidReadBytes(const ReadBytesSuccessCallback& success_callback, | 211 void OnDidReadBytes(const ReadBytesSuccessCallback& success_callback, |
212 const base::File::Info& file_info, int bytes_read); | 212 const base::File::Info& file_info, int bytes_read); |
213 | 213 |
214 // Called when FillFileCache() succeeds. | 214 // Called when FillFileCache() succeeds. |
215 void OnDidFillFileCache(const base::FilePath& path, | 215 void OnDidFillFileCache(const base::FilePath& path, |
216 const fileapi::AsyncFileUtil::EntryList& file_list, | 216 const storage::AsyncFileUtil::EntryList& file_list, |
217 bool has_more); | 217 bool has_more); |
218 | 218 |
219 // Called when FillFileCache() fails. | 219 // Called when FillFileCache() fails. |
220 void OnFillFileCacheFailed(base::File::Error error); | 220 void OnFillFileCacheFailed(base::File::Error error); |
221 | 221 |
222 // Handles the device file |error| while operating on |file_id|. | 222 // Handles the device file |error| while operating on |file_id|. |
223 // |error_callback| is invoked to notify the caller about the file error. | 223 // |error_callback| is invoked to notify the caller about the file error. |
224 void HandleDeviceFileError(const ErrorCallback& error_callback, | 224 void HandleDeviceFileError(const ErrorCallback& error_callback, |
225 uint32 file_id, | 225 uint32 file_id, |
226 base::File::Error error); | 226 base::File::Error error); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // can return results over multiple callbacks, is in progress. | 278 // can return results over multiple callbacks, is in progress. |
279 std::set<std::string> child_nodes_seen_; | 279 std::set<std::string> child_nodes_seen_; |
280 | 280 |
281 // For callbacks that may run after destruction. | 281 // For callbacks that may run after destruction. |
282 base::WeakPtrFactory<MTPDeviceDelegateImplLinux> weak_ptr_factory_; | 282 base::WeakPtrFactory<MTPDeviceDelegateImplLinux> weak_ptr_factory_; |
283 | 283 |
284 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux); | 284 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux); |
285 }; | 285 }; |
286 | 286 |
287 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H
_ | 287 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H
_ |
OLD | NEW |