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

Side by Side Diff: webkit/fileapi/file_system_operation.cc

Issue 8424006: Bind: Merge FileUtilProxy and FileSystemFileUtilProxy: CreateOrOpen/Close (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/fileapi/file_system_operation.h" 5 #include "webkit/fileapi/file_system_operation.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "net/base/escape.h" 10 #include "net/base/escape.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 dispatcher_(dispatcher), 65 dispatcher_(dispatcher),
66 operation_context_(file_system_context, NULL), 66 operation_context_(file_system_context, NULL),
67 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 67 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
68 #ifndef NDEBUG 68 #ifndef NDEBUG
69 pending_operation_ = kOperationNone; 69 pending_operation_ = kOperationNone;
70 #endif 70 #endif
71 } 71 }
72 72
73 FileSystemOperation::~FileSystemOperation() { 73 FileSystemOperation::~FileSystemOperation() {
74 if (file_writer_delegate_.get()) 74 if (file_writer_delegate_.get())
75 FileSystemFileUtilProxy::Close( 75 base::FileUtilProxy::RelayClose(
76 operation_context_, proxy_, file_writer_delegate_->file(), 76 proxy_,
77 base::Bind(&FileSystemFileUtil::Close,
78 base::Unretained(operation_context_.src_file_util()),
79 base::Unretained(&operation_context_)),
tzik 2011/11/01 04:47:46 base::Owned(new FileSystemOperation(operation_cont
kinuko 2011/11/01 06:39:01 Done.
80 file_writer_delegate_->file(),
77 FileSystemFileUtilProxy::StatusCallback()); 81 FileSystemFileUtilProxy::StatusCallback());
78 } 82 }
79 83
80 void FileSystemOperation::OpenFileSystem( 84 void FileSystemOperation::OpenFileSystem(
81 const GURL& origin_url, fileapi::FileSystemType type, bool create) { 85 const GURL& origin_url, fileapi::FileSystemType type, bool create) {
82 #ifndef NDEBUG 86 #ifndef NDEBUG
83 DCHECK(kOperationNone == pending_operation_); 87 DCHECK(kOperationNone == pending_operation_);
84 pending_operation_ = static_cast<FileSystemOperation::OperationType>( 88 pending_operation_ = static_cast<FileSystemOperation::OperationType>(
85 kOperationOpenFileSystem); 89 kOperationOpenFileSystem);
86 #endif 90 #endif
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 352
349 void FileSystemOperation::DelayedWriteForQuota(quota::QuotaStatusCode status, 353 void FileSystemOperation::DelayedWriteForQuota(quota::QuotaStatusCode status,
350 int64 usage, int64 quota) { 354 int64 usage, int64 quota) {
351 operation_context_.set_allowed_bytes_growth(quota - usage); 355 operation_context_.set_allowed_bytes_growth(quota - usage);
352 356
353 quota_util_helper_.reset(new ScopedQuotaUtilHelper( 357 quota_util_helper_.reset(new ScopedQuotaUtilHelper(
354 file_system_context(), 358 file_system_context(),
355 operation_context_.src_origin_url(), 359 operation_context_.src_origin_url(),
356 operation_context_.src_type())); 360 operation_context_.src_type()));
357 361
358 FileSystemFileUtilProxy::CreateOrOpen( 362 int file_flags = base::PLATFORM_FILE_OPEN |
359 operation_context_, 363 base::PLATFORM_FILE_WRITE |
364 base::PLATFORM_FILE_ASYNC;
365
366 base::FileUtilProxy::RelayCreateOrOpen(
360 proxy_, 367 proxy_,
361 src_virtual_path_, 368 base::Bind(&FileSystemFileUtil::CreateOrOpen,
362 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE | 369 base::Unretained(operation_context_.src_file_util()),
363 base::PLATFORM_FILE_ASYNC, 370 base::Unretained(&operation_context_),
371 src_virtual_path_,
372 file_flags),
373 base::Bind(&FileSystemFileUtil::Close,
374 base::Unretained(operation_context_.src_file_util()),
375 base::Unretained(&operation_context_)),
364 base::Bind(&FileSystemOperation::OnFileOpenedForWrite, 376 base::Bind(&FileSystemOperation::OnFileOpenedForWrite,
365 weak_factory_.GetWeakPtr())); 377 weak_factory_.GetWeakPtr()));
kinuko 2011/11/01 06:39:01 Most of them can also be replaced with Owned() and
366 } 378 }
367 379
368 void FileSystemOperation::Truncate(const GURL& path, int64 length) { 380 void FileSystemOperation::Truncate(const GURL& path, int64 length) {
369 #ifndef NDEBUG 381 #ifndef NDEBUG
370 DCHECK(kOperationNone == pending_operation_); 382 DCHECK(kOperationNone == pending_operation_);
371 pending_operation_ = kOperationTruncate; 383 pending_operation_ = kOperationTruncate;
372 #endif 384 #endif
373 if (!SetupSrcContextForWrite(path, false)) { 385 if (!SetupSrcContextForWrite(path, false)) {
374 delete this; 386 delete this;
375 return; 387 return;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 469
458 void FileSystemOperation::DelayedOpenFileForQuota(quota::QuotaStatusCode status, 470 void FileSystemOperation::DelayedOpenFileForQuota(quota::QuotaStatusCode status,
459 int64 usage, int64 quota) { 471 int64 usage, int64 quota) {
460 operation_context_.set_allowed_bytes_growth(quota - usage); 472 operation_context_.set_allowed_bytes_growth(quota - usage);
461 473
462 quota_util_helper_.reset(new ScopedQuotaUtilHelper( 474 quota_util_helper_.reset(new ScopedQuotaUtilHelper(
463 file_system_context(), 475 file_system_context(),
464 operation_context_.src_origin_url(), 476 operation_context_.src_origin_url(),
465 operation_context_.src_type())); 477 operation_context_.src_type()));
466 478
467 FileSystemFileUtilProxy::CreateOrOpen( 479 base::FileUtilProxy::RelayCreateOrOpen(
468 operation_context_, proxy_, src_virtual_path_, file_flags_, 480 proxy_,
481 base::Bind(&FileSystemFileUtil::CreateOrOpen,
482 base::Unretained(operation_context_.src_file_util()),
483 base::Unretained(&operation_context_),
484 src_virtual_path_,
485 file_flags_),
486 base::Bind(&FileSystemFileUtil::Close,
487 base::Unretained(operation_context_.src_file_util()),
488 base::Unretained(&operation_context_)),
469 base::Bind(&FileSystemOperation::DidOpenFile, 489 base::Bind(&FileSystemOperation::DidOpenFile,
470 weak_factory_.GetWeakPtr())); 490 weak_factory_.GetWeakPtr()));
471 } 491 }
472 492
473 void FileSystemOperation::SyncGetPlatformPath(const GURL& path, 493 void FileSystemOperation::SyncGetPlatformPath(const GURL& path,
474 FilePath* platform_path) { 494 FilePath* platform_path) {
475 #ifndef NDEBUG 495 #ifndef NDEBUG
476 DCHECK(kOperationNone == pending_operation_); 496 DCHECK(kOperationNone == pending_operation_);
477 pending_operation_ = kOperationGetLocalPath; 497 pending_operation_ = kOperationGetLocalPath;
478 #endif 498 #endif
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 bool result = VerifyFileSystemPathForWrite( 847 bool result = VerifyFileSystemPathForWrite(
828 path, create, &origin_url, &type, &dest_virtual_path_, &file_util); 848 path, create, &origin_url, &type, &dest_virtual_path_, &file_util);
829 operation_context_.set_dest_origin_url(origin_url); 849 operation_context_.set_dest_origin_url(origin_url);
830 operation_context_.set_dest_type(type); 850 operation_context_.set_dest_type(type);
831 if (!operation_context_.dest_file_util()) 851 if (!operation_context_.dest_file_util())
832 operation_context_.set_dest_file_util(file_util); 852 operation_context_.set_dest_file_util(file_util);
833 return result; 853 return result;
834 } 854 }
835 855
836 } // namespace fileapi 856 } // namespace fileapi
OLDNEW
« base/file_util_proxy.cc ('K') | « webkit/fileapi/file_system_file_util_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698