| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // initialized. | 88 // initialized. |
| 89 void EnsureInitAndRunTask(const PendingTaskInfo& task_info); | 89 void EnsureInitAndRunTask(const PendingTaskInfo& task_info); |
| 90 | 90 |
| 91 // Writes data from the device to the snapshot file path based on the | 91 // Writes data from the device to the snapshot file path based on the |
| 92 // parameters in |current_snapshot_request_info_| by doing a call-and-reply to | 92 // parameters in |current_snapshot_request_info_| by doing a call-and-reply to |
| 93 // the UI thread. | 93 // the UI thread. |
| 94 // | 94 // |
| 95 // |snapshot_file_info| specifies the metadata details of the snapshot file. | 95 // |snapshot_file_info| specifies the metadata details of the snapshot file. |
| 96 void WriteDataIntoSnapshotFile(const base::File::Info& snapshot_file_info); | 96 void WriteDataIntoSnapshotFile(const base::File::Info& snapshot_file_info); |
| 97 | 97 |
| 98 // Mark the current request as complete and call ProcessNextPendingRequest(). |
| 99 void PendingRequestDone(); |
| 100 |
| 98 // Processes the next pending request. | 101 // Processes the next pending request. |
| 99 void ProcessNextPendingRequest(); | 102 void ProcessNextPendingRequest(); |
| 100 | 103 |
| 101 // Handles the device initialization event. |succeeded| indicates whether | 104 // Handles the device initialization event. |succeeded| indicates whether |
| 102 // device initialization succeeded. | 105 // device initialization succeeded. |
| 103 // | 106 // |
| 104 // If the device is successfully initialized, runs the next pending task. | 107 // If the device is successfully initialized, runs the next pending task. |
| 105 void OnInitCompleted(bool succeeded); | 108 void OnInitCompleted(bool succeeded); |
| 106 | 109 |
| 107 // Called when GetFileInfo() succeeds. |file_info| specifies the | 110 // Called when GetFileInfo() succeeds. |file_info| specifies the |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 173 |
| 171 // Handles the device file |error|. |error_callback| is invoked to notify the | 174 // Handles the device file |error|. |error_callback| is invoked to notify the |
| 172 // caller about the file error. | 175 // caller about the file error. |
| 173 void HandleDeviceFileError(const ErrorCallback& error_callback, | 176 void HandleDeviceFileError(const ErrorCallback& error_callback, |
| 174 base::File::Error error); | 177 base::File::Error error); |
| 175 | 178 |
| 176 // MTP device initialization state. | 179 // MTP device initialization state. |
| 177 InitializationState init_state_; | 180 InitializationState init_state_; |
| 178 | 181 |
| 179 // Used to make sure only one task is in progress at any time. | 182 // Used to make sure only one task is in progress at any time. |
| 183 // Otherwise the browser will try to send too many requests at once and |
| 184 // overload the device. |
| 180 bool task_in_progress_; | 185 bool task_in_progress_; |
| 181 | 186 |
| 182 // Registered file system device path. This path does not | 187 // Registered file system device path. This path does not |
| 183 // 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"). |
| 184 const base::FilePath device_path_; | 189 const base::FilePath device_path_; |
| 185 | 190 |
| 186 // MTP device storage name (e.g. "usb:2,2:81282"). | 191 // MTP device storage name (e.g. "usb:2,2:81282"). |
| 187 std::string storage_name_; | 192 std::string storage_name_; |
| 188 | 193 |
| 189 // A list of pending tasks that needs to be run when the device is | 194 // A list of pending tasks that needs to be run when the device is |
| 190 // initialized or when the current task in progress is complete. | 195 // initialized or when the current task in progress is complete. |
| 191 std::queue<PendingTaskInfo> pending_tasks_; | 196 std::queue<PendingTaskInfo> pending_tasks_; |
| 192 | 197 |
| 193 // Used to track the current snapshot file request. A snapshot file is created | 198 // Used to track the current snapshot file request. A snapshot file is created |
| 194 // incrementally. CreateSnapshotFile request reads the device file and writes | 199 // incrementally. CreateSnapshotFile request reads the device file and writes |
| 195 // to the snapshot file in chunks. In order to retain the order of the | 200 // to the snapshot file in chunks. In order to retain the order of the |
| 196 // snapshot file requests, make sure there is only one active snapshot file | 201 // snapshot file requests, make sure there is only one active snapshot file |
| 197 // request at any time. | 202 // request at any time. |
| 198 scoped_ptr<SnapshotRequestInfo> current_snapshot_request_info_; | 203 scoped_ptr<SnapshotRequestInfo> current_snapshot_request_info_; |
| 199 | 204 |
| 200 // For callbacks that may run after destruction. | 205 // For callbacks that may run after destruction. |
| 201 base::WeakPtrFactory<MTPDeviceDelegateImplLinux> weak_ptr_factory_; | 206 base::WeakPtrFactory<MTPDeviceDelegateImplLinux> weak_ptr_factory_; |
| 202 | 207 |
| 203 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux); | 208 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux); |
| 204 }; | 209 }; |
| 205 | 210 |
| 206 #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 |