| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 scoped_ptr<FileSystemCallbackDispatcher> dispatcher, | |
| 62 scoped_refptr<base::MessageLoopProxy> proxy, | |
| 63 FileSystemContext* file_system_context) | |
| 64 : proxy_(proxy), | |
| 65 dispatcher_(dispatcher.Pass()), | |
| 66 operation_context_(file_system_context, NULL), | |
| 67 peer_handle_(base::kNullProcessHandle) { | |
| 68 #ifndef NDEBUG | |
| 69 pending_operation_ = kOperationNone; | |
| 70 #endif | |
| 71 } | |
| 72 | |
| 73 FileSystemOperation::~FileSystemOperation() { | 60 FileSystemOperation::~FileSystemOperation() { |
| 74 if (file_writer_delegate_.get()) { | 61 if (file_writer_delegate_.get()) { |
| 75 FileSystemOperationContext* c = | 62 FileSystemOperationContext* c = |
| 76 new FileSystemOperationContext(operation_context_); | 63 new FileSystemOperationContext(operation_context_); |
| 77 base::FileUtilProxy::RelayClose( | 64 base::FileUtilProxy::RelayClose( |
| 78 proxy_, | 65 proxy_, |
| 79 base::Bind(&FileSystemFileUtil::Close, | 66 base::Bind(&FileSystemFileUtil::Close, |
| 80 base::Unretained(c->src_file_util()), | 67 base::Unretained(c->src_file_util()), |
| 81 base::Owned(c)), | 68 base::Owned(c)), |
| 82 file_writer_delegate_->file(), | 69 file_writer_delegate_->file(), |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 #endif | 501 #endif |
| 515 // We're cancelling a truncate operation, but we can't actually stop it | 502 // We're cancelling a truncate operation, but we can't actually stop it |
| 516 // since it's been proxied to another thread. We need to save the | 503 // since it's been proxied to another thread. We need to save the |
| 517 // cancel_dispatcher so that when the truncate returns, it can see that it's | 504 // cancel_dispatcher so that when the truncate returns, it can see that it's |
| 518 // been cancelled, report it, and report that the cancel has succeeded. | 505 // been cancelled, report it, and report that the cancel has succeeded. |
| 519 DCHECK(!cancel_dispatcher_.get()); | 506 DCHECK(!cancel_dispatcher_.get()); |
| 520 cancel_dispatcher_ = cancel_dispatcher.Pass(); | 507 cancel_dispatcher_ = cancel_dispatcher.Pass(); |
| 521 } | 508 } |
| 522 } | 509 } |
| 523 | 510 |
| 511 FileSystemOperation* FileSystemOperation::AsFileSystemOperation() { |
| 512 return this; |
| 513 } |
| 514 |
| 524 void FileSystemOperation::SyncGetPlatformPath(const GURL& path, | 515 void FileSystemOperation::SyncGetPlatformPath(const GURL& path, |
| 525 FilePath* platform_path) { | 516 FilePath* platform_path) { |
| 526 #ifndef NDEBUG | 517 #ifndef NDEBUG |
| 527 DCHECK(kOperationNone == pending_operation_); | 518 DCHECK(kOperationNone == pending_operation_); |
| 528 pending_operation_ = kOperationGetLocalPath; | 519 pending_operation_ = kOperationGetLocalPath; |
| 529 #endif | 520 #endif |
| 530 if (!SetupSrcContextForRead(path)) { | 521 if (!SetupSrcContextForRead(path)) { |
| 531 delete this; | 522 delete this; |
| 532 return; | 523 return; |
| 533 } | 524 } |
| 534 | 525 |
| 535 operation_context_.src_file_util()->GetLocalFilePath( | 526 operation_context_.src_file_util()->GetLocalFilePath( |
| 536 &operation_context_, src_virtual_path_, platform_path); | 527 &operation_context_, src_virtual_path_, platform_path); |
| 537 | 528 |
| 538 delete this; | 529 delete this; |
| 539 } | 530 } |
| 540 | 531 |
| 532 FileSystemOperation::FileSystemOperation( |
| 533 scoped_ptr<FileSystemCallbackDispatcher> dispatcher, |
| 534 scoped_refptr<base::MessageLoopProxy> proxy, |
| 535 FileSystemContext* file_system_context) |
| 536 : proxy_(proxy), |
| 537 dispatcher_(dispatcher.Pass()), |
| 538 operation_context_(file_system_context, NULL), |
| 539 peer_handle_(base::kNullProcessHandle) { |
| 540 #ifndef NDEBUG |
| 541 pending_operation_ = kOperationNone; |
| 542 #endif |
| 543 } |
| 544 |
| 541 void FileSystemOperation::GetUsageAndQuotaThenCallback( | 545 void FileSystemOperation::GetUsageAndQuotaThenCallback( |
| 542 const GURL& origin_url, | 546 const GURL& origin_url, |
| 543 const quota::QuotaManager::GetUsageAndQuotaCallback& callback) { | 547 const quota::QuotaManager::GetUsageAndQuotaCallback& callback) { |
| 544 quota::QuotaManagerProxy* quota_manager_proxy = | 548 quota::QuotaManagerProxy* quota_manager_proxy = |
| 545 file_system_context()->quota_manager_proxy(); | 549 file_system_context()->quota_manager_proxy(); |
| 546 if (!quota_manager_proxy || | 550 if (!quota_manager_proxy || |
| 547 !file_system_context()->GetQuotaUtil( | 551 !file_system_context()->GetQuotaUtil( |
| 548 operation_context_.src_type())) { | 552 operation_context_.src_type())) { |
| 549 // If we don't have the quota manager or the requested filesystem type | 553 // If we don't have the quota manager or the requested filesystem type |
| 550 // does not support quota, we should be able to let it go. | 554 // does not support quota, we should be able to let it go. |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 bool result = VerifyFileSystemPathForWrite( | 804 bool result = VerifyFileSystemPathForWrite( |
| 801 path, create, &origin_url, &type, &dest_virtual_path_, &file_util); | 805 path, create, &origin_url, &type, &dest_virtual_path_, &file_util); |
| 802 operation_context_.set_dest_origin_url(origin_url); | 806 operation_context_.set_dest_origin_url(origin_url); |
| 803 operation_context_.set_dest_type(type); | 807 operation_context_.set_dest_type(type); |
| 804 if (!operation_context_.dest_file_util()) | 808 if (!operation_context_.dest_file_util()) |
| 805 operation_context_.set_dest_file_util(file_util); | 809 operation_context_.set_dest_file_util(file_util); |
| 806 return result; | 810 return result; |
| 807 } | 811 } |
| 808 | 812 |
| 809 } // namespace fileapi | 813 } // namespace fileapi |
| OLD | NEW |