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

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 wrong function definition. 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 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|
49 // runs on the IO thread. 51 // runs on the IO thread.
50 void OpenStorage(const std::string& storage_name, 52 void OpenStorage(const std::string& storage_name,
53 const bool read_only,
51 const OpenStorageCallback& callback); 54 const OpenStorageCallback& callback);
52 55
53 // Dispatches the GetFileInfo request to the MediaTransferProtocolManager. 56 // Dispatches the GetFileInfo request to the MediaTransferProtocolManager.
54 // 57 //
55 // |file_id| specifies the id of the file whose details are requested. 58 // |file_id| specifies the id of the file whose details are requested.
56 // 59 //
57 // If the file details are fetched successfully, |success_callback| is invoked 60 // If the file details are fetched successfully, |success_callback| is invoked
58 // on the IO thread to notify the caller about the file details. 61 // on the IO thread to notify the caller about the file details.
59 // 62 //
60 // If there is an error, |error_callback| is invoked on the IO thread to 63 // If there is an error, |error_callback| is invoked on the IO thread to
(...skipping 27 matching lines...) Expand all
88 const SnapshotRequestInfo& request_info, 91 const SnapshotRequestInfo& request_info,
89 const base::File::Info& snapshot_file_info); 92 const base::File::Info& snapshot_file_info);
90 93
91 // Dispatches the read bytes request to the MediaTransferProtocolManager. 94 // Dispatches the read bytes request to the MediaTransferProtocolManager.
92 // 95 //
93 // |request| contains details about the byte request including the file path, 96 // |request| contains details about the byte request including the file path,
94 // byte range, and the callbacks. The callbacks specified within |request| are 97 // 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. 98 // called on the IO thread to notify the caller about success or failure.
96 void ReadBytes(const MTPDeviceAsyncDelegate::ReadBytesRequest& request); 99 void ReadBytes(const MTPDeviceAsyncDelegate::ReadBytesRequest& request);
97 100
101 // Forwards CopyFileFromLocal request to the MediaTransferProtocolManager.
102 void CopyFileFromLocal(
103 const std::string& storage_name,
104 const int source_file_descriptor,
105 const uint32 parent_id,
106 const std::string& file_name,
107 const CopyFileFromLocalSuccessCallback& success_callback,
108 const ErrorCallback& error_callback);
109
98 // Dispatches the CloseStorage request to the MediaTransferProtocolManager. 110 // Dispatches the CloseStorage request to the MediaTransferProtocolManager.
99 void CloseStorage() const; 111 void CloseStorage() const;
100 112
101 private: 113 private:
102 // Query callback for OpenStorage() to run |callback| on the IO thread. 114 // Query callback for OpenStorage() to run |callback| on the IO thread.
103 // 115 //
104 // If OpenStorage request succeeds, |error| is set to false and 116 // If OpenStorage request succeeds, |error| is set to false and
105 // |device_handle| contains the handle to communicate with the MTP device. 117 // |device_handle| contains the handle to communicate with the MTP device.
106 // 118 //
107 // If OpenStorage request fails, |error| is set to true and |device_handle| is 119 // 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 // 164 //
153 // If there is an error, |error| is set to true, the buffer within |request| 165 // 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 166 // is untouched, and the error callback within |request| is invoked on the
155 // IO thread to notify the caller. 167 // IO thread to notify the caller.
156 void OnDidReadBytes( 168 void OnDidReadBytes(
157 const MTPDeviceAsyncDelegate::ReadBytesRequest& request, 169 const MTPDeviceAsyncDelegate::ReadBytesRequest& request,
158 const base::File::Info& file_info, 170 const base::File::Info& file_info,
159 const std::string& data, 171 const std::string& data,
160 bool error) const; 172 bool error) const;
161 173
174 // Called when CopyFileFromLocal completed either succeeded or failed.
Lei Zhang 2015/03/02 23:41:39 nit: grammar.
yawano 2015/03/03 09:16:54 Done. I wish this change fixes the error.
175 void OnCopyFileFromLocal(
176 const CopyFileFromLocalSuccessCallback& success_callback,
177 const ErrorCallback& error_callback,
178 const bool error) const;
179
162 // Called when the device is uninitialized. 180 // Called when the device is uninitialized.
163 // 181 //
164 // Runs |error_callback| on the IO thread to notify the caller about the 182 // Runs |error_callback| on the IO thread to notify the caller about the
165 // device |error|. 183 // device |error|.
166 void HandleDeviceError(const ErrorCallback& error_callback, 184 void HandleDeviceError(const ErrorCallback& error_callback,
167 base::File::Error error) const; 185 base::File::Error error) const;
168 186
169 // Handle to communicate with the MTP device. 187 // Handle to communicate with the MTP device.
170 std::string device_handle_; 188 std::string device_handle_;
171 189
172 // Used to handle WriteDataInfoSnapshotFile request. 190 // Used to handle WriteDataInfoSnapshotFile request.
173 scoped_ptr<MTPReadFileWorker> read_file_worker_; 191 scoped_ptr<MTPReadFileWorker> read_file_worker_;
174 192
175 // For callbacks that may run after destruction. 193 // For callbacks that may run after destruction.
176 base::WeakPtrFactory<MTPDeviceTaskHelper> weak_ptr_factory_; 194 base::WeakPtrFactory<MTPDeviceTaskHelper> weak_ptr_factory_;
177 195
178 DISALLOW_COPY_AND_ASSIGN(MTPDeviceTaskHelper); 196 DISALLOW_COPY_AND_ASSIGN(MTPDeviceTaskHelper);
179 }; 197 };
180 198
181 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_ 199 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698