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

Side by Side Diff: chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More nits 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 #include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h" 5 #include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 void DeviceMediaAsyncFileUtil::CreateOrOpen( 69 void DeviceMediaAsyncFileUtil::CreateOrOpen(
70 scoped_ptr<FileSystemOperationContext> context, 70 scoped_ptr<FileSystemOperationContext> context,
71 const FileSystemURL& url, 71 const FileSystemURL& url,
72 int file_flags, 72 int file_flags,
73 const CreateOrOpenCallback& callback) { 73 const CreateOrOpenCallback& callback) {
74 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 74 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
75 NOTIMPLEMENTED(); 75 NOTIMPLEMENTED();
76 base::PlatformFile invalid_file = base::kInvalidPlatformFileValue; 76 base::PlatformFile invalid_file = base::kInvalidPlatformFileValue;
77 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, 77 callback.Run(base::File::FILE_ERROR_SECURITY,
78 base::PassPlatformFile(&invalid_file), 78 base::PassPlatformFile(&invalid_file),
79 base::Closure()); 79 base::Closure());
80 } 80 }
81 81
82 void DeviceMediaAsyncFileUtil::EnsureFileExists( 82 void DeviceMediaAsyncFileUtil::EnsureFileExists(
83 scoped_ptr<FileSystemOperationContext> context, 83 scoped_ptr<FileSystemOperationContext> context,
84 const FileSystemURL& url, 84 const FileSystemURL& url,
85 const EnsureFileExistsCallback& callback) { 85 const EnsureFileExistsCallback& callback) {
86 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 86 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
87 NOTIMPLEMENTED(); 87 NOTIMPLEMENTED();
88 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, false); 88 callback.Run(base::File::FILE_ERROR_SECURITY, false);
89 } 89 }
90 90
91 void DeviceMediaAsyncFileUtil::CreateDirectory( 91 void DeviceMediaAsyncFileUtil::CreateDirectory(
92 scoped_ptr<FileSystemOperationContext> context, 92 scoped_ptr<FileSystemOperationContext> context,
93 const FileSystemURL& url, 93 const FileSystemURL& url,
94 bool exclusive, 94 bool exclusive,
95 bool recursive, 95 bool recursive,
96 const StatusCallback& callback) { 96 const StatusCallback& callback) {
97 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 97 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
98 NOTIMPLEMENTED(); 98 NOTIMPLEMENTED();
99 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 99 callback.Run(base::File::FILE_ERROR_SECURITY);
100 } 100 }
101 101
102 void DeviceMediaAsyncFileUtil::GetFileInfo( 102 void DeviceMediaAsyncFileUtil::GetFileInfo(
103 scoped_ptr<FileSystemOperationContext> context, 103 scoped_ptr<FileSystemOperationContext> context,
104 const FileSystemURL& url, 104 const FileSystemURL& url,
105 const GetFileInfoCallback& callback) { 105 const GetFileInfoCallback& callback) {
106 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 106 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
107 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 107 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
108 if (!delegate) { 108 if (!delegate) {
109 OnGetFileInfoError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND); 109 OnGetFileInfoError(callback, base::File::FILE_ERROR_NOT_FOUND);
110 return; 110 return;
111 } 111 }
112 delegate->GetFileInfo( 112 delegate->GetFileInfo(
113 url.path(), 113 url.path(),
114 base::Bind(&DeviceMediaAsyncFileUtil::OnDidGetFileInfo, 114 base::Bind(&DeviceMediaAsyncFileUtil::OnDidGetFileInfo,
115 weak_ptr_factory_.GetWeakPtr(), 115 weak_ptr_factory_.GetWeakPtr(),
116 callback), 116 callback),
117 base::Bind(&DeviceMediaAsyncFileUtil::OnGetFileInfoError, 117 base::Bind(&DeviceMediaAsyncFileUtil::OnGetFileInfoError,
118 weak_ptr_factory_.GetWeakPtr(), 118 weak_ptr_factory_.GetWeakPtr(),
119 callback)); 119 callback));
120 } 120 }
121 121
122 void DeviceMediaAsyncFileUtil::ReadDirectory( 122 void DeviceMediaAsyncFileUtil::ReadDirectory(
123 scoped_ptr<FileSystemOperationContext> context, 123 scoped_ptr<FileSystemOperationContext> context,
124 const FileSystemURL& url, 124 const FileSystemURL& url,
125 const ReadDirectoryCallback& callback) { 125 const ReadDirectoryCallback& callback) {
126 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 126 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
127 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 127 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
128 if (!delegate) { 128 if (!delegate) {
129 OnReadDirectoryError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND); 129 OnReadDirectoryError(callback, base::File::FILE_ERROR_NOT_FOUND);
130 return; 130 return;
131 } 131 }
132 delegate->ReadDirectory( 132 delegate->ReadDirectory(
133 url.path(), 133 url.path(),
134 base::Bind(&DeviceMediaAsyncFileUtil::OnDidReadDirectory, 134 base::Bind(&DeviceMediaAsyncFileUtil::OnDidReadDirectory,
135 weak_ptr_factory_.GetWeakPtr(), 135 weak_ptr_factory_.GetWeakPtr(),
136 callback), 136 callback),
137 base::Bind(&DeviceMediaAsyncFileUtil::OnReadDirectoryError, 137 base::Bind(&DeviceMediaAsyncFileUtil::OnReadDirectoryError,
138 weak_ptr_factory_.GetWeakPtr(), 138 weak_ptr_factory_.GetWeakPtr(),
139 callback)); 139 callback));
140 } 140 }
141 141
142 void DeviceMediaAsyncFileUtil::Touch( 142 void DeviceMediaAsyncFileUtil::Touch(
143 scoped_ptr<FileSystemOperationContext> context, 143 scoped_ptr<FileSystemOperationContext> context,
144 const FileSystemURL& url, 144 const FileSystemURL& url,
145 const base::Time& last_access_time, 145 const base::Time& last_access_time,
146 const base::Time& last_modified_time, 146 const base::Time& last_modified_time,
147 const StatusCallback& callback) { 147 const StatusCallback& callback) {
148 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 148 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
149 NOTIMPLEMENTED(); 149 NOTIMPLEMENTED();
150 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 150 callback.Run(base::File::FILE_ERROR_SECURITY);
151 } 151 }
152 152
153 void DeviceMediaAsyncFileUtil::Truncate( 153 void DeviceMediaAsyncFileUtil::Truncate(
154 scoped_ptr<FileSystemOperationContext> context, 154 scoped_ptr<FileSystemOperationContext> context,
155 const FileSystemURL& url, 155 const FileSystemURL& url,
156 int64 length, 156 int64 length,
157 const StatusCallback& callback) { 157 const StatusCallback& callback) {
158 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 158 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
159 NOTIMPLEMENTED(); 159 NOTIMPLEMENTED();
160 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 160 callback.Run(base::File::FILE_ERROR_SECURITY);
161 } 161 }
162 162
163 void DeviceMediaAsyncFileUtil::CopyFileLocal( 163 void DeviceMediaAsyncFileUtil::CopyFileLocal(
164 scoped_ptr<FileSystemOperationContext> context, 164 scoped_ptr<FileSystemOperationContext> context,
165 const FileSystemURL& src_url, 165 const FileSystemURL& src_url,
166 const FileSystemURL& dest_url, 166 const FileSystemURL& dest_url,
167 CopyOrMoveOption option, 167 CopyOrMoveOption option,
168 const CopyFileProgressCallback& progress_callback, 168 const CopyFileProgressCallback& progress_callback,
169 const StatusCallback& callback) { 169 const StatusCallback& callback) {
170 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 170 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
171 NOTIMPLEMENTED(); 171 NOTIMPLEMENTED();
172 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 172 callback.Run(base::File::FILE_ERROR_SECURITY);
173 } 173 }
174 174
175 void DeviceMediaAsyncFileUtil::MoveFileLocal( 175 void DeviceMediaAsyncFileUtil::MoveFileLocal(
176 scoped_ptr<FileSystemOperationContext> context, 176 scoped_ptr<FileSystemOperationContext> context,
177 const FileSystemURL& src_url, 177 const FileSystemURL& src_url,
178 const FileSystemURL& dest_url, 178 const FileSystemURL& dest_url,
179 CopyOrMoveOption option, 179 CopyOrMoveOption option,
180 const StatusCallback& callback) { 180 const StatusCallback& callback) {
181 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 181 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
182 NOTIMPLEMENTED(); 182 NOTIMPLEMENTED();
183 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 183 callback.Run(base::File::FILE_ERROR_SECURITY);
184 } 184 }
185 185
186 void DeviceMediaAsyncFileUtil::CopyInForeignFile( 186 void DeviceMediaAsyncFileUtil::CopyInForeignFile(
187 scoped_ptr<FileSystemOperationContext> context, 187 scoped_ptr<FileSystemOperationContext> context,
188 const base::FilePath& src_file_path, 188 const base::FilePath& src_file_path,
189 const FileSystemURL& dest_url, 189 const FileSystemURL& dest_url,
190 const StatusCallback& callback) { 190 const StatusCallback& callback) {
191 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 191 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
192 NOTIMPLEMENTED(); 192 NOTIMPLEMENTED();
193 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 193 callback.Run(base::File::FILE_ERROR_SECURITY);
194 } 194 }
195 195
196 void DeviceMediaAsyncFileUtil::DeleteFile( 196 void DeviceMediaAsyncFileUtil::DeleteFile(
197 scoped_ptr<FileSystemOperationContext> context, 197 scoped_ptr<FileSystemOperationContext> context,
198 const FileSystemURL& url, 198 const FileSystemURL& url,
199 const StatusCallback& callback) { 199 const StatusCallback& callback) {
200 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 200 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
201 NOTIMPLEMENTED(); 201 NOTIMPLEMENTED();
202 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 202 callback.Run(base::File::FILE_ERROR_SECURITY);
203 } 203 }
204 204
205 void DeviceMediaAsyncFileUtil::DeleteDirectory( 205 void DeviceMediaAsyncFileUtil::DeleteDirectory(
206 scoped_ptr<FileSystemOperationContext> context, 206 scoped_ptr<FileSystemOperationContext> context,
207 const FileSystemURL& url, 207 const FileSystemURL& url,
208 const StatusCallback& callback) { 208 const StatusCallback& callback) {
209 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 209 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
210 NOTIMPLEMENTED(); 210 NOTIMPLEMENTED();
211 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 211 callback.Run(base::File::FILE_ERROR_SECURITY);
212 } 212 }
213 213
214 void DeviceMediaAsyncFileUtil::DeleteRecursively( 214 void DeviceMediaAsyncFileUtil::DeleteRecursively(
215 scoped_ptr<FileSystemOperationContext> context, 215 scoped_ptr<FileSystemOperationContext> context,
216 const FileSystemURL& url, 216 const FileSystemURL& url,
217 const StatusCallback& callback) { 217 const StatusCallback& callback) {
218 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 218 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
219 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); 219 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
220 } 220 }
221 221
222 void DeviceMediaAsyncFileUtil::CreateSnapshotFile( 222 void DeviceMediaAsyncFileUtil::CreateSnapshotFile(
223 scoped_ptr<FileSystemOperationContext> context, 223 scoped_ptr<FileSystemOperationContext> context,
224 const FileSystemURL& url, 224 const FileSystemURL& url,
225 const CreateSnapshotFileCallback& callback) { 225 const CreateSnapshotFileCallback& callback) {
226 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 226 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
227 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 227 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
228 if (!delegate) { 228 if (!delegate) {
229 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND); 229 OnCreateSnapshotFileError(callback, base::File::FILE_ERROR_NOT_FOUND);
230 return; 230 return;
231 } 231 }
232 base::FilePath* snapshot_file_path = new base::FilePath; 232 base::FilePath* snapshot_file_path = new base::FilePath;
233 base::SequencedTaskRunner* task_runner = context->task_runner(); 233 base::SequencedTaskRunner* task_runner = context->task_runner();
234 const bool success = task_runner->PostTaskAndReply( 234 const bool success = task_runner->PostTaskAndReply(
235 FROM_HERE, 235 FROM_HERE,
236 base::Bind(&CreateSnapshotFileOnBlockingPool, 236 base::Bind(&CreateSnapshotFileOnBlockingPool,
237 url.path(), 237 url.path(),
238 profile_path_, 238 profile_path_,
239 base::Unretained(snapshot_file_path)), 239 base::Unretained(snapshot_file_path)),
240 base::Bind(&DeviceMediaAsyncFileUtil::OnSnapshotFileCreatedRunTask, 240 base::Bind(&DeviceMediaAsyncFileUtil::OnSnapshotFileCreatedRunTask,
241 weak_ptr_factory_.GetWeakPtr(), 241 weak_ptr_factory_.GetWeakPtr(),
242 base::Passed(&context), 242 base::Passed(&context),
243 callback, 243 callback,
244 url, 244 url,
245 base::Owned(snapshot_file_path))); 245 base::Owned(snapshot_file_path)));
246 DCHECK(success); 246 DCHECK(success);
247 } 247 }
248 248
249 DeviceMediaAsyncFileUtil::DeviceMediaAsyncFileUtil( 249 DeviceMediaAsyncFileUtil::DeviceMediaAsyncFileUtil(
250 const base::FilePath& profile_path) 250 const base::FilePath& profile_path)
251 : profile_path_(profile_path), 251 : profile_path_(profile_path),
252 weak_ptr_factory_(this) { 252 weak_ptr_factory_(this) {
253 } 253 }
254 254
255 void DeviceMediaAsyncFileUtil::OnDidGetFileInfo( 255 void DeviceMediaAsyncFileUtil::OnDidGetFileInfo(
256 const AsyncFileUtil::GetFileInfoCallback& callback, 256 const AsyncFileUtil::GetFileInfoCallback& callback,
257 const base::PlatformFileInfo& file_info) { 257 const base::File::Info& file_info) {
258 callback.Run(base::PLATFORM_FILE_OK, file_info); 258 callback.Run(base::File::FILE_OK, file_info);
259 } 259 }
260 260
261 void DeviceMediaAsyncFileUtil::OnGetFileInfoError( 261 void DeviceMediaAsyncFileUtil::OnGetFileInfoError(
262 const AsyncFileUtil::GetFileInfoCallback& callback, 262 const AsyncFileUtil::GetFileInfoCallback& callback,
263 base::PlatformFileError error) { 263 base::File::Error error) {
264 callback.Run(error, base::PlatformFileInfo()); 264 callback.Run(error, base::File::Info());
265 } 265 }
266 266
267 void DeviceMediaAsyncFileUtil::OnDidReadDirectory( 267 void DeviceMediaAsyncFileUtil::OnDidReadDirectory(
268 const AsyncFileUtil::ReadDirectoryCallback& callback, 268 const AsyncFileUtil::ReadDirectoryCallback& callback,
269 const AsyncFileUtil::EntryList& file_list, 269 const AsyncFileUtil::EntryList& file_list,
270 bool has_more) { 270 bool has_more) {
271 callback.Run(base::PLATFORM_FILE_OK, file_list, has_more); 271 callback.Run(base::File::FILE_OK, file_list, has_more);
272 } 272 }
273 273
274 void DeviceMediaAsyncFileUtil::OnReadDirectoryError( 274 void DeviceMediaAsyncFileUtil::OnReadDirectoryError(
275 const AsyncFileUtil::ReadDirectoryCallback& callback, 275 const AsyncFileUtil::ReadDirectoryCallback& callback,
276 base::PlatformFileError error) { 276 base::File::Error error) {
277 callback.Run(error, AsyncFileUtil::EntryList(), false /*no more*/); 277 callback.Run(error, AsyncFileUtil::EntryList(), false /*no more*/);
278 } 278 }
279 279
280 void DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile( 280 void DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile(
281 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 281 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
282 base::SequencedTaskRunner* media_task_runner, 282 base::SequencedTaskRunner* media_task_runner,
283 const base::PlatformFileInfo& file_info, 283 const base::File::Info& file_info,
284 const base::FilePath& platform_path) { 284 const base::FilePath& platform_path) {
285 base::PostTaskAndReplyWithResult( 285 base::PostTaskAndReplyWithResult(
286 media_task_runner, 286 media_task_runner,
287 FROM_HERE, 287 FROM_HERE,
288 base::Bind(&NativeMediaFileUtil::IsMediaFile, platform_path), 288 base::Bind(&NativeMediaFileUtil::IsMediaFile, platform_path),
289 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCheckMedia, 289 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCheckMedia,
290 weak_ptr_factory_.GetWeakPtr(), 290 weak_ptr_factory_.GetWeakPtr(),
291 callback, 291 callback,
292 file_info, 292 file_info,
293 ShareableFileReference::GetOrCreate( 293 ShareableFileReference::GetOrCreate(
294 platform_path, 294 platform_path,
295 ShareableFileReference::DELETE_ON_FINAL_RELEASE, 295 ShareableFileReference::DELETE_ON_FINAL_RELEASE,
296 media_task_runner))); 296 media_task_runner)));
297 } 297 }
298 298
299 void DeviceMediaAsyncFileUtil::OnDidCheckMedia( 299 void DeviceMediaAsyncFileUtil::OnDidCheckMedia(
300 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 300 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
301 const base::PlatformFileInfo& file_info, 301 const base::File::Info& file_info,
302 scoped_refptr<webkit_blob::ShareableFileReference> platform_file, 302 scoped_refptr<webkit_blob::ShareableFileReference> platform_file,
303 base::PlatformFileError error) { 303 base::File::Error error) {
304 base::FilePath platform_path(platform_file.get()->path()); 304 base::FilePath platform_path(platform_file.get()->path());
305 if (error != base::PLATFORM_FILE_OK) 305 if (error != base::File::FILE_OK)
306 platform_file = NULL; 306 platform_file = NULL;
307 callback.Run(error, file_info, platform_path, platform_file); 307 callback.Run(error, file_info, platform_path, platform_file);
308 } 308 }
309 309
310 void DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError( 310 void DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError(
311 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 311 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
312 base::PlatformFileError error) { 312 base::File::Error error) {
313 callback.Run(error, base::PlatformFileInfo(), base::FilePath(), 313 callback.Run(error, base::File::Info(), base::FilePath(),
314 scoped_refptr<ShareableFileReference>()); 314 scoped_refptr<ShareableFileReference>());
315 } 315 }
316 316
317 void DeviceMediaAsyncFileUtil::OnSnapshotFileCreatedRunTask( 317 void DeviceMediaAsyncFileUtil::OnSnapshotFileCreatedRunTask(
318 scoped_ptr<FileSystemOperationContext> context, 318 scoped_ptr<FileSystemOperationContext> context,
319 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 319 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
320 const FileSystemURL& url, 320 const FileSystemURL& url,
321 base::FilePath* snapshot_file_path) { 321 base::FilePath* snapshot_file_path) {
322 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 322 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
323 if (!snapshot_file_path || snapshot_file_path->empty()) { 323 if (!snapshot_file_path || snapshot_file_path->empty()) {
324 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_FAILED); 324 OnCreateSnapshotFileError(callback, base::File::FILE_ERROR_FAILED);
325 return; 325 return;
326 } 326 }
327 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 327 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
328 if (!delegate) { 328 if (!delegate) {
329 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND); 329 OnCreateSnapshotFileError(callback, base::File::FILE_ERROR_NOT_FOUND);
330 return; 330 return;
331 } 331 }
332 delegate->CreateSnapshotFile( 332 delegate->CreateSnapshotFile(
333 url.path(), // device file path 333 url.path(), // device file path
334 *snapshot_file_path, 334 *snapshot_file_path,
335 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile, 335 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile,
336 weak_ptr_factory_.GetWeakPtr(), 336 weak_ptr_factory_.GetWeakPtr(),
337 callback, 337 callback,
338 make_scoped_refptr(context->task_runner())), 338 make_scoped_refptr(context->task_runner())),
339 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError, 339 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError,
340 weak_ptr_factory_.GetWeakPtr(), 340 weak_ptr_factory_.GetWeakPtr(),
341 callback)); 341 callback));
342 } 342 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698