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

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

Issue 14265022: [Quota][FileAPI] Add quota policy to FileSystemOperationContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: drop .gitmodule change Created 7 years, 7 months 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_operation_context.h ('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) 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
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,
336 quota::kQuotaLimitTypeLimited);
335 return; 337 return;
336 } 338 }
337 if (file_flags & 339 if (file_flags &
338 (base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_OPEN_ALWAYS | 340 (base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_OPEN_ALWAYS |
339 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_TRUNCATED | 341 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_TRUNCATED |
340 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE | 342 base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE |
341 base::PLATFORM_FILE_DELETE_ON_CLOSE | 343 base::PLATFORM_FILE_DELETE_ON_CLOSE |
342 base::PLATFORM_FILE_WRITE_ATTRIBUTES)) { 344 base::PLATFORM_FILE_WRITE_ATTRIBUTES)) {
343 base::PlatformFileError result = SetUp(url, OPERATION_MODE_WRITE); 345 base::PlatformFileError result = SetUp(url, OPERATION_MODE_WRITE);
344 if (result != base::PLATFORM_FILE_OK) { 346 if (result != base::PLATFORM_FILE_OK) {
345 callback.Run(result, base::PlatformFile(), base::ProcessHandle()); 347 callback.Run(result,
348 base::kInvalidPlatformFileValue,
349 base::kNullProcessHandle,
350 quota::kQuotaLimitTypeLimited);
346 return; 351 return;
347 } 352 }
348 } else { 353 } else {
349 base::PlatformFileError result = SetUp(url, OPERATION_MODE_READ); 354 base::PlatformFileError result = SetUp(url, OPERATION_MODE_READ);
350 if (result != base::PLATFORM_FILE_OK) { 355 if (result != base::PLATFORM_FILE_OK) {
351 callback.Run(result, base::PlatformFile(), base::ProcessHandle()); 356 callback.Run(result,
357 base::kInvalidPlatformFileValue,
358 base::kNullProcessHandle,
359 quota::kQuotaLimitTypeLimited);
352 return; 360 return;
353 } 361 }
354 } 362 }
355 GetUsageAndQuotaThenRunTask( 363 GetUsageAndQuotaThenRunTask(
356 url, 364 url,
357 base::Bind(&LocalFileSystemOperation::DoOpenFile, 365 base::Bind(&LocalFileSystemOperation::DoOpenFile,
358 base::Unretained(deleter.release()), 366 base::Unretained(deleter.release()),
359 url, callback, file_flags), 367 url, callback, file_flags),
360 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED, 368 base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED,
361 base::kInvalidPlatformFileValue, 369 base::kInvalidPlatformFileValue,
362 base::kNullProcessHandle)); 370 base::kNullProcessHandle,
371 quota::kQuotaLimitTypeLimited));
363 } 372 }
364 373
365 void LocalFileSystemOperation::NotifyCloseFile(const FileSystemURL& url) { 374 void LocalFileSystemOperation::NotifyCloseFile(const FileSystemURL& url) {
366 // No particular task to do. This method is for remote file systems that 375 // No particular task to do. This method is for remote file systems that
367 // need synchronization with remote server. 376 // need synchronization with remote server.
368 delete this; 377 delete this;
369 } 378 }
370 379
371 // We can only get here on a write or truncate that's not yet completed. 380 // We can only get here on a write or truncate that's not yet completed.
372 // We don't support cancelling any other operation at this time. 381 // We don't support cancelling any other operation at this time.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 const FileSystemURL& url, 564 const FileSystemURL& url,
556 const base::Closure& task, 565 const base::Closure& task,
557 const base::Closure& error_callback) { 566 const base::Closure& error_callback) {
558 quota::QuotaManagerProxy* quota_manager_proxy = 567 quota::QuotaManagerProxy* quota_manager_proxy =
559 file_system_context()->quota_manager_proxy(); 568 file_system_context()->quota_manager_proxy();
560 if (!quota_manager_proxy || 569 if (!quota_manager_proxy ||
561 !file_system_context()->GetQuotaUtil(url.type())) { 570 !file_system_context()->GetQuotaUtil(url.type())) {
562 // If we don't have the quota manager or the requested filesystem type 571 // 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. 572 // does not support quota, we should be able to let it go.
564 operation_context()->set_allowed_bytes_growth(kint64max); 573 operation_context()->set_allowed_bytes_growth(kint64max);
574 operation_context()->set_quota_limit_type(quota::kQuotaLimitTypeUnlimited);
kinuko 2013/04/26 06:44:21 Looks like this is the primary change you want to
tzik 2013/04/26 06:55:11 Done.
565 task.Run(); 575 task.Run();
566 return; 576 return;
567 } 577 }
568 578
569 DCHECK(quota_manager_proxy); 579 DCHECK(quota_manager_proxy);
570 DCHECK(quota_manager_proxy->quota_manager()); 580 DCHECK(quota_manager_proxy->quota_manager());
581 if (quota_manager_proxy->quota_manager()->IsStorageUnlimited(
582 url.origin(),
583 FileSystemTypeToQuotaStorageType(url.type()))) {
584 operation_context()->set_quota_limit_type(quota::kQuotaLimitTypeUnlimited);
585 } else {
586 operation_context()->set_quota_limit_type(quota::kQuotaLimitTypeLimited);
587 }
588
571 quota_manager_proxy->quota_manager()->GetUsageAndQuota( 589 quota_manager_proxy->quota_manager()->GetUsageAndQuota(
572 url.origin(), 590 url.origin(),
573 FileSystemTypeToQuotaStorageType(url.type()), 591 FileSystemTypeToQuotaStorageType(url.type()),
574 base::Bind(&LocalFileSystemOperation::DidGetUsageAndQuotaAndRunTask, 592 base::Bind(&LocalFileSystemOperation::DidGetUsageAndQuotaAndRunTask,
575 weak_factory_.GetWeakPtr(), task, error_callback)); 593 weak_factory_.GetWeakPtr(), task, error_callback));
576 } 594 }
577 595
578 void LocalFileSystemOperation::DidGetUsageAndQuotaAndRunTask( 596 void LocalFileSystemOperation::DidGetUsageAndQuotaAndRunTask(
579 const base::Closure& task, 597 const base::Closure& task,
580 const base::Closure& error_callback, 598 const base::Closure& error_callback,
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 callback.Run(rv); 830 callback.Run(rv);
813 } 831 }
814 832
815 void LocalFileSystemOperation::DidOpenFile( 833 void LocalFileSystemOperation::DidOpenFile(
816 const OpenFileCallback& callback, 834 const OpenFileCallback& callback,
817 base::PlatformFileError rv, 835 base::PlatformFileError rv,
818 base::PassPlatformFile file, 836 base::PassPlatformFile file,
819 bool unused) { 837 bool unused) {
820 if (rv == base::PLATFORM_FILE_OK) 838 if (rv == base::PLATFORM_FILE_OK)
821 CHECK_NE(base::kNullProcessHandle, peer_handle_); 839 CHECK_NE(base::kNullProcessHandle, peer_handle_);
822 callback.Run(rv, file.ReleaseValue(), peer_handle_); 840 callback.Run(rv, file.ReleaseValue(),
841 peer_handle_,
842 operation_context()->quota_limit_type());
823 } 843 }
824 844
825 void LocalFileSystemOperation::DidCreateSnapshotFile( 845 void LocalFileSystemOperation::DidCreateSnapshotFile(
826 const SnapshotFileCallback& callback, 846 const SnapshotFileCallback& callback,
827 base::PlatformFileError result, 847 base::PlatformFileError result,
828 const base::PlatformFileInfo& file_info, 848 const base::PlatformFileInfo& file_info,
829 const base::FilePath& platform_path, 849 const base::FilePath& platform_path,
830 SnapshotFilePolicy snapshot_policy) { 850 SnapshotFilePolicy snapshot_policy) {
831 scoped_refptr<ShareableFileReference> file_ref; 851 scoped_refptr<ShareableFileReference> file_ref;
832 if (result == base::PLATFORM_FILE_OK && 852 if (result == base::PLATFORM_FILE_OK &&
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 } 889 }
870 890
871 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { 891 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) {
872 if (pending_operation_ != kOperationNone) 892 if (pending_operation_ != kOperationNone)
873 return false; 893 return false;
874 pending_operation_ = type; 894 pending_operation_ = type;
875 return true; 895 return true;
876 } 896 }
877 897
878 } // namespace fileapi 898 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_operation_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698