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/time.h" | 7 #include "base/time.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "net/base/escape.h" | 9 #include "net/base/escape.h" |
10 #include "net/url_request/url_request_context.h" | 10 #include "net/url_request/url_request_context.h" |
11 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 11 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
12 #include "webkit/fileapi/file_system_context.h" | 12 #include "webkit/fileapi/file_system_context.h" |
13 #include "webkit/fileapi/file_system_file_util_proxy.h" | 13 #include "webkit/fileapi/file_system_file_util_proxy.h" |
14 #include "webkit/fileapi/file_system_operation_context.h" | 14 #include "webkit/fileapi/file_system_operation_context.h" |
15 #include "webkit/fileapi/file_system_path_manager.h" | 15 #include "webkit/fileapi/file_system_path_manager.h" |
16 #include "webkit/fileapi/file_system_quota_util.h" | |
16 #include "webkit/fileapi/file_system_types.h" | 17 #include "webkit/fileapi/file_system_types.h" |
17 #include "webkit/fileapi/file_system_util.h" | 18 #include "webkit/fileapi/file_system_util.h" |
18 #include "webkit/fileapi/file_writer_delegate.h" | 19 #include "webkit/fileapi/file_writer_delegate.h" |
19 #include "webkit/fileapi/local_file_system_file_util.h" | 20 #include "webkit/fileapi/local_file_system_file_util.h" |
20 #include "webkit/fileapi/quota_file_util.h" | 21 #include "webkit/fileapi/quota_file_util.h" |
21 #include "webkit/quota/quota_types.h" | 22 #include "webkit/quota/quota_types.h" |
22 | 23 |
23 namespace fileapi { | 24 namespace fileapi { |
24 | 25 |
25 FileSystemOperation::FileSystemOperation( | 26 FileSystemOperation::FileSystemOperation( |
26 FileSystemCallbackDispatcher* dispatcher, | 27 FileSystemCallbackDispatcher* dispatcher, |
27 scoped_refptr<base::MessageLoopProxy> proxy, | 28 scoped_refptr<base::MessageLoopProxy> proxy, |
28 FileSystemContext* file_system_context, | 29 FileSystemContext* file_system_context, |
29 FileSystemFileUtil* file_system_file_util) | 30 FileSystemFileUtil* file_system_file_util) |
30 : proxy_(proxy), | 31 : proxy_(proxy), |
31 dispatcher_(dispatcher), | 32 dispatcher_(dispatcher), |
32 file_system_operation_context_( | 33 file_system_operation_context_( |
33 file_system_context, file_system_file_util), | 34 file_system_context, file_system_file_util), |
34 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 35 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
35 DCHECK(dispatcher); | 36 DCHECK(dispatcher); |
36 #ifndef NDEBUG | 37 #ifndef NDEBUG |
37 pending_operation_ = kOperationNone; | 38 pending_operation_ = kOperationNone; |
38 #endif | 39 #endif |
39 // TODO(dmikurube): Read and set available bytes from the Quota Manager. | |
ericu
2011/05/24 03:03:56
Was this just dead code?
kinuko
2011/05/24 03:09:32
I believe so.
| |
40 file_system_operation_context_.set_allowed_bytes_growth( | |
41 QuotaFileUtil::kNoLimit); | |
42 } | 40 } |
43 | 41 |
44 FileSystemOperation::~FileSystemOperation() { | 42 FileSystemOperation::~FileSystemOperation() { |
45 if (file_writer_delegate_.get()) | 43 if (file_writer_delegate_.get()) |
46 FileSystemFileUtilProxy::Close( | 44 FileSystemFileUtilProxy::Close( |
47 file_system_operation_context_, | 45 file_system_operation_context_, |
48 proxy_, file_writer_delegate_->file(), NULL); | 46 proxy_, file_writer_delegate_->file(), NULL); |
49 } | 47 } |
50 | 48 |
51 void FileSystemOperation::OpenFileSystem( | 49 void FileSystemOperation::OpenFileSystem( |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
649 } | 647 } |
650 dispatcher_->DidOpenFileSystem(name, result); | 648 dispatcher_->DidOpenFileSystem(name, result); |
651 delete this; | 649 delete this; |
652 } | 650 } |
653 | 651 |
654 void FileSystemOperation::DidEnsureFileExistsExclusive( | 652 void FileSystemOperation::DidEnsureFileExistsExclusive( |
655 base::PlatformFileError rv, bool created) { | 653 base::PlatformFileError rv, bool created) { |
656 if (rv == base::PLATFORM_FILE_OK && !created) { | 654 if (rv == base::PLATFORM_FILE_OK && !created) { |
657 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_EXISTS); | 655 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_EXISTS); |
658 delete this; | 656 delete this; |
659 } else | 657 } else { |
660 DidFinishFileOperation(rv); | 658 DidFinishFileOperation(rv); |
659 } | |
661 } | 660 } |
662 | 661 |
663 void FileSystemOperation::DidEnsureFileExistsNonExclusive( | 662 void FileSystemOperation::DidEnsureFileExistsNonExclusive( |
664 base::PlatformFileError rv, bool /* created */) { | 663 base::PlatformFileError rv, bool /* created */) { |
665 DidFinishFileOperation(rv); | 664 DidFinishFileOperation(rv); |
666 } | 665 } |
667 | 666 |
668 void FileSystemOperation::DidFinishFileOperation( | 667 void FileSystemOperation::DidFinishFileOperation( |
669 base::PlatformFileError rv) { | 668 base::PlatformFileError rv) { |
670 if (cancel_operation_.get()) { | 669 if (cancel_operation_.get()) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
811 if (!file_system_context()->path_manager()->IsAccessAllowed( | 810 if (!file_system_context()->path_manager()->IsAccessAllowed( |
812 *origin_url, *type, *virtual_path)) { | 811 *origin_url, *type, *virtual_path)) { |
813 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); | 812 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); |
814 return false; | 813 return false; |
815 } | 814 } |
816 DCHECK(file_system_file_util); | 815 DCHECK(file_system_file_util); |
817 *file_system_file_util = | 816 *file_system_file_util = |
818 file_system_context()->path_manager()->GetFileSystemFileUtil(*type); | 817 file_system_context()->path_manager()->GetFileSystemFileUtil(*type); |
819 DCHECK(*file_system_file_util); | 818 DCHECK(*file_system_file_util); |
820 | 819 |
820 // We notify this read access whether the read access succeeds or not. | |
821 // This must be ok since this is used to let the QM's eviction logic know | |
822 // someone is interested in reading the origin data and therefore to indicate | |
823 // that evicting this origin may not be a good idea. | |
824 file_system_context()->GetQuotaUtil(*type)-> | |
825 NotifyOriginWasAccessedOnIOThread( | |
826 file_system_context()->quota_manager_proxy(), | |
827 *origin_url, | |
828 *type); | |
829 | |
821 return true; | 830 return true; |
822 } | 831 } |
823 | 832 |
824 bool FileSystemOperation::VerifyFileSystemPathForWrite( | 833 bool FileSystemOperation::VerifyFileSystemPathForWrite( |
825 const GURL& path, bool create, GURL* origin_url, FileSystemType* type, | 834 const GURL& path, bool create, GURL* origin_url, FileSystemType* type, |
826 FilePath* virtual_path, FileSystemFileUtil** file_system_file_util) { | 835 FilePath* virtual_path, FileSystemFileUtil** file_system_file_util) { |
827 | 836 |
828 // If we have no context, we just allow any operations, for testing. | 837 // If we have no context, we just allow any operations, for testing. |
829 // TODO(ericu): Revisit this hack for security. | 838 // TODO(ericu): Revisit this hack for security. |
830 if (!file_system_context()) { | 839 if (!file_system_context()) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
868 } | 877 } |
869 DCHECK(file_system_file_util); | 878 DCHECK(file_system_file_util); |
870 *file_system_file_util = | 879 *file_system_file_util = |
871 file_system_context()->path_manager()->GetFileSystemFileUtil(*type); | 880 file_system_context()->path_manager()->GetFileSystemFileUtil(*type); |
872 DCHECK(*file_system_file_util); | 881 DCHECK(*file_system_file_util); |
873 | 882 |
874 return true; | 883 return true; |
875 } | 884 } |
876 | 885 |
877 } // namespace fileapi | 886 } // namespace fileapi |
OLD | NEW |