Chromium Code Reviews| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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()); |
|
willchan no longer on Chromium
2011/11/01 22:57:37
What's the long-term vision? Is FileSystemFileUtil
kinuko
2011/11/02 05:48:22
Yes, I'm going to deprecate this one (in the next
| |
| 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(kOperationNone == pending_operation_); | 90 DCHECK(kOperationNone == pending_operation_); |
| 84 pending_operation_ = static_cast<FileSystemOperation::OperationType>( | 91 pending_operation_ = static_cast<FileSystemOperation::OperationType>( |
| 85 kOperationOpenFileSystem); | 92 kOperationOpenFileSystem); |
| 86 #endif | 93 #endif |
| 87 | 94 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 | 355 |
| 349 void FileSystemOperation::DelayedWriteForQuota(quota::QuotaStatusCode status, | 356 void FileSystemOperation::DelayedWriteForQuota(quota::QuotaStatusCode status, |
| 350 int64 usage, int64 quota) { | 357 int64 usage, int64 quota) { |
| 351 operation_context_.set_allowed_bytes_growth(quota - usage); | 358 operation_context_.set_allowed_bytes_growth(quota - usage); |
| 352 | 359 |
| 353 quota_util_helper_.reset(new ScopedQuotaUtilHelper( | 360 quota_util_helper_.reset(new ScopedQuotaUtilHelper( |
| 354 file_system_context(), | 361 file_system_context(), |
| 355 operation_context_.src_origin_url(), | 362 operation_context_.src_origin_url(), |
| 356 operation_context_.src_type())); | 363 operation_context_.src_type())); |
| 357 | 364 |
| 358 FileSystemFileUtilProxy::CreateOrOpen( | 365 int file_flags = base::PLATFORM_FILE_OPEN | |
| 359 operation_context_, | 366 base::PLATFORM_FILE_WRITE | |
| 367 base::PLATFORM_FILE_ASYNC; | |
| 368 | |
| 369 base::FileUtilProxy::RelayCreateOrOpen( | |
| 360 proxy_, | 370 proxy_, |
| 361 src_virtual_path_, | 371 base::Bind(&FileSystemFileUtil::CreateOrOpen, |
| 362 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE | | 372 base::Unretained(operation_context_.src_file_util()), |
| 363 base::PLATFORM_FILE_ASYNC, | 373 base::Unretained(&operation_context_), |
| 374 src_virtual_path_, file_flags), | |
| 375 base::Bind(&FileSystemFileUtil::Close, | |
| 376 base::Unretained(operation_context_.src_file_util()), | |
| 377 base::Unretained(&operation_context_)), | |
| 364 base::Bind(&FileSystemOperation::OnFileOpenedForWrite, | 378 base::Bind(&FileSystemOperation::OnFileOpenedForWrite, |
| 365 weak_factory_.GetWeakPtr())); | 379 weak_factory_.GetWeakPtr())); |
| 366 } | 380 } |
| 367 | 381 |
| 368 void FileSystemOperation::Truncate(const GURL& path, int64 length) { | 382 void FileSystemOperation::Truncate(const GURL& path, int64 length) { |
| 369 #ifndef NDEBUG | 383 #ifndef NDEBUG |
| 370 DCHECK(kOperationNone == pending_operation_); | 384 DCHECK(kOperationNone == pending_operation_); |
| 371 pending_operation_ = kOperationTruncate; | 385 pending_operation_ = kOperationTruncate; |
| 372 #endif | 386 #endif |
| 373 if (!SetupSrcContextForWrite(path, false)) { | 387 if (!SetupSrcContextForWrite(path, false)) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 | 471 |
| 458 void FileSystemOperation::DelayedOpenFileForQuota(quota::QuotaStatusCode status, | 472 void FileSystemOperation::DelayedOpenFileForQuota(quota::QuotaStatusCode status, |
| 459 int64 usage, int64 quota) { | 473 int64 usage, int64 quota) { |
| 460 operation_context_.set_allowed_bytes_growth(quota - usage); | 474 operation_context_.set_allowed_bytes_growth(quota - usage); |
| 461 | 475 |
| 462 quota_util_helper_.reset(new ScopedQuotaUtilHelper( | 476 quota_util_helper_.reset(new ScopedQuotaUtilHelper( |
| 463 file_system_context(), | 477 file_system_context(), |
| 464 operation_context_.src_origin_url(), | 478 operation_context_.src_origin_url(), |
| 465 operation_context_.src_type())); | 479 operation_context_.src_type())); |
| 466 | 480 |
| 467 FileSystemFileUtilProxy::CreateOrOpen( | 481 base::FileUtilProxy::RelayCreateOrOpen( |
| 468 operation_context_, proxy_, src_virtual_path_, file_flags_, | 482 proxy_, |
| 483 base::Bind(&FileSystemFileUtil::CreateOrOpen, | |
| 484 base::Unretained(operation_context_.src_file_util()), | |
| 485 base::Unretained(&operation_context_), | |
| 486 src_virtual_path_, file_flags_), | |
| 487 base::Bind(&FileSystemFileUtil::Close, | |
| 488 base::Unretained(operation_context_.src_file_util()), | |
| 489 base::Unretained(&operation_context_)), | |
| 469 base::Bind(&FileSystemOperation::DidOpenFile, | 490 base::Bind(&FileSystemOperation::DidOpenFile, |
| 470 weak_factory_.GetWeakPtr())); | 491 weak_factory_.GetWeakPtr())); |
| 471 } | 492 } |
| 472 | 493 |
| 473 void FileSystemOperation::SyncGetPlatformPath(const GURL& path, | 494 void FileSystemOperation::SyncGetPlatformPath(const GURL& path, |
| 474 FilePath* platform_path) { | 495 FilePath* platform_path) { |
| 475 #ifndef NDEBUG | 496 #ifndef NDEBUG |
| 476 DCHECK(kOperationNone == pending_operation_); | 497 DCHECK(kOperationNone == pending_operation_); |
| 477 pending_operation_ = kOperationGetLocalPath; | 498 pending_operation_ = kOperationGetLocalPath; |
| 478 #endif | 499 #endif |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 827 bool result = VerifyFileSystemPathForWrite( | 848 bool result = VerifyFileSystemPathForWrite( |
| 828 path, create, &origin_url, &type, &dest_virtual_path_, &file_util); | 849 path, create, &origin_url, &type, &dest_virtual_path_, &file_util); |
| 829 operation_context_.set_dest_origin_url(origin_url); | 850 operation_context_.set_dest_origin_url(origin_url); |
| 830 operation_context_.set_dest_type(type); | 851 operation_context_.set_dest_type(type); |
| 831 if (!operation_context_.dest_file_util()) | 852 if (!operation_context_.dest_file_util()) |
| 832 operation_context_.set_dest_file_util(file_util); | 853 operation_context_.set_dest_file_util(file_util); |
| 833 return result; | 854 return result; |
| 834 } | 855 } |
| 835 | 856 |
| 836 } // namespace fileapi | 857 } // namespace fileapi |
| OLD | NEW |