| OLD | NEW |
| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 FileSystemOperation::ScopedQuotaUtilHelper::~ScopedQuotaUtilHelper() { | 53 FileSystemOperation::ScopedQuotaUtilHelper::~ScopedQuotaUtilHelper() { |
| 54 if (quota_util_) { | 54 if (quota_util_) { |
| 55 DCHECK(quota_util_->proxy()); | 55 DCHECK(quota_util_->proxy()); |
| 56 quota_util_->proxy()->EndUpdateOrigin(origin_url_, type_); | 56 quota_util_->proxy()->EndUpdateOrigin(origin_url_, type_); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 FileSystemOperation::FileSystemOperation( | |
| 61 FileSystemCallbackDispatcher* dispatcher, | |
| 62 scoped_refptr<base::MessageLoopProxy> proxy, | |
| 63 FileSystemContext* file_system_context) | |
| 64 : proxy_(proxy), | |
| 65 dispatcher_(dispatcher), | |
| 66 operation_context_(file_system_context, NULL) { | |
| 67 #ifndef NDEBUG | |
| 68 pending_operation_ = kOperationNone; | |
| 69 #endif | |
| 70 } | |
| 71 | |
| 72 FileSystemOperation::~FileSystemOperation() { | 60 FileSystemOperation::~FileSystemOperation() { |
| 73 if (file_writer_delegate_.get()) { | 61 if (file_writer_delegate_.get()) { |
| 74 FileSystemOperationContext* c = | 62 FileSystemOperationContext* c = |
| 75 new FileSystemOperationContext(operation_context_); | 63 new FileSystemOperationContext(operation_context_); |
| 76 base::FileUtilProxy::RelayClose( | 64 base::FileUtilProxy::RelayClose( |
| 77 proxy_, | 65 proxy_, |
| 78 base::Bind(&FileSystemFileUtil::Close, | 66 base::Bind(&FileSystemFileUtil::Close, |
| 79 base::Unretained(c->src_file_util()), | 67 base::Unretained(c->src_file_util()), |
| 80 base::Owned(c)), | 68 base::Owned(c)), |
| 81 file_writer_delegate_->file(), | 69 file_writer_delegate_->file(), |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 delete this; | 445 delete this; |
| 458 return; | 446 return; |
| 459 } | 447 } |
| 460 } | 448 } |
| 461 GetUsageAndQuotaThenCallback( | 449 GetUsageAndQuotaThenCallback( |
| 462 operation_context_.src_origin_url(), | 450 operation_context_.src_origin_url(), |
| 463 base::Bind(&FileSystemOperation::DelayedOpenFileForQuota, | 451 base::Bind(&FileSystemOperation::DelayedOpenFileForQuota, |
| 464 base::Unretained(this), file_flags)); | 452 base::Unretained(this), file_flags)); |
| 465 } | 453 } |
| 466 | 454 |
| 455 FileSystemOperation::FileSystemOperation( |
| 456 FileSystemCallbackDispatcher* dispatcher, |
| 457 scoped_refptr<base::MessageLoopProxy> proxy, |
| 458 FileSystemContext* file_system_context) |
| 459 : proxy_(proxy), |
| 460 dispatcher_(dispatcher), |
| 461 operation_context_(file_system_context, NULL) { |
| 462 #ifndef NDEBUG |
| 463 pending_operation_ = kOperationNone; |
| 464 #endif |
| 465 } |
| 466 |
| 467 void FileSystemOperation::DelayedOpenFileForQuota(int file_flags, | 467 void FileSystemOperation::DelayedOpenFileForQuota(int file_flags, |
| 468 quota::QuotaStatusCode status, | 468 quota::QuotaStatusCode status, |
| 469 int64 usage, int64 quota) { | 469 int64 usage, int64 quota) { |
| 470 operation_context_.set_allowed_bytes_growth(quota - usage); | 470 operation_context_.set_allowed_bytes_growth(quota - usage); |
| 471 | 471 |
| 472 quota_util_helper_.reset(new ScopedQuotaUtilHelper( | 472 quota_util_helper_.reset(new ScopedQuotaUtilHelper( |
| 473 file_system_context(), | 473 file_system_context(), |
| 474 operation_context_.src_origin_url(), | 474 operation_context_.src_origin_url(), |
| 475 operation_context_.src_type())); | 475 operation_context_.src_type())); |
| 476 | 476 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 bool result = VerifyFileSystemPathForWrite( | 797 bool result = VerifyFileSystemPathForWrite( |
| 798 path, create, &origin_url, &type, &dest_virtual_path_, &file_util); | 798 path, create, &origin_url, &type, &dest_virtual_path_, &file_util); |
| 799 operation_context_.set_dest_origin_url(origin_url); | 799 operation_context_.set_dest_origin_url(origin_url); |
| 800 operation_context_.set_dest_type(type); | 800 operation_context_.set_dest_type(type); |
| 801 if (!operation_context_.dest_file_util()) | 801 if (!operation_context_.dest_file_util()) |
| 802 operation_context_.set_dest_file_util(file_util); | 802 operation_context_.set_dest_file_util(file_util); |
| 803 return result; | 803 return result; |
| 804 } | 804 } |
| 805 | 805 |
| 806 } // namespace fileapi | 806 } // namespace fileapi |
| OLD | NEW |