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

Side by Side Diff: webkit/browser/fileapi/file_system_operation_runner.cc

Issue 23135019: Make SyncableFileSystemOperation not inherit from FileSystemOperationImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
« no previous file with comments | « webkit/browser/fileapi/file_system_operation_runner.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "webkit/browser/fileapi/file_system_operation_runner.h" 5 #include "webkit/browser/fileapi/file_system_operation_runner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "net/url_request/url_request_context.h" 8 #include "net/url_request/url_request_context.h"
9 #include "webkit/browser/fileapi/file_observers.h" 9 #include "webkit/browser/fileapi/file_observers.h"
10 #include "webkit/browser/fileapi/file_stream_writer.h" 10 #include "webkit/browser/fileapi/file_stream_writer.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 base::Bind(&FileSystemOperationRunner::DidCreateSnapshot, AsWeakPtr(), 341 base::Bind(&FileSystemOperationRunner::DidCreateSnapshot, AsWeakPtr(),
342 id, callback)); 342 id, callback));
343 return id; 343 return id;
344 } 344 }
345 345
346 OperationID FileSystemOperationRunner::CopyInForeignFile( 346 OperationID FileSystemOperationRunner::CopyInForeignFile(
347 const base::FilePath& src_local_disk_path, 347 const base::FilePath& src_local_disk_path,
348 const FileSystemURL& dest_url, 348 const FileSystemURL& dest_url,
349 const StatusCallback& callback) { 349 const StatusCallback& callback) {
350 base::PlatformFileError error = base::PLATFORM_FILE_OK; 350 base::PlatformFileError error = base::PLATFORM_FILE_OK;
351 FileSystemOperation* operation = CreateFileSystemOperationImpl( 351 FileSystemOperation* operation =
352 dest_url, &error); 352 file_system_context_->CreateFileSystemOperation(dest_url, &error);
353 if (!operation) { 353 if (!operation) {
354 callback.Run(error); 354 callback.Run(error);
355 return kErrorOperationID; 355 return kErrorOperationID;
356 } 356 }
357 OperationID id = operations_.Add(operation); 357 OperationID id = operations_.Add(operation);
358 operation->AsFileSystemOperationImpl()->CopyInForeignFile( 358 operation->CopyInForeignFile(
359 src_local_disk_path, dest_url, 359 src_local_disk_path, dest_url,
360 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 360 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
361 id, callback)); 361 id, callback));
362 return id; 362 return id;
363 } 363 }
364 364
365 OperationID FileSystemOperationRunner::RemoveFile( 365 OperationID FileSystemOperationRunner::RemoveFile(
366 const FileSystemURL& url, 366 const FileSystemURL& url,
367 const StatusCallback& callback) { 367 const StatusCallback& callback) {
368 base::PlatformFileError error = base::PLATFORM_FILE_OK; 368 base::PlatformFileError error = base::PLATFORM_FILE_OK;
369 FileSystemOperation* operation = CreateFileSystemOperationImpl(url, &error); 369 FileSystemOperation* operation =
370 file_system_context_->CreateFileSystemOperation(url, &error);
370 if (!operation) { 371 if (!operation) {
371 callback.Run(error); 372 callback.Run(error);
372 return kErrorOperationID; 373 return kErrorOperationID;
373 } 374 }
374 OperationID id = operations_.Add(operation); 375 OperationID id = operations_.Add(operation);
375 operation->AsFileSystemOperationImpl()->RemoveFile( 376 operation->RemoveFile(
376 url, 377 url,
377 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 378 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
378 id, callback)); 379 id, callback));
379 return id; 380 return id;
380 } 381 }
381 382
382 OperationID FileSystemOperationRunner::RemoveDirectory( 383 OperationID FileSystemOperationRunner::RemoveDirectory(
383 const FileSystemURL& url, 384 const FileSystemURL& url,
384 const StatusCallback& callback) { 385 const StatusCallback& callback) {
385 base::PlatformFileError error = base::PLATFORM_FILE_OK; 386 base::PlatformFileError error = base::PLATFORM_FILE_OK;
386 FileSystemOperation* operation = CreateFileSystemOperationImpl(url, &error); 387 FileSystemOperation* operation =
388 file_system_context_->CreateFileSystemOperation(url, &error);
387 if (!operation) { 389 if (!operation) {
388 callback.Run(error); 390 callback.Run(error);
389 return kErrorOperationID; 391 return kErrorOperationID;
390 } 392 }
391 OperationID id = operations_.Add(operation); 393 OperationID id = operations_.Add(operation);
392 operation->AsFileSystemOperationImpl()->RemoveDirectory( 394 operation->RemoveDirectory(
393 url, 395 url,
394 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 396 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
395 id, callback)); 397 id, callback));
396 return id; 398 return id;
397 } 399 }
398 400
399 OperationID FileSystemOperationRunner::CopyFileLocal( 401 OperationID FileSystemOperationRunner::CopyFileLocal(
400 const FileSystemURL& src_url, 402 const FileSystemURL& src_url,
401 const FileSystemURL& dest_url, 403 const FileSystemURL& dest_url,
402 const StatusCallback& callback) { 404 const StatusCallback& callback) {
403 base::PlatformFileError error = base::PLATFORM_FILE_OK; 405 base::PlatformFileError error = base::PLATFORM_FILE_OK;
404 FileSystemOperation* operation = CreateFileSystemOperationImpl( 406 FileSystemOperation* operation =
405 src_url, &error); 407 file_system_context_->CreateFileSystemOperation(src_url, &error);
406 if (!operation) { 408 if (!operation) {
407 callback.Run(error); 409 callback.Run(error);
408 return kErrorOperationID; 410 return kErrorOperationID;
409 } 411 }
410 OperationID id = operations_.Add(operation); 412 OperationID id = operations_.Add(operation);
411 operation->AsFileSystemOperationImpl()->CopyFileLocal( 413 operation->CopyFileLocal(
412 src_url, dest_url, 414 src_url, dest_url,
413 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 415 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
414 id, callback)); 416 id, callback));
415 return id; 417 return id;
416 } 418 }
417 419
418 OperationID FileSystemOperationRunner::MoveFileLocal( 420 OperationID FileSystemOperationRunner::MoveFileLocal(
419 const FileSystemURL& src_url, 421 const FileSystemURL& src_url,
420 const FileSystemURL& dest_url, 422 const FileSystemURL& dest_url,
421 const StatusCallback& callback) { 423 const StatusCallback& callback) {
422 base::PlatformFileError error = base::PLATFORM_FILE_OK; 424 base::PlatformFileError error = base::PLATFORM_FILE_OK;
423 FileSystemOperation* operation = CreateFileSystemOperationImpl( 425 FileSystemOperation* operation =
424 src_url, &error); 426 file_system_context_->CreateFileSystemOperation(src_url, &error);
425 if (!operation) { 427 if (!operation) {
426 callback.Run(error); 428 callback.Run(error);
427 return kErrorOperationID; 429 return kErrorOperationID;
428 } 430 }
429 OperationID id = operations_.Add(operation); 431 OperationID id = operations_.Add(operation);
430 operation->AsFileSystemOperationImpl()->MoveFileLocal( 432 operation->MoveFileLocal(
431 src_url, dest_url, 433 src_url, dest_url,
432 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 434 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
433 id, callback)); 435 id, callback));
434 return id; 436 return id;
435 } 437 }
436 438
437 base::PlatformFileError FileSystemOperationRunner::SyncGetPlatformPath( 439 base::PlatformFileError FileSystemOperationRunner::SyncGetPlatformPath(
438 const FileSystemURL& url, 440 const FileSystemURL& url,
439 base::FilePath* platform_path) { 441 base::FilePath* platform_path) {
440 base::PlatformFileError error = base::PLATFORM_FILE_OK; 442 base::PlatformFileError error = base::PLATFORM_FILE_OK;
441 FileSystemOperation* operation = CreateFileSystemOperationImpl(url, &error); 443 FileSystemOperation* operation =
444 file_system_context_->CreateFileSystemOperation(url, &error);
442 if (!operation) 445 if (!operation)
443 return error; 446 return error;
444 447 return operation->SyncGetPlatformPath(url, platform_path);
445 return operation->AsFileSystemOperationImpl()->SyncGetPlatformPath(
446 url, platform_path);
447 } 448 }
448 449
449 FileSystemOperationRunner::FileSystemOperationRunner( 450 FileSystemOperationRunner::FileSystemOperationRunner(
450 FileSystemContext* file_system_context) 451 FileSystemContext* file_system_context)
451 : file_system_context_(file_system_context) {} 452 : file_system_context_(file_system_context) {}
452 453
453 void FileSystemOperationRunner::DidFinish( 454 void FileSystemOperationRunner::DidFinish(
454 OperationID id, 455 OperationID id,
455 const StatusCallback& callback, 456 const StatusCallback& callback,
456 base::PlatformFileError rv) { 457 base::PlatformFileError rv) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 OperationID id, 505 OperationID id,
505 const SnapshotFileCallback& callback, 506 const SnapshotFileCallback& callback,
506 base::PlatformFileError rv, 507 base::PlatformFileError rv,
507 const base::PlatformFileInfo& file_info, 508 const base::PlatformFileInfo& file_info,
508 const base::FilePath& platform_path, 509 const base::FilePath& platform_path,
509 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { 510 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
510 callback.Run(rv, file_info, platform_path, file_ref); 511 callback.Run(rv, file_info, platform_path, file_ref);
511 FinishOperation(id); 512 FinishOperation(id);
512 } 513 }
513 514
514 FileSystemOperation*
515 FileSystemOperationRunner::CreateFileSystemOperationImpl(
516 const FileSystemURL& url, base::PlatformFileError* error) {
517 FileSystemOperation* operation =
518 file_system_context_->CreateFileSystemOperation(url, error);
519 if (!operation)
520 return NULL;
521 if (!operation->AsFileSystemOperationImpl()) {
522 *error = base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
523 delete operation;
524 return NULL;
525 }
526 return operation;
527 }
528
529 void FileSystemOperationRunner::PrepareForWrite(OperationID id, 515 void FileSystemOperationRunner::PrepareForWrite(OperationID id,
530 const FileSystemURL& url) { 516 const FileSystemURL& url) {
531 if (file_system_context_->GetUpdateObservers(url.type())) { 517 if (file_system_context_->GetUpdateObservers(url.type())) {
532 file_system_context_->GetUpdateObservers(url.type())->Notify( 518 file_system_context_->GetUpdateObservers(url.type())->Notify(
533 &FileUpdateObserver::OnStartUpdate, MakeTuple(url)); 519 &FileUpdateObserver::OnStartUpdate, MakeTuple(url));
534 } 520 }
535 write_target_urls_[id].insert(url); 521 write_target_urls_[id].insert(url);
536 } 522 }
537 523
538 void FileSystemOperationRunner::PrepareForRead(OperationID id, 524 void FileSystemOperationRunner::PrepareForRead(OperationID id,
(...skipping 15 matching lines...) Expand all
554 &FileUpdateObserver::OnEndUpdate, MakeTuple(*iter)); 540 &FileUpdateObserver::OnEndUpdate, MakeTuple(*iter));
555 } 541 }
556 } 542 }
557 write_target_urls_.erase(found); 543 write_target_urls_.erase(found);
558 } 544 }
559 DCHECK(operations_.Lookup(id)); 545 DCHECK(operations_.Lookup(id));
560 operations_.Remove(id); 546 operations_.Remove(id);
561 } 547 }
562 548
563 } // namespace fileapi 549 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/file_system_operation_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698