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

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

Issue 8466003: 2nd try: 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
« no previous file with comments | « webkit/fileapi/file_system_file_util_proxy.cc ('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 (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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 : proxy_(proxy), 64 : proxy_(proxy),
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 FileSystemOperationContext* c =
76 operation_context_, proxy_, file_writer_delegate_->file(), 76 new FileSystemOperationContext(operation_context_);
77 base::FileUtilProxy::RelayClose(
78 proxy_,
79 base::Bind(&FileSystemFileUtil::Close,
80 base::Unretained(c->src_file_util()),
81 base::Owned(c)),
82 file_writer_delegate_->file(),
77 FileSystemFileUtilProxy::StatusCallback()); 83 FileSystemFileUtilProxy::StatusCallback());
84 }
78 } 85 }
79 86
80 void FileSystemOperation::OpenFileSystem( 87 void FileSystemOperation::OpenFileSystem(
81 const GURL& origin_url, fileapi::FileSystemType type, bool create) { 88 const GURL& origin_url, fileapi::FileSystemType type, bool create) {
82 #ifndef NDEBUG 89 #ifndef NDEBUG
83 DCHECK(dispatcher_.get()); 90 DCHECK(dispatcher_.get());
84 DCHECK(kOperationNone == pending_operation_); 91 DCHECK(kOperationNone == pending_operation_);
85 pending_operation_ = static_cast<FileSystemOperation::OperationType>( 92 pending_operation_ = static_cast<FileSystemOperation::OperationType>(
86 kOperationOpenFileSystem); 93 kOperationOpenFileSystem);
87 #endif 94 #endif
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 366
360 void FileSystemOperation::DelayedWriteForQuota(quota::QuotaStatusCode status, 367 void FileSystemOperation::DelayedWriteForQuota(quota::QuotaStatusCode status,
361 int64 usage, int64 quota) { 368 int64 usage, int64 quota) {
362 operation_context_.set_allowed_bytes_growth(quota - usage); 369 operation_context_.set_allowed_bytes_growth(quota - usage);
363 370
364 quota_util_helper_.reset(new ScopedQuotaUtilHelper( 371 quota_util_helper_.reset(new ScopedQuotaUtilHelper(
365 file_system_context(), 372 file_system_context(),
366 operation_context_.src_origin_url(), 373 operation_context_.src_origin_url(),
367 operation_context_.src_type())); 374 operation_context_.src_type()));
368 375
369 FileSystemFileUtilProxy::CreateOrOpen( 376 int file_flags = base::PLATFORM_FILE_OPEN |
370 operation_context_, 377 base::PLATFORM_FILE_WRITE |
378 base::PLATFORM_FILE_ASYNC;
379
380 base::FileUtilProxy::RelayCreateOrOpen(
371 proxy_, 381 proxy_,
372 src_virtual_path_, 382 base::Bind(&FileSystemFileUtil::CreateOrOpen,
373 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE | 383 base::Unretained(operation_context_.src_file_util()),
374 base::PLATFORM_FILE_ASYNC, 384 base::Unretained(&operation_context_),
385 src_virtual_path_, file_flags),
386 base::Bind(&FileSystemFileUtil::Close,
387 base::Unretained(operation_context_.src_file_util()),
388 base::Unretained(&operation_context_)),
375 base::Bind(&FileSystemOperation::OnFileOpenedForWrite, 389 base::Bind(&FileSystemOperation::OnFileOpenedForWrite,
376 weak_factory_.GetWeakPtr())); 390 weak_factory_.GetWeakPtr()));
377 } 391 }
378 392
379 void FileSystemOperation::Truncate(const GURL& path, int64 length) { 393 void FileSystemOperation::Truncate(const GURL& path, int64 length) {
380 #ifndef NDEBUG 394 #ifndef NDEBUG
381 DCHECK(dispatcher_.get()); 395 DCHECK(dispatcher_.get());
382 DCHECK(kOperationNone == pending_operation_); 396 DCHECK(kOperationNone == pending_operation_);
383 pending_operation_ = kOperationTruncate; 397 pending_operation_ = kOperationTruncate;
384 #endif 398 #endif
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 485
472 void FileSystemOperation::DelayedOpenFileForQuota(quota::QuotaStatusCode status, 486 void FileSystemOperation::DelayedOpenFileForQuota(quota::QuotaStatusCode status,
473 int64 usage, int64 quota) { 487 int64 usage, int64 quota) {
474 operation_context_.set_allowed_bytes_growth(quota - usage); 488 operation_context_.set_allowed_bytes_growth(quota - usage);
475 489
476 quota_util_helper_.reset(new ScopedQuotaUtilHelper( 490 quota_util_helper_.reset(new ScopedQuotaUtilHelper(
477 file_system_context(), 491 file_system_context(),
478 operation_context_.src_origin_url(), 492 operation_context_.src_origin_url(),
479 operation_context_.src_type())); 493 operation_context_.src_type()));
480 494
481 FileSystemFileUtilProxy::CreateOrOpen( 495 base::FileUtilProxy::RelayCreateOrOpen(
482 operation_context_, proxy_, src_virtual_path_, file_flags_, 496 proxy_,
497 base::Bind(&FileSystemFileUtil::CreateOrOpen,
498 base::Unretained(operation_context_.src_file_util()),
499 base::Unretained(&operation_context_),
500 src_virtual_path_, file_flags_),
501 base::Bind(&FileSystemFileUtil::Close,
502 base::Unretained(operation_context_.src_file_util()),
503 base::Unretained(&operation_context_)),
483 base::Bind(&FileSystemOperation::DidOpenFile, 504 base::Bind(&FileSystemOperation::DidOpenFile,
484 weak_factory_.GetWeakPtr())); 505 weak_factory_.GetWeakPtr()));
485 } 506 }
486 507
487 void FileSystemOperation::SyncGetPlatformPath(const GURL& path, 508 void FileSystemOperation::SyncGetPlatformPath(const GURL& path,
488 FilePath* platform_path) { 509 FilePath* platform_path) {
489 #ifndef NDEBUG 510 #ifndef NDEBUG
490 DCHECK(kOperationNone == pending_operation_); 511 DCHECK(kOperationNone == pending_operation_);
491 pending_operation_ = kOperationGetLocalPath; 512 pending_operation_ = kOperationGetLocalPath;
492 #endif 513 #endif
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 bool result = VerifyFileSystemPathForWrite( 862 bool result = VerifyFileSystemPathForWrite(
842 path, create, &origin_url, &type, &dest_virtual_path_, &file_util); 863 path, create, &origin_url, &type, &dest_virtual_path_, &file_util);
843 operation_context_.set_dest_origin_url(origin_url); 864 operation_context_.set_dest_origin_url(origin_url);
844 operation_context_.set_dest_type(type); 865 operation_context_.set_dest_type(type);
845 if (!operation_context_.dest_file_util()) 866 if (!operation_context_.dest_file_util())
846 operation_context_.set_dest_file_util(file_util); 867 operation_context_.set_dest_file_util(file_util);
847 return result; 868 return result;
848 } 869 }
849 870
850 } // namespace fileapi 871 } // namespace fileapi
OLDNEW
« no previous file with comments | « 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