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

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

Issue 982283002: Implement DeleteFile and DeleteDirectory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. 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 20 matching lines...) Expand all
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; 39 typedef base::Closure CopyFileFromLocalSuccessCallback;
40 40
41 typedef base::Closure DeleteObjectSuccessCallback;
42
41 typedef MTPDeviceAsyncDelegate::ErrorCallback ErrorCallback; 43 typedef MTPDeviceAsyncDelegate::ErrorCallback ErrorCallback;
42 44
43 MTPDeviceTaskHelper(); 45 MTPDeviceTaskHelper();
44 ~MTPDeviceTaskHelper(); 46 ~MTPDeviceTaskHelper();
45 47
46 // Dispatches the request to the MediaTransferProtocolManager to open the MTP 48 // Dispatches the request to the MediaTransferProtocolManager to open the MTP
47 // storage for communication. 49 // storage for communication.
48 // 50 //
49 // |storage_name| specifies the name of the storage device. 51 // |storage_name| specifies the name of the storage device.
50 // |callback| is called when the OpenStorage request completes. |callback| 52 // |callback| is called when the OpenStorage request completes. |callback|
(...skipping 20 matching lines...) Expand all
71 // |dir_id| specifies the directory id. 73 // |dir_id| specifies the directory id.
72 // 74 //
73 // If the directory file entries are enumerated successfully, 75 // If the directory file entries are enumerated successfully,
74 // |success_callback| is invoked on the IO thread to notify the caller about 76 // |success_callback| is invoked on the IO thread to notify the caller about
75 // the directory file entries. Please see the note in the 77 // the directory file entries. Please see the note in the
76 // ReadDirectorySuccessCallback typedef regarding the special treatment of 78 // ReadDirectorySuccessCallback typedef regarding the special treatment of
77 // file names. 79 // file names.
78 // 80 //
79 // If there is an error, |error_callback| is invoked on the IO thread to 81 // If there is an error, |error_callback| is invoked on the IO thread to
80 // notify the caller about the file error. 82 // notify the caller about the file error.
81 void ReadDirectory(uint32 dir_id, 83 void ReadDirectory(const uint32 directory_id,
84 const size_t max_size,
82 const ReadDirectorySuccessCallback& success_callback, 85 const ReadDirectorySuccessCallback& success_callback,
83 const ErrorCallback& error_callback); 86 const ErrorCallback& error_callback);
84 87
85 // Forwards the WriteDataIntoSnapshotFile request to the MTPReadFileWorker 88 // Forwards the WriteDataIntoSnapshotFile request to the MTPReadFileWorker
86 // object. 89 // object.
87 // 90 //
88 // |request_info| specifies the snapshot file request params. 91 // |request_info| specifies the snapshot file request params.
89 // |snapshot_file_info| specifies the metadata of the snapshot file. 92 // |snapshot_file_info| specifies the metadata of the snapshot file.
90 void WriteDataIntoSnapshotFile( 93 void WriteDataIntoSnapshotFile(
91 const SnapshotRequestInfo& request_info, 94 const SnapshotRequestInfo& request_info,
92 const base::File::Info& snapshot_file_info); 95 const base::File::Info& snapshot_file_info);
93 96
94 // Dispatches the read bytes request to the MediaTransferProtocolManager. 97 // Dispatches the read bytes request to the MediaTransferProtocolManager.
95 // 98 //
96 // |request| contains details about the byte request including the file path, 99 // |request| contains details about the byte request including the file path,
97 // byte range, and the callbacks. The callbacks specified within |request| are 100 // byte range, and the callbacks. The callbacks specified within |request| are
98 // called on the IO thread to notify the caller about success or failure. 101 // called on the IO thread to notify the caller about success or failure.
99 void ReadBytes(const MTPDeviceAsyncDelegate::ReadBytesRequest& request); 102 void ReadBytes(const MTPDeviceAsyncDelegate::ReadBytesRequest& request);
100 103
101 // Forwards CopyFileFromLocal request to the MediaTransferProtocolManager. 104 // Forwards CopyFileFromLocal request to the MediaTransferProtocolManager.
102 void CopyFileFromLocal( 105 void CopyFileFromLocal(
103 const std::string& storage_name, 106 const std::string& storage_name,
104 const int source_file_descriptor, 107 const int source_file_descriptor,
105 const uint32 parent_id, 108 const uint32 parent_id,
106 const std::string& file_name, 109 const std::string& file_name,
107 const CopyFileFromLocalSuccessCallback& success_callback, 110 const CopyFileFromLocalSuccessCallback& success_callback,
108 const ErrorCallback& error_callback); 111 const ErrorCallback& error_callback);
109 112
113 // Forwards DeleteObject request to the MediaTransferProtocolManager.
114 void DeleteObject(const uint32 object_id,
115 const DeleteObjectSuccessCallback& success_callback,
116 const ErrorCallback& error_callback);
117
110 // Dispatches the CloseStorage request to the MediaTransferProtocolManager. 118 // Dispatches the CloseStorage request to the MediaTransferProtocolManager.
111 void CloseStorage() const; 119 void CloseStorage() const;
112 120
113 private: 121 private:
114 // Query callback for OpenStorage() to run |callback| on the IO thread. 122 // Query callback for OpenStorage() to run |callback| on the IO thread.
115 // 123 //
116 // If OpenStorage request succeeds, |error| is set to false and 124 // If OpenStorage request succeeds, |error| is set to false and
117 // |device_handle| contains the handle to communicate with the MTP device. 125 // |device_handle| contains the handle to communicate with the MTP device.
118 // 126 //
119 // If OpenStorage request fails, |error| is set to true and |device_handle| is 127 // 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
164 // 172 //
165 // If there is an error, |error| is set to true, the buffer within |request| 173 // If there is an error, |error| is set to true, the buffer within |request|
166 // is untouched, and the error callback within |request| is invoked on the 174 // is untouched, and the error callback within |request| is invoked on the
167 // IO thread to notify the caller. 175 // IO thread to notify the caller.
168 void OnDidReadBytes( 176 void OnDidReadBytes(
169 const MTPDeviceAsyncDelegate::ReadBytesRequest& request, 177 const MTPDeviceAsyncDelegate::ReadBytesRequest& request,
170 const base::File::Info& file_info, 178 const base::File::Info& file_info,
171 const std::string& data, 179 const std::string& data,
172 bool error) const; 180 bool error) const;
173 181
174 // Called when CopyFileFromLocal completed no matter if it succeeded or 182 // Called when CopyFileFromLocal completes.
175 // failed.
176 void OnCopyFileFromLocal( 183 void OnCopyFileFromLocal(
177 const CopyFileFromLocalSuccessCallback& success_callback, 184 const CopyFileFromLocalSuccessCallback& success_callback,
178 const ErrorCallback& error_callback, 185 const ErrorCallback& error_callback,
179 const bool error) const; 186 const bool error) const;
180 187
188 // Called when DeleteObject completes.
189 void OnDeleteObject(const DeleteObjectSuccessCallback& success_callback,
190 const ErrorCallback& error_callback,
191 const bool error) const;
192
181 // Called when the device is uninitialized. 193 // Called when the device is uninitialized.
182 // 194 //
183 // Runs |error_callback| on the IO thread to notify the caller about the 195 // Runs |error_callback| on the IO thread to notify the caller about the
184 // device |error|. 196 // device |error|.
185 void HandleDeviceError(const ErrorCallback& error_callback, 197 void HandleDeviceError(const ErrorCallback& error_callback,
186 base::File::Error error) const; 198 base::File::Error error) const;
187 199
188 // Handle to communicate with the MTP device. 200 // Handle to communicate with the MTP device.
189 std::string device_handle_; 201 std::string device_handle_;
190 202
191 // Used to handle WriteDataInfoSnapshotFile request. 203 // Used to handle WriteDataInfoSnapshotFile request.
192 scoped_ptr<MTPReadFileWorker> read_file_worker_; 204 scoped_ptr<MTPReadFileWorker> read_file_worker_;
193 205
194 // For callbacks that may run after destruction. 206 // For callbacks that may run after destruction.
195 base::WeakPtrFactory<MTPDeviceTaskHelper> weak_ptr_factory_; 207 base::WeakPtrFactory<MTPDeviceTaskHelper> weak_ptr_factory_;
196 208
197 DISALLOW_COPY_AND_ASSIGN(MTPDeviceTaskHelper); 209 DISALLOW_COPY_AND_ASSIGN(MTPDeviceTaskHelper);
198 }; 210 };
199 211
200 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_ 212 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698