Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Side by Side Diff: chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.h

Issue 947943002: Implement CopyFileFromLocal of MTPDeviceAsyncDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix failed test case. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 const base::FilePath& local_path, 83 const base::FilePath& local_path,
84 const CreateSnapshotFileSuccessCallback& success_callback, 84 const CreateSnapshotFileSuccessCallback& success_callback,
85 const ErrorCallback& error_callback) override; 85 const ErrorCallback& error_callback) override;
86 bool IsStreaming() override; 86 bool IsStreaming() override;
87 void ReadBytes(const base::FilePath& device_file_path, 87 void ReadBytes(const base::FilePath& device_file_path,
88 const scoped_refptr<net::IOBuffer>& buf, 88 const scoped_refptr<net::IOBuffer>& buf,
89 int64 offset, 89 int64 offset,
90 int buf_len, 90 int buf_len,
91 const ReadBytesSuccessCallback& success_callback, 91 const ReadBytesSuccessCallback& success_callback,
92 const ErrorCallback& error_callback) override; 92 const ErrorCallback& error_callback) override;
93 void CopyFileFromLocal(
94 const base::FilePath& source_file_path,
95 const base::FilePath& device_file_path,
96 const CopyFileFromLocalSuccessCallback& success_callback,
97 const ErrorCallback& error_callback) override;
93 void CancelPendingTasksAndDeleteDelegate() override; 98 void CancelPendingTasksAndDeleteDelegate() override;
94 99
95 // The internal methods correspond to the similarly named methods above. 100 // The internal methods correspond to the similarly named methods above.
96 // The |root_node_| cache should be filled at this point. 101 // The |root_node_| cache should be filled at this point.
97 virtual void GetFileInfoInternal( 102 virtual void GetFileInfoInternal(
98 const base::FilePath& file_path, 103 const base::FilePath& file_path,
99 const GetFileInfoSuccessCallback& success_callback, 104 const GetFileInfoSuccessCallback& success_callback,
100 const ErrorCallback& error_callback); 105 const ErrorCallback& error_callback);
101 virtual void ReadDirectoryInternal( 106 virtual void ReadDirectoryInternal(
102 const base::FilePath& root, 107 const base::FilePath& root,
103 const ReadDirectorySuccessCallback& success_callback, 108 const ReadDirectorySuccessCallback& success_callback,
104 const ErrorCallback& error_callback); 109 const ErrorCallback& error_callback);
105 virtual void CreateSnapshotFileInternal( 110 virtual void CreateSnapshotFileInternal(
106 const base::FilePath& device_file_path, 111 const base::FilePath& device_file_path,
107 const base::FilePath& local_path, 112 const base::FilePath& local_path,
108 const CreateSnapshotFileSuccessCallback& success_callback, 113 const CreateSnapshotFileSuccessCallback& success_callback,
109 const ErrorCallback& error_callback); 114 const ErrorCallback& error_callback);
110 virtual void ReadBytesInternal( 115 virtual void ReadBytesInternal(
111 const base::FilePath& device_file_path, 116 const base::FilePath& device_file_path,
112 net::IOBuffer* buf, int64 offset, int buf_len, 117 net::IOBuffer* buf, int64 offset, int buf_len,
113 const ReadBytesSuccessCallback& success_callback, 118 const ReadBytesSuccessCallback& success_callback,
114 const ErrorCallback& error_callback); 119 const ErrorCallback& error_callback);
120 virtual void CopyFileFromLocalInternal(
121 const base::FilePath& source_file_path,
122 const base::FilePath& device_file_path,
123 const CopyFileFromLocalSuccessCallback& success_callback,
124 const ErrorCallback& error_callback);
115 125
116 // Ensures the device is initialized for communication. 126 // Ensures the device is initialized for communication.
117 // If the device is already initialized, call RunTask(). 127 // If the device is already initialized, call RunTask().
118 // 128 //
119 // If the device is uninitialized, store the |task_info| in a pending task 129 // If the device is uninitialized, store the |task_info| in a pending task
120 // queue and runs the pending tasks in the queue once the device is 130 // queue and runs the pending tasks in the queue once the device is
121 // successfully initialized. 131 // successfully initialized.
122 void EnsureInitAndRunTask(const PendingTaskInfo& task_info); 132 void EnsureInitAndRunTask(const PendingTaskInfo& task_info);
123 133
124 // Runs a task. If |task_info.path| is empty, or if the path is cached, runs 134 // Runs a task. If |task_info.path| is empty, or if the path is cached, runs
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 const base::File::Info& file_info, int bytes_read); 225 const base::File::Info& file_info, int bytes_read);
216 226
217 // Called when FillFileCache() succeeds. 227 // Called when FillFileCache() succeeds.
218 void OnDidFillFileCache(const base::FilePath& path, 228 void OnDidFillFileCache(const base::FilePath& path,
219 const storage::AsyncFileUtil::EntryList& file_list, 229 const storage::AsyncFileUtil::EntryList& file_list,
220 bool has_more); 230 bool has_more);
221 231
222 // Called when FillFileCache() fails. 232 // Called when FillFileCache() fails.
223 void OnFillFileCacheFailed(base::File::Error error); 233 void OnFillFileCacheFailed(base::File::Error error);
224 234
235 // Called when CopyFileFromLocal() succeeds.
236 void OnDidCopyFileFromLocal(
237 const CopyFileFromLocalSuccessCallback& success_callback,
238 const uint32 source_file_descriptor);
239
240 // Called when CopyFileFromLocal() fails.
241 void HandleCopyFileFromLocalError(const ErrorCallback& error_callback,
242 const uint32 source_file_descriptor,
243 base::File::Error error);
244
225 // Handles the device file |error| while operating on |file_id|. 245 // Handles the device file |error| while operating on |file_id|.
226 // |error_callback| is invoked to notify the caller about the file error. 246 // |error_callback| is invoked to notify the caller about the file error.
227 void HandleDeviceFileError(const ErrorCallback& error_callback, 247 void HandleDeviceFileError(const ErrorCallback& error_callback,
228 uint32 file_id, 248 uint32 file_id,
229 base::File::Error error); 249 base::File::Error error);
230 250
231 // Given a full path, returns a non-empty sub-path that needs to be read into 251 // Given a full path, returns a non-empty sub-path that needs to be read into
232 // the cache if such a uncached path exists. 252 // the cache if such a uncached path exists.
233 // |cached_path| is the portion of |path| that has had cache lookup attempts. 253 // |cached_path| is the portion of |path| that has had cache lookup attempts.
234 base::FilePath NextUncachedPathComponent( 254 base::FilePath NextUncachedPathComponent(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // the ReadDirectory operation. 306 // the ReadDirectory operation.
287 FileInfoCache file_info_cache_; 307 FileInfoCache file_info_cache_;
288 308
289 // For callbacks that may run after destruction. 309 // For callbacks that may run after destruction.
290 base::WeakPtrFactory<MTPDeviceDelegateImplLinux> weak_ptr_factory_; 310 base::WeakPtrFactory<MTPDeviceDelegateImplLinux> weak_ptr_factory_;
291 311
292 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux); 312 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux);
293 }; 313 };
294 314
295 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H _ 315 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698