OLD | NEW |
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 <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // If the device is uninitialized, store the |task_info| in a pending task | 87 // If the device is uninitialized, store the |task_info| in a pending task |
88 // list and runs all the pending tasks once the device is successfully | 88 // list and runs all the pending tasks once the device is successfully |
89 // initialized. | 89 // initialized. |
90 void EnsureInitAndRunTask(const PendingTaskInfo& task_info); | 90 void EnsureInitAndRunTask(const PendingTaskInfo& task_info); |
91 | 91 |
92 // Writes data from the device to the snapshot file path based on the | 92 // Writes data from the device to the snapshot file path based on the |
93 // parameters in |current_snapshot_request_info_| by doing a call-and-reply to | 93 // parameters in |current_snapshot_request_info_| by doing a call-and-reply to |
94 // the UI thread. | 94 // the UI thread. |
95 // | 95 // |
96 // |snapshot_file_info| specifies the metadata details of the snapshot file. | 96 // |snapshot_file_info| specifies the metadata details of the snapshot file. |
97 void WriteDataIntoSnapshotFile( | 97 void WriteDataIntoSnapshotFile(const base::File::Info& snapshot_file_info); |
98 const base::PlatformFileInfo& snapshot_file_info); | |
99 | 98 |
100 // Processes the next pending request. | 99 // Processes the next pending request. |
101 void ProcessNextPendingRequest(); | 100 void ProcessNextPendingRequest(); |
102 | 101 |
103 // Handles the device initialization event. |succeeded| indicates whether | 102 // Handles the device initialization event. |succeeded| indicates whether |
104 // device initialization succeeded. | 103 // device initialization succeeded. |
105 // | 104 // |
106 // If the device is successfully initialized, runs the next pending task. | 105 // If the device is successfully initialized, runs the next pending task. |
107 void OnInitCompleted(bool succeeded); | 106 void OnInitCompleted(bool succeeded); |
108 | 107 |
109 // Called when GetFileInfo() succeeds. |file_info| specifies the | 108 // Called when GetFileInfo() succeeds. |file_info| specifies the |
110 // requested file details. |success_callback| is invoked to notify the caller | 109 // requested file details. |success_callback| is invoked to notify the caller |
111 // about the requested file details. | 110 // about the requested file details. |
112 void OnDidGetFileInfo(const GetFileInfoSuccessCallback& success_callback, | 111 void OnDidGetFileInfo(const GetFileInfoSuccessCallback& success_callback, |
113 const base::PlatformFileInfo& file_info); | 112 const base::File::Info& file_info); |
114 | 113 |
115 // Called when GetFileInfo() succeeds. GetFileInfo() is invoked to | 114 // Called when GetFileInfo() succeeds. GetFileInfo() is invoked to |
116 // get the |root| directory metadata details. |file_info| specifies the |root| | 115 // get the |root| directory metadata details. |file_info| specifies the |root| |
117 // directory details. | 116 // directory details. |
118 // | 117 // |
119 // If |root| is a directory, post a task on the UI thread to read the |root| | 118 // If |root| is a directory, post a task on the UI thread to read the |root| |
120 // directory file entries. | 119 // directory file entries. |
121 // | 120 // |
122 // If |root| is not a directory, |error_callback| is invoked to notify the | 121 // If |root| is not a directory, |error_callback| is invoked to notify the |
123 // caller about the platform file error and process the next pending request. | 122 // caller about the platform file error and process the next pending request. |
124 void OnDidGetFileInfoToReadDirectory( | 123 void OnDidGetFileInfoToReadDirectory( |
125 const std::string& root, | 124 const std::string& root, |
126 const ReadDirectorySuccessCallback& success_callback, | 125 const ReadDirectorySuccessCallback& success_callback, |
127 const ErrorCallback& error_callback, | 126 const ErrorCallback& error_callback, |
128 const base::PlatformFileInfo& file_info); | 127 const base::File::Info& file_info); |
129 | 128 |
130 // Called when GetFileInfo() succeeds. GetFileInfo() is invoked to | 129 // Called when GetFileInfo() succeeds. GetFileInfo() is invoked to |
131 // create the snapshot file of |snapshot_request_info.device_file_path|. | 130 // create the snapshot file of |snapshot_request_info.device_file_path|. |
132 // |file_info| specifies the device file metadata details. | 131 // |file_info| specifies the device file metadata details. |
133 // | 132 // |
134 // Posts a task on the UI thread to copy the data contents of the device file | 133 // Posts a task on the UI thread to copy the data contents of the device file |
135 // to the snapshot file. | 134 // to the snapshot file. |
136 void OnDidGetFileInfoToCreateSnapshotFile( | 135 void OnDidGetFileInfoToCreateSnapshotFile( |
137 scoped_ptr<SnapshotRequestInfo> snapshot_request_info, | 136 scoped_ptr<SnapshotRequestInfo> snapshot_request_info, |
138 const base::PlatformFileInfo& file_info); | 137 const base::File::Info& file_info); |
139 | 138 |
140 // Called when GetFileInfo() succeeds to read a range of bytes. | 139 // Called when GetFileInfo() succeeds to read a range of bytes. |
141 void OnDidGetFileInfoToReadBytes(const ReadBytesRequest& request, | 140 void OnDidGetFileInfoToReadBytes(const ReadBytesRequest& request, |
142 const base::PlatformFileInfo& file_info); | 141 const base::File::Info& file_info); |
143 | 142 |
144 // Called when ReadDirectory() succeeds. | 143 // Called when ReadDirectory() succeeds. |
145 // | 144 // |
146 // |file_list| contains the directory file entries. | 145 // |file_list| contains the directory file entries. |
147 // |success_callback| is invoked to notify the caller about the directory | 146 // |success_callback| is invoked to notify the caller about the directory |
148 // file entries. | 147 // file entries. |
149 void OnDidReadDirectory(const ReadDirectorySuccessCallback& success_callback, | 148 void OnDidReadDirectory(const ReadDirectorySuccessCallback& success_callback, |
150 const fileapi::AsyncFileUtil::EntryList& file_list); | 149 const fileapi::AsyncFileUtil::EntryList& file_list); |
151 | 150 |
152 // Called when WriteDataIntoSnapshotFile() succeeds. | 151 // Called when WriteDataIntoSnapshotFile() succeeds. |
153 // | 152 // |
154 // |snapshot_file_info| specifies the snapshot file metadata details. | 153 // |snapshot_file_info| specifies the snapshot file metadata details. |
155 // | 154 // |
156 // |current_snapshot_request_info_.success_callback| is invoked to notify the | 155 // |current_snapshot_request_info_.success_callback| is invoked to notify the |
157 // caller about |snapshot_file_info|. | 156 // caller about |snapshot_file_info|. |
158 void OnDidWriteDataIntoSnapshotFile( | 157 void OnDidWriteDataIntoSnapshotFile( |
159 const base::PlatformFileInfo& snapshot_file_info, | 158 const base::File::Info& snapshot_file_info, |
160 const base::FilePath& snapshot_file_path); | 159 const base::FilePath& snapshot_file_path); |
161 | 160 |
162 // Called when WriteDataIntoSnapshotFile() fails. | 161 // Called when WriteDataIntoSnapshotFile() fails. |
163 // | 162 // |
164 // |error| specifies the platform file error code. | 163 // |error| specifies the platform file error code. |
165 // | 164 // |
166 // |current_snapshot_request_info_.error_callback| is invoked to notify the | 165 // |current_snapshot_request_info_.error_callback| is invoked to notify the |
167 // caller about |error|. | 166 // caller about |error|. |
168 void OnWriteDataIntoSnapshotFileError(base::PlatformFileError error); | 167 void OnWriteDataIntoSnapshotFileError(base::File::Error error); |
169 | 168 |
170 // Called when ReadBytes() succeeds. | 169 // Called when ReadBytes() succeeds. |
171 // | 170 // |
172 // |success_callback| is invoked to notify the caller about the read bytes. | 171 // |success_callback| is invoked to notify the caller about the read bytes. |
173 // |bytes_read| is the number of bytes read. | 172 // |bytes_read| is the number of bytes read. |
174 void OnDidReadBytes(const ReadBytesSuccessCallback& success_callback, | 173 void OnDidReadBytes(const ReadBytesSuccessCallback& success_callback, |
175 int bytes_read); | 174 int bytes_read); |
176 | 175 |
177 // Handles the device file |error|. |error_callback| is invoked to notify the | 176 // Handles the device file |error|. |error_callback| is invoked to notify the |
178 // caller about the file error. | 177 // caller about the file error. |
179 void HandleDeviceFileError(const ErrorCallback& error_callback, | 178 void HandleDeviceFileError(const ErrorCallback& error_callback, |
180 base::PlatformFileError error); | 179 base::File::Error error); |
181 | 180 |
182 // MTP device initialization state. | 181 // MTP device initialization state. |
183 InitializationState init_state_; | 182 InitializationState init_state_; |
184 | 183 |
185 // Used to make sure only one task is in progress at any time. | 184 // Used to make sure only one task is in progress at any time. |
186 bool task_in_progress_; | 185 bool task_in_progress_; |
187 | 186 |
188 // Registered file system device path. This path does not | 187 // Registered file system device path. This path does not |
189 // correspond to a real device path (e.g. "/usb:2,2:81282"). | 188 // correspond to a real device path (e.g. "/usb:2,2:81282"). |
190 const base::FilePath device_path_; | 189 const base::FilePath device_path_; |
(...skipping 12 matching lines...) Expand all Loading... |
203 // request at any time. | 202 // request at any time. |
204 scoped_ptr<SnapshotRequestInfo> current_snapshot_request_info_; | 203 scoped_ptr<SnapshotRequestInfo> current_snapshot_request_info_; |
205 | 204 |
206 // For callbacks that may run after destruction. | 205 // For callbacks that may run after destruction. |
207 base::WeakPtrFactory<MTPDeviceDelegateImplLinux> weak_ptr_factory_; | 206 base::WeakPtrFactory<MTPDeviceDelegateImplLinux> weak_ptr_factory_; |
208 | 207 |
209 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux); | 208 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux); |
210 }; | 209 }; |
211 | 210 |
212 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H
_ | 211 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_DELEGATE_IMPL_LINUX_H
_ |
OLD | NEW |