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

Side by Side Diff: chrome/browser/media_galleries/linux/mtp_device_task_helper.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, 9 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 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 18 matching lines...) Expand all
29 typedef base::Callback<void(bool succeeded)> OpenStorageCallback; 29 typedef base::Callback<void(bool succeeded)> OpenStorageCallback;
30 30
31 typedef MTPDeviceAsyncDelegate::GetFileInfoSuccessCallback 31 typedef MTPDeviceAsyncDelegate::GetFileInfoSuccessCallback
32 GetFileInfoSuccessCallback; 32 GetFileInfoSuccessCallback;
33 33
34 // NOTE: The file names in the entry list have their file id appended at the 34 // NOTE: The file names in the entry list have their file id appended at the
35 // end. e.g. foo.jpg with file id 45 becomes foo.jpg,45. 35 // end. e.g. foo.jpg with file id 45 becomes foo.jpg,45.
36 typedef base::Callback<void(const storage::AsyncFileUtil::EntryList& entries, 36 typedef base::Callback<void(const storage::AsyncFileUtil::EntryList& entries,
37 bool has_more)> ReadDirectorySuccessCallback; 37 bool has_more)> ReadDirectorySuccessCallback;
38 38
39 typedef base::Closure CopyFileFromLocalSuccessCallback;
40
39 typedef MTPDeviceAsyncDelegate::ErrorCallback ErrorCallback; 41 typedef MTPDeviceAsyncDelegate::ErrorCallback ErrorCallback;
40 42
41 MTPDeviceTaskHelper(); 43 MTPDeviceTaskHelper();
42 ~MTPDeviceTaskHelper(); 44 ~MTPDeviceTaskHelper();
43 45
44 // Dispatches the request to the MediaTransferProtocolManager to open the MTP 46 // Dispatches the request to the MediaTransferProtocolManager to open the MTP
45 // storage for communication. 47 // storage for communication.
46 // 48 //
47 // |storage_name| specifies the name of the storage device. 49 // |storage_name| specifies the name of the storage device.
48 // |callback| is called when the OpenStorage request completes. |callback| 50 // |callback| is called when the OpenStorage request completes. |callback|
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 const SnapshotRequestInfo& request_info, 90 const SnapshotRequestInfo& request_info,
89 const base::File::Info& snapshot_file_info); 91 const base::File::Info& snapshot_file_info);
90 92
91 // Dispatches the read bytes request to the MediaTransferProtocolManager. 93 // Dispatches the read bytes request to the MediaTransferProtocolManager.
92 // 94 //
93 // |request| contains details about the byte request including the file path, 95 // |request| contains details about the byte request including the file path,
94 // byte range, and the callbacks. The callbacks specified within |request| are 96 // byte range, and the callbacks. The callbacks specified within |request| are
95 // called on the IO thread to notify the caller about success or failure. 97 // called on the IO thread to notify the caller about success or failure.
96 void ReadBytes(const MTPDeviceAsyncDelegate::ReadBytesRequest& request); 98 void ReadBytes(const MTPDeviceAsyncDelegate::ReadBytesRequest& request);
97 99
100 // Forwards CopyFileFromLocal request to the MediaTransferProtocolManager.
101 void CopyFileFromLocal(
102 const std::string& storage_name,
103 const uint32 source_file_descriptor,
104 const uint32 parent_id,
105 const std::string& file_name,
106 const CopyFileFromLocalSuccessCallback& success_callback,
107 const ErrorCallback& error_callback);
108
98 // Dispatches the CloseStorage request to the MediaTransferProtocolManager. 109 // Dispatches the CloseStorage request to the MediaTransferProtocolManager.
99 void CloseStorage() const; 110 void CloseStorage() const;
100 111
101 private: 112 private:
102 // Query callback for OpenStorage() to run |callback| on the IO thread. 113 // Query callback for OpenStorage() to run |callback| on the IO thread.
103 // 114 //
104 // If OpenStorage request succeeds, |error| is set to false and 115 // If OpenStorage request succeeds, |error| is set to false and
105 // |device_handle| contains the handle to communicate with the MTP device. 116 // |device_handle| contains the handle to communicate with the MTP device.
106 // 117 //
107 // If OpenStorage request fails, |error| is set to true and |device_handle| is 118 // If OpenStorage request fails, |error| is set to true and |device_handle| is
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // 163 //
153 // If there is an error, |error| is set to true, the buffer within |request| 164 // If there is an error, |error| is set to true, the buffer within |request|
154 // is untouched, and the error callback within |request| is invoked on the 165 // is untouched, and the error callback within |request| is invoked on the
155 // IO thread to notify the caller. 166 // IO thread to notify the caller.
156 void OnDidReadBytes( 167 void OnDidReadBytes(
157 const MTPDeviceAsyncDelegate::ReadBytesRequest& request, 168 const MTPDeviceAsyncDelegate::ReadBytesRequest& request,
158 const base::File::Info& file_info, 169 const base::File::Info& file_info,
159 const std::string& data, 170 const std::string& data,
160 bool error) const; 171 bool error) const;
161 172
173 // Called when CopyFileFromLocal completed either succeeded or failed.
174 void OnCopyFileFromLocal(
175 const CopyFileFromLocalSuccessCallback& success_callback,
176 const ErrorCallback& error_callback,
177 const bool error) const;
178
162 // Called when the device is uninitialized. 179 // Called when the device is uninitialized.
163 // 180 //
164 // Runs |error_callback| on the IO thread to notify the caller about the 181 // Runs |error_callback| on the IO thread to notify the caller about the
165 // device |error|. 182 // device |error|.
166 void HandleDeviceError(const ErrorCallback& error_callback, 183 void HandleDeviceError(const ErrorCallback& error_callback,
167 base::File::Error error) const; 184 base::File::Error error) const;
168 185
169 // Handle to communicate with the MTP device. 186 // Handle to communicate with the MTP device.
170 std::string device_handle_; 187 std::string device_handle_;
171 188
172 // Used to handle WriteDataInfoSnapshotFile request. 189 // Used to handle WriteDataInfoSnapshotFile request.
173 scoped_ptr<MTPReadFileWorker> read_file_worker_; 190 scoped_ptr<MTPReadFileWorker> read_file_worker_;
174 191
175 // For callbacks that may run after destruction. 192 // For callbacks that may run after destruction.
176 base::WeakPtrFactory<MTPDeviceTaskHelper> weak_ptr_factory_; 193 base::WeakPtrFactory<MTPDeviceTaskHelper> weak_ptr_factory_;
177 194
178 DISALLOW_COPY_AND_ASSIGN(MTPDeviceTaskHelper); 195 DISALLOW_COPY_AND_ASSIGN(MTPDeviceTaskHelper);
179 }; 196 };
180 197
181 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_ 198 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698