OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/files/file.h" |
11 #include "base/location.h" | 12 #include "base/location.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
14 #include "base/platform_file.h" | |
15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 #include "base/win/scoped_comptr.h" | 16 #include "base/win/scoped_comptr.h" |
17 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" | 17 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" |
18 #include "webkit/browser/fileapi/async_file_util.h" | 18 #include "webkit/browser/fileapi/async_file_util.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class FilePath; | 21 class FilePath; |
22 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
23 } | 23 } |
24 | 24 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 enum InitializationState { | 66 enum InitializationState { |
67 UNINITIALIZED = 0, | 67 UNINITIALIZED = 0, |
68 PENDING_INIT, | 68 PENDING_INIT, |
69 INITIALIZED | 69 INITIALIZED |
70 }; | 70 }; |
71 | 71 |
72 // Used to represent pending task details. | 72 // Used to represent pending task details. |
73 struct PendingTaskInfo { | 73 struct PendingTaskInfo { |
74 PendingTaskInfo(const tracked_objects::Location& location, | 74 PendingTaskInfo(const tracked_objects::Location& location, |
75 const base::Callback<base::PlatformFileError(void)>& task, | 75 const base::Callback<base::File::Error(void)>& task, |
76 const base::Callback<void(base::PlatformFileError)>& reply); | 76 const base::Callback<void(base::File::Error)>& reply); |
77 | 77 |
78 const tracked_objects::Location location; | 78 const tracked_objects::Location location; |
79 const base::Callback<base::PlatformFileError(void)> task; | 79 const base::Callback<base::File::Error(void)> task; |
80 const base::Callback<void(base::PlatformFileError)> reply; | 80 const base::Callback<void(base::File::Error)> reply; |
81 }; | 81 }; |
82 | 82 |
83 // Defers the device initializations until the first file operation request. | 83 // Defers the device initializations until the first file operation request. |
84 // Do all the initializations in EnsureInitAndRunTask() function. | 84 // Do all the initializations in EnsureInitAndRunTask() function. |
85 MTPDeviceDelegateImplWin(const base::string16& registered_device_path, | 85 MTPDeviceDelegateImplWin(const base::string16& registered_device_path, |
86 const base::string16& pnp_device_id, | 86 const base::string16& pnp_device_id, |
87 const base::string16& storage_object_id); | 87 const base::string16& storage_object_id); |
88 | 88 |
89 // Destructed via CancelPendingTasksAndDeleteDelegate(). | 89 // Destructed via CancelPendingTasksAndDeleteDelegate(). |
90 virtual ~MTPDeviceDelegateImplWin(); | 90 virtual ~MTPDeviceDelegateImplWin(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // Called when GetFileInfo() completes. |file_info| specifies the requested | 139 // Called when GetFileInfo() completes. |file_info| specifies the requested |
140 // file details. |error| specifies the platform file error code. | 140 // file details. |error| specifies the platform file error code. |
141 // | 141 // |
142 // If the GetFileInfo() succeeds, |success_callback| is invoked to notify the | 142 // If the GetFileInfo() succeeds, |success_callback| is invoked to notify the |
143 // caller about the |file_info| details. | 143 // caller about the |file_info| details. |
144 // | 144 // |
145 // If the GetFileInfo() fails, |file_info| is not set and |error_callback| is | 145 // If the GetFileInfo() fails, |file_info| is not set and |error_callback| is |
146 // invoked to notify the caller about the platform file |error|. | 146 // invoked to notify the caller about the platform file |error|. |
147 void OnGetFileInfo(const GetFileInfoSuccessCallback& success_callback, | 147 void OnGetFileInfo(const GetFileInfoSuccessCallback& success_callback, |
148 const ErrorCallback& error_callback, | 148 const ErrorCallback& error_callback, |
149 base::PlatformFileInfo* file_info, | 149 base::File::Info* file_info, |
150 base::PlatformFileError error); | 150 base::File::Error error); |
151 | 151 |
152 // Called when ReadDirectory() completes. |file_list| contains the directory | 152 // Called when ReadDirectory() completes. |file_list| contains the directory |
153 // file entries information. |error| specifies the platform file error code. | 153 // file entries information. |error| specifies the platform file error code. |
154 // | 154 // |
155 // If the ReadDirectory() succeeds, |success_callback| is invoked to notify | 155 // If the ReadDirectory() succeeds, |success_callback| is invoked to notify |
156 // the caller about the directory file entries. | 156 // the caller about the directory file entries. |
157 // | 157 // |
158 // If the ReadDirectory() fails, |file_list| is not set and |error_callback| | 158 // If the ReadDirectory() fails, |file_list| is not set and |error_callback| |
159 // is invoked to notify the caller about the platform file |error|. | 159 // is invoked to notify the caller about the platform file |error|. |
160 void OnDidReadDirectory(const ReadDirectorySuccessCallback& success_callback, | 160 void OnDidReadDirectory(const ReadDirectorySuccessCallback& success_callback, |
161 const ErrorCallback& error_callback, | 161 const ErrorCallback& error_callback, |
162 fileapi::AsyncFileUtil::EntryList* file_list, | 162 fileapi::AsyncFileUtil::EntryList* file_list, |
163 base::PlatformFileError error); | 163 base::File::Error error); |
164 | 164 |
165 // Called when the get file stream request completes. | 165 // Called when the get file stream request completes. |
166 // |file_details.request_info| contains the CreateSnapshot request param | 166 // |file_details.request_info| contains the CreateSnapshot request param |
167 // details. |error| specifies the platform file error code. | 167 // details. |error| specifies the platform file error code. |
168 // | 168 // |
169 // If the file stream of the device file is successfully | 169 // If the file stream of the device file is successfully |
170 // fetched, |file_details| will contain the required details for the creation | 170 // fetched, |file_details| will contain the required details for the creation |
171 // of the snapshot file. | 171 // of the snapshot file. |
172 // | 172 // |
173 // If the get file stream request fails, |error| is set accordingly. | 173 // If the get file stream request fails, |error| is set accordingly. |
174 void OnGetFileStream(scoped_ptr<SnapshotFileDetails> file_details, | 174 void OnGetFileStream(scoped_ptr<SnapshotFileDetails> file_details, |
175 base::PlatformFileError error); | 175 base::File::Error error); |
176 | 176 |
177 // Called when WriteDataChunkIntoSnapshotFile() completes. | 177 // Called when WriteDataChunkIntoSnapshotFile() completes. |
178 // |bytes_written| specifies the number of bytes written into the | 178 // |bytes_written| specifies the number of bytes written into the |
179 // |snapshot_file_path| during the last write operation. | 179 // |snapshot_file_path| during the last write operation. |
180 // | 180 // |
181 // If the write operation succeeds, |bytes_written| is set to a non-zero | 181 // If the write operation succeeds, |bytes_written| is set to a non-zero |
182 // value. | 182 // value. |
183 // | 183 // |
184 // If the write operation fails, |bytes_written| is set to zero. | 184 // If the write operation fails, |bytes_written| is set to zero. |
185 void OnWroteDataChunkIntoSnapshotFile( | 185 void OnWroteDataChunkIntoSnapshotFile( |
(...skipping 27 matching lines...) Expand all Loading... |
213 // Used to make sure only one task is in progress at any time. | 213 // Used to make sure only one task is in progress at any time. |
214 bool task_in_progress_; | 214 bool task_in_progress_; |
215 | 215 |
216 // For callbacks that may run after destruction. | 216 // For callbacks that may run after destruction. |
217 base::WeakPtrFactory<MTPDeviceDelegateImplWin> weak_ptr_factory_; | 217 base::WeakPtrFactory<MTPDeviceDelegateImplWin> weak_ptr_factory_; |
218 | 218 |
219 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplWin); | 219 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplWin); |
220 }; | 220 }; |
221 | 221 |
222 #endif // CHROME_BROWSER_MEDIA_GALLERIES_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_ | 222 #endif // CHROME_BROWSER_MEDIA_GALLERIES_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_ |
OLD | NEW |