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

Side by Side Diff: chrome/browser/media_galleries/win/mtp_device_delegate_impl_win.h

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
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
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // Called when GetFileInfo() completes. |file_info| specifies the requested 133 // Called when GetFileInfo() completes. |file_info| specifies the requested
134 // file details. |error| specifies the platform file error code. 134 // file details. |error| specifies the platform file error code.
135 // 135 //
136 // If the GetFileInfo() succeeds, |success_callback| is invoked to notify the 136 // If the GetFileInfo() succeeds, |success_callback| is invoked to notify the
137 // caller about the |file_info| details. 137 // caller about the |file_info| details.
138 // 138 //
139 // If the GetFileInfo() fails, |file_info| is not set and |error_callback| is 139 // If the GetFileInfo() fails, |file_info| is not set and |error_callback| is
140 // invoked to notify the caller about the platform file |error|. 140 // invoked to notify the caller about the platform file |error|.
141 void OnGetFileInfo(const GetFileInfoSuccessCallback& success_callback, 141 void OnGetFileInfo(const GetFileInfoSuccessCallback& success_callback,
142 const ErrorCallback& error_callback, 142 const ErrorCallback& error_callback,
143 base::PlatformFileInfo* file_info, 143 base::File::Info* file_info,
144 base::PlatformFileError error); 144 base::File::Error error);
145 145
146 // Called when ReadDirectory() completes. |file_list| contains the directory 146 // Called when ReadDirectory() completes. |file_list| contains the directory
147 // file entries information. |error| specifies the platform file error code. 147 // file entries information. |error| specifies the platform file error code.
148 // 148 //
149 // If the ReadDirectory() succeeds, |success_callback| is invoked to notify 149 // If the ReadDirectory() succeeds, |success_callback| is invoked to notify
150 // the caller about the directory file entries. 150 // the caller about the directory file entries.
151 // 151 //
152 // If the ReadDirectory() fails, |file_list| is not set and |error_callback| 152 // If the ReadDirectory() fails, |file_list| is not set and |error_callback|
153 // is invoked to notify the caller about the platform file |error|. 153 // is invoked to notify the caller about the platform file |error|.
154 void OnDidReadDirectory(const ReadDirectorySuccessCallback& success_callback, 154 void OnDidReadDirectory(const ReadDirectorySuccessCallback& success_callback,
155 const ErrorCallback& error_callback, 155 const ErrorCallback& error_callback,
156 fileapi::AsyncFileUtil::EntryList* file_list, 156 fileapi::AsyncFileUtil::EntryList* file_list,
157 base::PlatformFileError error); 157 base::File::Error error);
158 158
159 // Called when the get file stream request completes. 159 // Called when the get file stream request completes.
160 // |file_details.request_info| contains the CreateSnapshot request param 160 // |file_details.request_info| contains the CreateSnapshot request param
161 // details. |error| specifies the platform file error code. 161 // details. |error| specifies the platform file error code.
162 // 162 //
163 // If the file stream of the device file is successfully 163 // If the file stream of the device file is successfully
164 // fetched, |file_details| will contain the required details for the creation 164 // fetched, |file_details| will contain the required details for the creation
165 // of the snapshot file. 165 // of the snapshot file.
166 // 166 //
167 // If the get file stream request fails, |error| is set accordingly. 167 // If the get file stream request fails, |error| is set accordingly.
168 void OnGetFileStream(scoped_ptr<SnapshotFileDetails> file_details, 168 void OnGetFileStream(scoped_ptr<SnapshotFileDetails> file_details,
169 base::PlatformFileError error); 169 base::File::Error error);
170 170
171 // Called when WriteDataChunkIntoSnapshotFile() completes. 171 // Called when WriteDataChunkIntoSnapshotFile() completes.
172 // |bytes_written| specifies the number of bytes written into the 172 // |bytes_written| specifies the number of bytes written into the
173 // |snapshot_file_path| during the last write operation. 173 // |snapshot_file_path| during the last write operation.
174 // 174 //
175 // If the write operation succeeds, |bytes_written| is set to a non-zero 175 // If the write operation succeeds, |bytes_written| is set to a non-zero
176 // value. 176 // value.
177 // 177 //
178 // If the write operation fails, |bytes_written| is set to zero. 178 // If the write operation fails, |bytes_written| is set to zero.
179 void OnWroteDataChunkIntoSnapshotFile( 179 void OnWroteDataChunkIntoSnapshotFile(
(...skipping 27 matching lines...) Expand all
207 // Used to make sure only one task is in progress at any time. 207 // Used to make sure only one task is in progress at any time.
208 bool task_in_progress_; 208 bool task_in_progress_;
209 209
210 // For callbacks that may run after destruction. 210 // For callbacks that may run after destruction.
211 base::WeakPtrFactory<MTPDeviceDelegateImplWin> weak_ptr_factory_; 211 base::WeakPtrFactory<MTPDeviceDelegateImplWin> weak_ptr_factory_;
212 212
213 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplWin); 213 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplWin);
214 }; 214 };
215 215
216 #endif // CHROME_BROWSER_MEDIA_GALLERIES_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_ 216 #endif // CHROME_BROWSER_MEDIA_GALLERIES_WIN_MTP_DEVICE_DELEGATE_IMPL_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698