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

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: Rebase Created 6 years, 10 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 void DeviceMediaAsyncFileUtil::CreateOrOpen( 74 void DeviceMediaAsyncFileUtil::CreateOrOpen(
75 scoped_ptr<FileSystemOperationContext> context, 75 scoped_ptr<FileSystemOperationContext> context,
76 const FileSystemURL& url, 76 const FileSystemURL& url,
77 int file_flags, 77 int file_flags,
78 const CreateOrOpenCallback& callback) { 78 const CreateOrOpenCallback& callback) {
79 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 79 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
80 NOTIMPLEMENTED(); 80 NOTIMPLEMENTED();
81 base::PlatformFile invalid_file = base::kInvalidPlatformFileValue; 81 base::PlatformFile invalid_file = base::kInvalidPlatformFileValue;
82 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, 82 callback.Run(base::File::FILE_ERROR_SECURITY,
83 base::PassPlatformFile(&invalid_file), 83 base::PassPlatformFile(&invalid_file),
84 base::Closure()); 84 base::Closure());
85 } 85 }
86 86
87 void DeviceMediaAsyncFileUtil::EnsureFileExists( 87 void DeviceMediaAsyncFileUtil::EnsureFileExists(
88 scoped_ptr<FileSystemOperationContext> context, 88 scoped_ptr<FileSystemOperationContext> context,
89 const FileSystemURL& url, 89 const FileSystemURL& url,
90 const EnsureFileExistsCallback& callback) { 90 const EnsureFileExistsCallback& callback) {
91 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 91 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
92 NOTIMPLEMENTED(); 92 NOTIMPLEMENTED();
93 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, false); 93 callback.Run(base::File::FILE_ERROR_SECURITY, false);
94 } 94 }
95 95
96 void DeviceMediaAsyncFileUtil::CreateDirectory( 96 void DeviceMediaAsyncFileUtil::CreateDirectory(
97 scoped_ptr<FileSystemOperationContext> context, 97 scoped_ptr<FileSystemOperationContext> context,
98 const FileSystemURL& url, 98 const FileSystemURL& url,
99 bool exclusive, 99 bool exclusive,
100 bool recursive, 100 bool recursive,
101 const StatusCallback& callback) { 101 const StatusCallback& callback) {
102 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 102 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
103 NOTIMPLEMENTED(); 103 NOTIMPLEMENTED();
104 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 104 callback.Run(base::File::FILE_ERROR_SECURITY);
105 } 105 }
106 106
107 void DeviceMediaAsyncFileUtil::GetFileInfo( 107 void DeviceMediaAsyncFileUtil::GetFileInfo(
108 scoped_ptr<FileSystemOperationContext> context, 108 scoped_ptr<FileSystemOperationContext> context,
109 const FileSystemURL& url, 109 const FileSystemURL& url,
110 const GetFileInfoCallback& callback) { 110 const GetFileInfoCallback& callback) {
111 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 111 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
112 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 112 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
113 if (!delegate) { 113 if (!delegate) {
114 OnGetFileInfoError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND); 114 OnGetFileInfoError(callback, base::File::FILE_ERROR_NOT_FOUND);
115 return; 115 return;
116 } 116 }
117 delegate->GetFileInfo( 117 delegate->GetFileInfo(
118 url.path(), 118 url.path(),
119 base::Bind(&DeviceMediaAsyncFileUtil::OnDidGetFileInfo, 119 base::Bind(&DeviceMediaAsyncFileUtil::OnDidGetFileInfo,
120 weak_ptr_factory_.GetWeakPtr(), 120 weak_ptr_factory_.GetWeakPtr(),
121 callback), 121 callback),
122 base::Bind(&DeviceMediaAsyncFileUtil::OnGetFileInfoError, 122 base::Bind(&DeviceMediaAsyncFileUtil::OnGetFileInfoError,
123 weak_ptr_factory_.GetWeakPtr(), 123 weak_ptr_factory_.GetWeakPtr(),
124 callback)); 124 callback));
125 } 125 }
126 126
127 void DeviceMediaAsyncFileUtil::ReadDirectory( 127 void DeviceMediaAsyncFileUtil::ReadDirectory(
128 scoped_ptr<FileSystemOperationContext> context, 128 scoped_ptr<FileSystemOperationContext> context,
129 const FileSystemURL& url, 129 const FileSystemURL& url,
130 const ReadDirectoryCallback& callback) { 130 const ReadDirectoryCallback& callback) {
131 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 131 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
132 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 132 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
133 if (!delegate) { 133 if (!delegate) {
134 OnReadDirectoryError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND); 134 OnReadDirectoryError(callback, base::File::FILE_ERROR_NOT_FOUND);
135 return; 135 return;
136 } 136 }
137 delegate->ReadDirectory( 137 delegate->ReadDirectory(
138 url.path(), 138 url.path(),
139 base::Bind(&DeviceMediaAsyncFileUtil::OnDidReadDirectory, 139 base::Bind(&DeviceMediaAsyncFileUtil::OnDidReadDirectory,
140 weak_ptr_factory_.GetWeakPtr(), 140 weak_ptr_factory_.GetWeakPtr(),
141 callback), 141 callback),
142 base::Bind(&DeviceMediaAsyncFileUtil::OnReadDirectoryError, 142 base::Bind(&DeviceMediaAsyncFileUtil::OnReadDirectoryError,
143 weak_ptr_factory_.GetWeakPtr(), 143 weak_ptr_factory_.GetWeakPtr(),
144 callback)); 144 callback));
145 } 145 }
146 146
147 void DeviceMediaAsyncFileUtil::Touch( 147 void DeviceMediaAsyncFileUtil::Touch(
148 scoped_ptr<FileSystemOperationContext> context, 148 scoped_ptr<FileSystemOperationContext> context,
149 const FileSystemURL& url, 149 const FileSystemURL& url,
150 const base::Time& last_access_time, 150 const base::Time& last_access_time,
151 const base::Time& last_modified_time, 151 const base::Time& last_modified_time,
152 const StatusCallback& callback) { 152 const StatusCallback& callback) {
153 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 153 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
154 NOTIMPLEMENTED(); 154 NOTIMPLEMENTED();
155 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 155 callback.Run(base::File::FILE_ERROR_SECURITY);
156 } 156 }
157 157
158 void DeviceMediaAsyncFileUtil::Truncate( 158 void DeviceMediaAsyncFileUtil::Truncate(
159 scoped_ptr<FileSystemOperationContext> context, 159 scoped_ptr<FileSystemOperationContext> context,
160 const FileSystemURL& url, 160 const FileSystemURL& url,
161 int64 length, 161 int64 length,
162 const StatusCallback& callback) { 162 const StatusCallback& callback) {
163 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 163 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
164 NOTIMPLEMENTED(); 164 NOTIMPLEMENTED();
165 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 165 callback.Run(base::File::FILE_ERROR_SECURITY);
166 } 166 }
167 167
168 void DeviceMediaAsyncFileUtil::CopyFileLocal( 168 void DeviceMediaAsyncFileUtil::CopyFileLocal(
169 scoped_ptr<FileSystemOperationContext> context, 169 scoped_ptr<FileSystemOperationContext> context,
170 const FileSystemURL& src_url, 170 const FileSystemURL& src_url,
171 const FileSystemURL& dest_url, 171 const FileSystemURL& dest_url,
172 CopyOrMoveOption option, 172 CopyOrMoveOption option,
173 const CopyFileProgressCallback& progress_callback, 173 const CopyFileProgressCallback& progress_callback,
174 const StatusCallback& callback) { 174 const StatusCallback& callback) {
175 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 175 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
176 NOTIMPLEMENTED(); 176 NOTIMPLEMENTED();
177 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 177 callback.Run(base::File::FILE_ERROR_SECURITY);
178 } 178 }
179 179
180 void DeviceMediaAsyncFileUtil::MoveFileLocal( 180 void DeviceMediaAsyncFileUtil::MoveFileLocal(
181 scoped_ptr<FileSystemOperationContext> context, 181 scoped_ptr<FileSystemOperationContext> context,
182 const FileSystemURL& src_url, 182 const FileSystemURL& src_url,
183 const FileSystemURL& dest_url, 183 const FileSystemURL& dest_url,
184 CopyOrMoveOption option, 184 CopyOrMoveOption option,
185 const StatusCallback& callback) { 185 const StatusCallback& callback) {
186 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 186 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
187 NOTIMPLEMENTED(); 187 NOTIMPLEMENTED();
188 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 188 callback.Run(base::File::FILE_ERROR_SECURITY);
189 } 189 }
190 190
191 void DeviceMediaAsyncFileUtil::CopyInForeignFile( 191 void DeviceMediaAsyncFileUtil::CopyInForeignFile(
192 scoped_ptr<FileSystemOperationContext> context, 192 scoped_ptr<FileSystemOperationContext> context,
193 const base::FilePath& src_file_path, 193 const base::FilePath& src_file_path,
194 const FileSystemURL& dest_url, 194 const FileSystemURL& dest_url,
195 const StatusCallback& callback) { 195 const StatusCallback& callback) {
196 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 196 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
197 NOTIMPLEMENTED(); 197 NOTIMPLEMENTED();
198 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 198 callback.Run(base::File::FILE_ERROR_SECURITY);
199 } 199 }
200 200
201 void DeviceMediaAsyncFileUtil::DeleteFile( 201 void DeviceMediaAsyncFileUtil::DeleteFile(
202 scoped_ptr<FileSystemOperationContext> context, 202 scoped_ptr<FileSystemOperationContext> context,
203 const FileSystemURL& url, 203 const FileSystemURL& url,
204 const StatusCallback& callback) { 204 const StatusCallback& callback) {
205 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 205 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
206 NOTIMPLEMENTED(); 206 NOTIMPLEMENTED();
207 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 207 callback.Run(base::File::FILE_ERROR_SECURITY);
208 } 208 }
209 209
210 void DeviceMediaAsyncFileUtil::DeleteDirectory( 210 void DeviceMediaAsyncFileUtil::DeleteDirectory(
211 scoped_ptr<FileSystemOperationContext> context, 211 scoped_ptr<FileSystemOperationContext> context,
212 const FileSystemURL& url, 212 const FileSystemURL& url,
213 const StatusCallback& callback) { 213 const StatusCallback& callback) {
214 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 214 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
215 NOTIMPLEMENTED(); 215 NOTIMPLEMENTED();
216 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 216 callback.Run(base::File::FILE_ERROR_SECURITY);
217 } 217 }
218 218
219 void DeviceMediaAsyncFileUtil::DeleteRecursively( 219 void DeviceMediaAsyncFileUtil::DeleteRecursively(
220 scoped_ptr<FileSystemOperationContext> context, 220 scoped_ptr<FileSystemOperationContext> context,
221 const FileSystemURL& url, 221 const FileSystemURL& url,
222 const StatusCallback& callback) { 222 const StatusCallback& callback) {
223 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 223 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
224 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); 224 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
225 } 225 }
226 226
227 void DeviceMediaAsyncFileUtil::CreateSnapshotFile( 227 void DeviceMediaAsyncFileUtil::CreateSnapshotFile(
228 scoped_ptr<FileSystemOperationContext> context, 228 scoped_ptr<FileSystemOperationContext> context,
229 const FileSystemURL& url, 229 const FileSystemURL& url,
230 const CreateSnapshotFileCallback& callback) { 230 const CreateSnapshotFileCallback& callback) {
231 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 231 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
232 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 232 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
233 if (!delegate) { 233 if (!delegate) {
234 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND); 234 OnCreateSnapshotFileError(callback, base::File::FILE_ERROR_NOT_FOUND);
235 return; 235 return;
236 } 236 }
237 237
238 scoped_refptr<base::SequencedTaskRunner> task_runner = context->task_runner(); 238 scoped_refptr<base::SequencedTaskRunner> task_runner = context->task_runner();
239 239
240 if (delegate->IsStreaming()) { 240 if (delegate->IsStreaming()) {
241 GetFileInfo( 241 GetFileInfo(
242 context.Pass(), 242 context.Pass(),
243 url, 243 url,
244 base::Bind(&DeviceMediaAsyncFileUtil::GetHeaderBytesForMIMESniffing, 244 base::Bind(&DeviceMediaAsyncFileUtil::GetHeaderBytesForMIMESniffing,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 278 }
279 279
280 DeviceMediaAsyncFileUtil::DeviceMediaAsyncFileUtil( 280 DeviceMediaAsyncFileUtil::DeviceMediaAsyncFileUtil(
281 const base::FilePath& profile_path) 281 const base::FilePath& profile_path)
282 : profile_path_(profile_path), 282 : profile_path_(profile_path),
283 weak_ptr_factory_(this) { 283 weak_ptr_factory_(this) {
284 } 284 }
285 285
286 void DeviceMediaAsyncFileUtil::OnDidGetFileInfo( 286 void DeviceMediaAsyncFileUtil::OnDidGetFileInfo(
287 const AsyncFileUtil::GetFileInfoCallback& callback, 287 const AsyncFileUtil::GetFileInfoCallback& callback,
288 const base::PlatformFileInfo& file_info) { 288 const base::File::Info& file_info) {
289 callback.Run(base::PLATFORM_FILE_OK, file_info); 289 callback.Run(base::File::FILE_OK, file_info);
290 } 290 }
291 291
292 void DeviceMediaAsyncFileUtil::OnGetFileInfoError( 292 void DeviceMediaAsyncFileUtil::OnGetFileInfoError(
293 const AsyncFileUtil::GetFileInfoCallback& callback, 293 const AsyncFileUtil::GetFileInfoCallback& callback,
294 base::PlatformFileError error) { 294 base::File::Error error) {
295 callback.Run(error, base::PlatformFileInfo()); 295 callback.Run(error, base::File::Info());
296 } 296 }
297 297
298 void DeviceMediaAsyncFileUtil::OnDidReadDirectory( 298 void DeviceMediaAsyncFileUtil::OnDidReadDirectory(
299 const AsyncFileUtil::ReadDirectoryCallback& callback, 299 const AsyncFileUtil::ReadDirectoryCallback& callback,
300 const AsyncFileUtil::EntryList& file_list, 300 const AsyncFileUtil::EntryList& file_list,
301 bool has_more) { 301 bool has_more) {
302 callback.Run(base::PLATFORM_FILE_OK, file_list, has_more); 302 callback.Run(base::File::FILE_OK, file_list, has_more);
303 } 303 }
304 304
305 void DeviceMediaAsyncFileUtil::OnReadDirectoryError( 305 void DeviceMediaAsyncFileUtil::OnReadDirectoryError(
306 const AsyncFileUtil::ReadDirectoryCallback& callback, 306 const AsyncFileUtil::ReadDirectoryCallback& callback,
307 base::PlatformFileError error) { 307 base::File::Error error) {
308 callback.Run(error, AsyncFileUtil::EntryList(), false /*no more*/); 308 callback.Run(error, AsyncFileUtil::EntryList(), false /*no more*/);
309 } 309 }
310 310
311 void DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile( 311 void DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile(
312 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 312 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
313 base::SequencedTaskRunner* media_task_runner, 313 base::SequencedTaskRunner* media_task_runner,
314 const base::PlatformFileInfo& file_info, 314 const base::File::Info& file_info,
315 const base::FilePath& platform_path) { 315 const base::FilePath& platform_path) {
316 base::PostTaskAndReplyWithResult( 316 base::PostTaskAndReplyWithResult(
317 media_task_runner, 317 media_task_runner,
318 FROM_HERE, 318 FROM_HERE,
319 base::Bind(&NativeMediaFileUtil::IsMediaFile, platform_path), 319 base::Bind(&NativeMediaFileUtil::IsMediaFile, platform_path),
320 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCheckMedia, 320 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCheckMedia,
321 weak_ptr_factory_.GetWeakPtr(), 321 weak_ptr_factory_.GetWeakPtr(),
322 callback, 322 callback,
323 file_info, 323 file_info,
324 ShareableFileReference::GetOrCreate( 324 ShareableFileReference::GetOrCreate(
325 platform_path, 325 platform_path,
326 ShareableFileReference::DELETE_ON_FINAL_RELEASE, 326 ShareableFileReference::DELETE_ON_FINAL_RELEASE,
327 media_task_runner))); 327 media_task_runner)));
328 } 328 }
329 329
330 void DeviceMediaAsyncFileUtil::OnDidCheckMedia( 330 void DeviceMediaAsyncFileUtil::OnDidCheckMedia(
331 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 331 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
332 const base::PlatformFileInfo& file_info, 332 const base::File::Info& file_info,
333 scoped_refptr<webkit_blob::ShareableFileReference> platform_file, 333 scoped_refptr<webkit_blob::ShareableFileReference> platform_file,
334 base::PlatformFileError error) { 334 base::File::Error error) {
335 base::FilePath platform_path(platform_file.get()->path()); 335 base::FilePath platform_path(platform_file.get()->path());
336 if (error != base::PLATFORM_FILE_OK) 336 if (error != base::File::FILE_OK)
337 platform_file = NULL; 337 platform_file = NULL;
338 callback.Run(error, file_info, platform_path, platform_file); 338 callback.Run(error, file_info, platform_path, platform_file);
339 } 339 }
340 340
341 void DeviceMediaAsyncFileUtil::GetHeaderBytesForMIMESniffing( 341 void DeviceMediaAsyncFileUtil::GetHeaderBytesForMIMESniffing(
342 const fileapi::FileSystemURL& url, 342 const fileapi::FileSystemURL& url,
343 base::SequencedTaskRunner* media_task_runner, 343 base::SequencedTaskRunner* media_task_runner,
344 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 344 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
345 base::PlatformFileError error, 345 base::File::Error error,
346 const base::PlatformFileInfo& file_info) { 346 const base::File::Info& file_info) {
347 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 347 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
348 if (!delegate) { 348 if (!delegate) {
349 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND); 349 OnCreateSnapshotFileError(callback, base::File::FILE_ERROR_NOT_FOUND);
350 return; 350 return;
351 } 351 }
352 352
353 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(net::kMaxBytesToSniff)); 353 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(net::kMaxBytesToSniff));
354 delegate->ReadBytes( 354 delegate->ReadBytes(
355 url.path(), 355 url.path(),
356 buffer, 356 buffer,
357 0, 357 0,
358 net::kMaxBytesToSniff, 358 net::kMaxBytesToSniff,
359 base::Bind(&DeviceMediaAsyncFileUtil::FinishStreamingSnapshotFile, 359 base::Bind(&DeviceMediaAsyncFileUtil::FinishStreamingSnapshotFile,
360 weak_ptr_factory_.GetWeakPtr(), url, 360 weak_ptr_factory_.GetWeakPtr(), url,
361 make_scoped_refptr(media_task_runner), callback, file_info, 361 make_scoped_refptr(media_task_runner), callback, file_info,
362 buffer), 362 buffer),
363 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError, 363 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError,
364 weak_ptr_factory_.GetWeakPtr(), callback)); 364 weak_ptr_factory_.GetWeakPtr(), callback));
365 } 365 }
366 366
367 void DeviceMediaAsyncFileUtil::FinishStreamingSnapshotFile( 367 void DeviceMediaAsyncFileUtil::FinishStreamingSnapshotFile(
368 const fileapi::FileSystemURL& url, 368 const fileapi::FileSystemURL& url,
369 base::SequencedTaskRunner* media_task_runner, 369 base::SequencedTaskRunner* media_task_runner,
370 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 370 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
371 const base::PlatformFileInfo& file_info, 371 const base::File::Info& file_info,
372 net::IOBuffer* buffer, 372 net::IOBuffer* buffer,
373 int buffer_size) { 373 int buffer_size) {
374 base::PlatformFileError error = 374 base::File::Error error =
375 NativeMediaFileUtil::BufferIsMediaHeader(buffer, buffer_size); 375 NativeMediaFileUtil::BufferIsMediaHeader(buffer, buffer_size);
376 if (error != base::PLATFORM_FILE_OK) { 376 if (error != base::File::FILE_OK) {
377 OnCreateSnapshotFileError(callback, error); 377 OnCreateSnapshotFileError(callback, error);
378 return; 378 return;
379 } 379 }
380 callback.Run(base::PLATFORM_FILE_OK, file_info, base::FilePath(), 380 callback.Run(base::File::FILE_OK, file_info, base::FilePath(),
381 scoped_refptr<ShareableFileReference>()); 381 scoped_refptr<ShareableFileReference>());
382 } 382 }
383 383
384 void DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError( 384 void DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError(
385 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 385 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
386 base::PlatformFileError error) { 386 base::File::Error error) {
387 callback.Run(error, base::PlatformFileInfo(), base::FilePath(), 387 callback.Run(error, base::File::Info(), base::FilePath(),
388 scoped_refptr<ShareableFileReference>()); 388 scoped_refptr<ShareableFileReference>());
389 } 389 }
390 390
391 void DeviceMediaAsyncFileUtil::OnSnapshotFileCreatedRunTask( 391 void DeviceMediaAsyncFileUtil::OnSnapshotFileCreatedRunTask(
392 scoped_ptr<FileSystemOperationContext> context, 392 scoped_ptr<FileSystemOperationContext> context,
393 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 393 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
394 const FileSystemURL& url, 394 const FileSystemURL& url,
395 base::FilePath* snapshot_file_path) { 395 base::FilePath* snapshot_file_path) {
396 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 396 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
397 if (!snapshot_file_path || snapshot_file_path->empty()) { 397 if (!snapshot_file_path || snapshot_file_path->empty()) {
398 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_FAILED); 398 OnCreateSnapshotFileError(callback, base::File::FILE_ERROR_FAILED);
399 return; 399 return;
400 } 400 }
401 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 401 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
402 if (!delegate) { 402 if (!delegate) {
403 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND); 403 OnCreateSnapshotFileError(callback, base::File::FILE_ERROR_NOT_FOUND);
404 return; 404 return;
405 } 405 }
406 delegate->CreateSnapshotFile( 406 delegate->CreateSnapshotFile(
407 url.path(), // device file path 407 url.path(), // device file path
408 *snapshot_file_path, 408 *snapshot_file_path,
409 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile, 409 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile,
410 weak_ptr_factory_.GetWeakPtr(), 410 weak_ptr_factory_.GetWeakPtr(),
411 callback, 411 callback,
412 make_scoped_refptr(context->task_runner())), 412 make_scoped_refptr(context->task_runner())),
413 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError, 413 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError,
414 weak_ptr_factory_.GetWeakPtr(), 414 weak_ptr_factory_.GetWeakPtr(),
415 callback)); 415 callback));
416 } 416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698