Chromium Code Reviews| 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/local_file_system_operation.h" | 5 #include "webkit/fileapi/local_file_system_operation.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 const OpenFileCallback& callback) { | 324 const OpenFileCallback& callback) { |
| 325 DCHECK(SetPendingOperationType(kOperationOpenFile)); | 325 DCHECK(SetPendingOperationType(kOperationOpenFile)); |
| 326 scoped_ptr<LocalFileSystemOperation> deleter(this); | 326 scoped_ptr<LocalFileSystemOperation> deleter(this); |
| 327 | 327 |
| 328 peer_handle_ = peer_handle; | 328 peer_handle_ = peer_handle; |
| 329 | 329 |
| 330 if (file_flags & ( | 330 if (file_flags & ( |
| 331 (base::PLATFORM_FILE_ENUMERATE | base::PLATFORM_FILE_TEMPORARY | | 331 (base::PLATFORM_FILE_ENUMERATE | base::PLATFORM_FILE_TEMPORARY | |
| 332 base::PLATFORM_FILE_HIDDEN))) { | 332 base::PLATFORM_FILE_HIDDEN))) { |
| 333 callback.Run(base::PLATFORM_FILE_ERROR_FAILED, | 333 callback.Run(base::PLATFORM_FILE_ERROR_FAILED, |
| 334 base::PlatformFile(), base::ProcessHandle()); | 334 base::kInvalidPlatformFileValue, |
| 335 base::kNullProcessHandle); | |
| 335 return; | 336 return; |
| 336 } | 337 } |
| 337 if (file_flags & | 338 if (file_flags & |
| 338 (base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_OPEN_ALWAYS | | 339 (base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_OPEN_ALWAYS | |
| 339 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_TRUNCATED | | 340 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_TRUNCATED | |
| 340 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE | | 341 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE | |
| 341 base::PLATFORM_FILE_DELETE_ON_CLOSE | | 342 base::PLATFORM_FILE_DELETE_ON_CLOSE | |
| 342 base::PLATFORM_FILE_WRITE_ATTRIBUTES)) { | 343 base::PLATFORM_FILE_WRITE_ATTRIBUTES)) { |
| 343 base::PlatformFileError result = SetUp(url, OPERATION_MODE_WRITE); | 344 base::PlatformFileError result = SetUp(url, OPERATION_MODE_WRITE); |
| 344 if (result != base::PLATFORM_FILE_OK) { | 345 if (result != base::PLATFORM_FILE_OK) { |
| 345 callback.Run(result, base::PlatformFile(), base::ProcessHandle()); | 346 callback.Run(result, |
| 347 base::kInvalidPlatformFileValue, | |
| 348 base::kNullProcessHandle); | |
| 346 return; | 349 return; |
| 347 } | 350 } |
| 348 } else { | 351 } else { |
| 349 base::PlatformFileError result = SetUp(url, OPERATION_MODE_READ); | 352 base::PlatformFileError result = SetUp(url, OPERATION_MODE_READ); |
| 350 if (result != base::PLATFORM_FILE_OK) { | 353 if (result != base::PLATFORM_FILE_OK) { |
| 351 callback.Run(result, base::PlatformFile(), base::ProcessHandle()); | 354 callback.Run(result, |
| 355 base::kInvalidPlatformFileValue, | |
| 356 base::kNullProcessHandle); | |
| 352 return; | 357 return; |
| 353 } | 358 } |
| 354 } | 359 } |
| 355 GetUsageAndQuotaThenRunTask( | 360 GetUsageAndQuotaThenRunTask( |
| 356 url, | 361 url, |
| 357 base::Bind(&LocalFileSystemOperation::DoOpenFile, | 362 base::Bind(&LocalFileSystemOperation::DoOpenFile, |
| 358 base::Unretained(deleter.release()), | 363 base::Unretained(deleter.release()), |
| 359 url, callback, file_flags), | 364 url, callback, file_flags), |
| 360 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED, | 365 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED, |
| 361 base::kInvalidPlatformFileValue, | 366 base::kInvalidPlatformFileValue, |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 const FileSystemURL& url, | 560 const FileSystemURL& url, |
| 556 const base::Closure& task, | 561 const base::Closure& task, |
| 557 const base::Closure& error_callback) { | 562 const base::Closure& error_callback) { |
| 558 quota::QuotaManagerProxy* quota_manager_proxy = | 563 quota::QuotaManagerProxy* quota_manager_proxy = |
| 559 file_system_context()->quota_manager_proxy(); | 564 file_system_context()->quota_manager_proxy(); |
| 560 if (!quota_manager_proxy || | 565 if (!quota_manager_proxy || |
| 561 !file_system_context()->GetQuotaUtil(url.type())) { | 566 !file_system_context()->GetQuotaUtil(url.type())) { |
| 562 // If we don't have the quota manager or the requested filesystem type | 567 // If we don't have the quota manager or the requested filesystem type |
| 563 // does not support quota, we should be able to let it go. | 568 // does not support quota, we should be able to let it go. |
| 564 operation_context()->set_allowed_bytes_growth(kint64max); | 569 operation_context()->set_allowed_bytes_growth(kint64max); |
| 570 operation_context()->set_quota_limit_type(quota::kQuotaLimitTypeUnlimited); | |
| 565 task.Run(); | 571 task.Run(); |
| 566 return; | 572 return; |
| 567 } | 573 } |
| 568 | 574 |
| 569 DCHECK(quota_manager_proxy); | 575 DCHECK(quota_manager_proxy); |
| 570 DCHECK(quota_manager_proxy->quota_manager()); | 576 DCHECK(quota_manager_proxy->quota_manager()); |
| 577 if (quota_manager_proxy->quota_manager()->IsStorageUnlimited( | |
| 578 url.origin(), | |
| 579 FileSystemTypeToQuotaStorageType(url.type()))) { | |
| 580 operation_context()->set_quota_limit_type(quota::kQuotaLimitTypeUnlimited); | |
| 581 } else { | |
| 582 operation_context()->set_quota_limit_type(quota::kQuotaLimitTypeLimited); | |
| 583 } | |
|
kinuko
2013/04/26 07:00:25
Can we do this in SandboxMountPointProvider::Creat
tzik
2013/04/26 07:17:59
Done.
| |
| 584 | |
| 571 quota_manager_proxy->quota_manager()->GetUsageAndQuota( | 585 quota_manager_proxy->quota_manager()->GetUsageAndQuota( |
| 572 url.origin(), | 586 url.origin(), |
| 573 FileSystemTypeToQuotaStorageType(url.type()), | 587 FileSystemTypeToQuotaStorageType(url.type()), |
| 574 base::Bind(&LocalFileSystemOperation::DidGetUsageAndQuotaAndRunTask, | 588 base::Bind(&LocalFileSystemOperation::DidGetUsageAndQuotaAndRunTask, |
| 575 weak_factory_.GetWeakPtr(), task, error_callback)); | 589 weak_factory_.GetWeakPtr(), task, error_callback)); |
| 576 } | 590 } |
| 577 | 591 |
| 578 void LocalFileSystemOperation::DidGetUsageAndQuotaAndRunTask( | 592 void LocalFileSystemOperation::DidGetUsageAndQuotaAndRunTask( |
| 579 const base::Closure& task, | 593 const base::Closure& task, |
| 580 const base::Closure& error_callback, | 594 const base::Closure& error_callback, |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 } | 883 } |
| 870 | 884 |
| 871 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { | 885 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { |
| 872 if (pending_operation_ != kOperationNone) | 886 if (pending_operation_ != kOperationNone) |
| 873 return false; | 887 return false; |
| 874 pending_operation_ = type; | 888 pending_operation_ = type; |
| 875 return true; | 889 return true; |
| 876 } | 890 } |
| 877 | 891 |
| 878 } // namespace fileapi | 892 } // namespace fileapi |
| OLD | NEW |