| OLD | NEW |
| 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 <stddef.h> |
| 8 #include <stdint.h> | 9 #include <stdint.h> |
| 9 | 10 |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 16 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" | 18 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" |
| 17 #include "device/media_transfer_protocol/mtp_file_entry.pb.h" | 19 #include "device/media_transfer_protocol/mtp_file_entry.pb.h" |
| 18 #include "storage/browser/fileapi/async_file_util.h" | 20 #include "storage/browser/fileapi/async_file_util.h" |
| 19 | 21 |
| 20 class MTPReadFileWorker; | 22 class MTPReadFileWorker; |
| 21 struct SnapshotRequestInfo; | 23 struct SnapshotRequestInfo; |
| 22 | 24 |
| 23 // MTPDeviceTaskHelper dispatches the media transfer protocol (MTP) device | 25 // MTPDeviceTaskHelper dispatches the media transfer protocol (MTP) device |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 73 |
| 72 // Dispatches the GetFileInfo request to the MediaTransferProtocolManager. | 74 // Dispatches the GetFileInfo request to the MediaTransferProtocolManager. |
| 73 // | 75 // |
| 74 // |file_id| specifies the id of the file whose details are requested. | 76 // |file_id| specifies the id of the file whose details are requested. |
| 75 // | 77 // |
| 76 // If the file details are fetched successfully, |success_callback| is invoked | 78 // If the file details are fetched successfully, |success_callback| is invoked |
| 77 // on the IO thread to notify the caller about the file details. | 79 // on the IO thread to notify the caller about the file details. |
| 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 GetFileInfo(uint32 file_id, | 83 void GetFileInfo(uint32_t file_id, |
| 82 const GetFileInfoSuccessCallback& success_callback, | 84 const GetFileInfoSuccessCallback& success_callback, |
| 83 const ErrorCallback& error_callback); | 85 const ErrorCallback& error_callback); |
| 84 | 86 |
| 85 // Forwards CreateDirectory request to the MediaTransferProtocolManager. | 87 // Forwards CreateDirectory request to the MediaTransferProtocolManager. |
| 86 void CreateDirectory(const uint32 parent_id, | 88 void CreateDirectory(const uint32_t parent_id, |
| 87 const std::string& directory_name, | 89 const std::string& directory_name, |
| 88 const CreateDirectorySuccessCallback& success_callback, | 90 const CreateDirectorySuccessCallback& success_callback, |
| 89 const ErrorCallback& error_callback); | 91 const ErrorCallback& error_callback); |
| 90 | 92 |
| 91 // Dispatches the read directory request to the MediaTransferProtocolManager. | 93 // Dispatches the read directory request to the MediaTransferProtocolManager. |
| 92 // | 94 // |
| 93 // |dir_id| specifies the directory id. | 95 // |dir_id| specifies the directory id. |
| 94 // | 96 // |
| 95 // If the directory file entries are enumerated successfully, | 97 // If the directory file entries are enumerated successfully, |
| 96 // |success_callback| is invoked on the IO thread to notify the caller about | 98 // |success_callback| is invoked on the IO thread to notify the caller about |
| 97 // the directory file entries. Please see the note in the | 99 // the directory file entries. Please see the note in the |
| 98 // ReadDirectorySuccessCallback typedef regarding the special treatment of | 100 // ReadDirectorySuccessCallback typedef regarding the special treatment of |
| 99 // file names. | 101 // file names. |
| 100 // | 102 // |
| 101 // If there is an error, |error_callback| is invoked on the IO thread to | 103 // If there is an error, |error_callback| is invoked on the IO thread to |
| 102 // notify the caller about the file error. | 104 // notify the caller about the file error. |
| 103 void ReadDirectory(const uint32 directory_id, | 105 void ReadDirectory(const uint32_t directory_id, |
| 104 const size_t max_size, | 106 const size_t max_size, |
| 105 const ReadDirectorySuccessCallback& success_callback, | 107 const ReadDirectorySuccessCallback& success_callback, |
| 106 const ErrorCallback& error_callback); | 108 const ErrorCallback& error_callback); |
| 107 | 109 |
| 108 // Forwards the WriteDataIntoSnapshotFile request to the MTPReadFileWorker | 110 // Forwards the WriteDataIntoSnapshotFile request to the MTPReadFileWorker |
| 109 // object. | 111 // object. |
| 110 // | 112 // |
| 111 // |request_info| specifies the snapshot file request params. | 113 // |request_info| specifies the snapshot file request params. |
| 112 // |snapshot_file_info| specifies the metadata of the snapshot file. | 114 // |snapshot_file_info| specifies the metadata of the snapshot file. |
| 113 void WriteDataIntoSnapshotFile( | 115 void WriteDataIntoSnapshotFile( |
| 114 const SnapshotRequestInfo& request_info, | 116 const SnapshotRequestInfo& request_info, |
| 115 const base::File::Info& snapshot_file_info); | 117 const base::File::Info& snapshot_file_info); |
| 116 | 118 |
| 117 // Dispatches the read bytes request to the MediaTransferProtocolManager. | 119 // Dispatches the read bytes request to the MediaTransferProtocolManager. |
| 118 // | 120 // |
| 119 // |request| contains details about the byte request including the file path, | 121 // |request| contains details about the byte request including the file path, |
| 120 // byte range, and the callbacks. The callbacks specified within |request| are | 122 // byte range, and the callbacks. The callbacks specified within |request| are |
| 121 // called on the IO thread to notify the caller about success or failure. | 123 // called on the IO thread to notify the caller about success or failure. |
| 122 void ReadBytes(const MTPDeviceAsyncDelegate::ReadBytesRequest& request); | 124 void ReadBytes(const MTPDeviceAsyncDelegate::ReadBytesRequest& request); |
| 123 | 125 |
| 124 // Forwards RenameObject request to the MediaTransferProtocolManager. | 126 // Forwards RenameObject request to the MediaTransferProtocolManager. |
| 125 void RenameObject(const uint32 object_id, | 127 void RenameObject(const uint32_t object_id, |
| 126 const std::string& new_name, | 128 const std::string& new_name, |
| 127 const RenameObjectSuccessCallback& success_callback, | 129 const RenameObjectSuccessCallback& success_callback, |
| 128 const ErrorCallback& error_callback); | 130 const ErrorCallback& error_callback); |
| 129 | 131 |
| 130 // Forwards CopyFileFromLocal request to the MediaTransferProtocolManager. | 132 // Forwards CopyFileFromLocal request to the MediaTransferProtocolManager. |
| 131 void CopyFileFromLocal( | 133 void CopyFileFromLocal( |
| 132 const std::string& storage_name, | 134 const std::string& storage_name, |
| 133 const int source_file_descriptor, | 135 const int source_file_descriptor, |
| 134 const uint32 parent_id, | 136 const uint32_t parent_id, |
| 135 const std::string& file_name, | 137 const std::string& file_name, |
| 136 const CopyFileFromLocalSuccessCallback& success_callback, | 138 const CopyFileFromLocalSuccessCallback& success_callback, |
| 137 const ErrorCallback& error_callback); | 139 const ErrorCallback& error_callback); |
| 138 | 140 |
| 139 // Forwards DeleteObject request to the MediaTransferProtocolManager. | 141 // Forwards DeleteObject request to the MediaTransferProtocolManager. |
| 140 void DeleteObject(const uint32 object_id, | 142 void DeleteObject(const uint32_t object_id, |
| 141 const DeleteObjectSuccessCallback& success_callback, | 143 const DeleteObjectSuccessCallback& success_callback, |
| 142 const ErrorCallback& error_callback); | 144 const ErrorCallback& error_callback); |
| 143 | 145 |
| 144 // Dispatches the CloseStorage request to the MediaTransferProtocolManager. | 146 // Dispatches the CloseStorage request to the MediaTransferProtocolManager. |
| 145 void CloseStorage() const; | 147 void CloseStorage() const; |
| 146 | 148 |
| 147 private: | 149 private: |
| 148 // Query callback for OpenStorage() to run |callback| on the IO thread. | 150 // Query callback for OpenStorage() to run |callback| on the IO thread. |
| 149 // | 151 // |
| 150 // If OpenStorage request succeeds, |error| is set to false and | 152 // If OpenStorage request succeeds, |error| is set to false and |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // Used to handle WriteDataInfoSnapshotFile request. | 241 // Used to handle WriteDataInfoSnapshotFile request. |
| 240 scoped_ptr<MTPReadFileWorker> read_file_worker_; | 242 scoped_ptr<MTPReadFileWorker> read_file_worker_; |
| 241 | 243 |
| 242 // For callbacks that may run after destruction. | 244 // For callbacks that may run after destruction. |
| 243 base::WeakPtrFactory<MTPDeviceTaskHelper> weak_ptr_factory_; | 245 base::WeakPtrFactory<MTPDeviceTaskHelper> weak_ptr_factory_; |
| 244 | 246 |
| 245 DISALLOW_COPY_AND_ASSIGN(MTPDeviceTaskHelper); | 247 DISALLOW_COPY_AND_ASSIGN(MTPDeviceTaskHelper); |
| 246 }; | 248 }; |
| 247 | 249 |
| 248 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_ | 250 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_H_ |
| OLD | NEW |