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 "content/browser/fileapi/fileapi_message_filter.h" | 5 #include "content/browser/fileapi/fileapi_message_filter.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "webkit/blob/blob_storage_controller.h" | 28 #include "webkit/blob/blob_storage_controller.h" |
29 #include "webkit/blob/shareable_file_reference.h" | 29 #include "webkit/blob/shareable_file_reference.h" |
30 #include "webkit/fileapi/file_observers.h" | 30 #include "webkit/fileapi/file_observers.h" |
31 #include "webkit/fileapi/file_permission_policy.h" | 31 #include "webkit/fileapi/file_permission_policy.h" |
32 #include "webkit/fileapi/file_system_context.h" | 32 #include "webkit/fileapi/file_system_context.h" |
33 #include "webkit/fileapi/file_system_types.h" | 33 #include "webkit/fileapi/file_system_types.h" |
34 #include "webkit/fileapi/file_system_util.h" | 34 #include "webkit/fileapi/file_system_util.h" |
35 #include "webkit/fileapi/isolated_context.h" | 35 #include "webkit/fileapi/isolated_context.h" |
36 #include "webkit/fileapi/local_file_system_operation.h" | 36 #include "webkit/fileapi/local_file_system_operation.h" |
37 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 37 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 38 #include "webkit/quota/quota_manager.h" |
38 | 39 |
39 using fileapi::FileSystemFileUtil; | 40 using fileapi::FileSystemFileUtil; |
40 using fileapi::FileSystemMountPointProvider; | 41 using fileapi::FileSystemMountPointProvider; |
41 using fileapi::FileSystemOperation; | 42 using fileapi::FileSystemOperation; |
42 using fileapi::FileSystemURL; | 43 using fileapi::FileSystemURL; |
43 using fileapi::FileUpdateObserver; | 44 using fileapi::FileUpdateObserver; |
44 using fileapi::LocalFileSystemOperation; | 45 using fileapi::LocalFileSystemOperation; |
45 using fileapi::UpdateObserverList; | 46 using fileapi::UpdateObserverList; |
46 using webkit_blob::BlobData; | 47 using webkit_blob::BlobData; |
47 using webkit_blob::BlobStorageController; | 48 using webkit_blob::BlobStorageController; |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 base::PlatformFileError result, | 674 base::PlatformFileError result, |
674 const std::vector<base::FileUtilProxy::Entry>& entries, | 675 const std::vector<base::FileUtilProxy::Entry>& entries, |
675 bool has_more) { | 676 bool has_more) { |
676 if (result == base::PLATFORM_FILE_OK) | 677 if (result == base::PLATFORM_FILE_OK) |
677 Send(new FileSystemMsg_DidReadDirectory(request_id, entries, has_more)); | 678 Send(new FileSystemMsg_DidReadDirectory(request_id, entries, has_more)); |
678 else | 679 else |
679 Send(new FileSystemMsg_DidFail(request_id, result)); | 680 Send(new FileSystemMsg_DidFail(request_id, result)); |
680 UnregisterOperation(request_id); | 681 UnregisterOperation(request_id); |
681 } | 682 } |
682 | 683 |
683 void FileAPIMessageFilter::DidOpenFile(int request_id, | 684 void FileAPIMessageFilter::DidOpenFile( |
684 const GURL& path, | 685 int request_id, |
685 base::PlatformFileError result, | 686 const GURL& path, |
686 base::PlatformFile file, | 687 base::PlatformFileError result, |
687 base::ProcessHandle peer_handle) { | 688 base::PlatformFile file, |
| 689 base::ProcessHandle peer_handle) { |
688 if (result == base::PLATFORM_FILE_OK) { | 690 if (result == base::PLATFORM_FILE_OK) { |
689 IPC::PlatformFileForTransit file_for_transit = | 691 IPC::PlatformFileForTransit file_for_transit = |
690 file != base::kInvalidPlatformFileValue ? | 692 file != base::kInvalidPlatformFileValue ? |
691 IPC::GetFileHandleForProcess(file, peer_handle, true) : | 693 IPC::GetFileHandleForProcess(file, peer_handle, true) : |
692 IPC::InvalidPlatformFileForTransit(); | 694 IPC::InvalidPlatformFileForTransit(); |
693 open_filesystem_urls_.insert(path); | 695 open_filesystem_urls_.insert(path); |
694 Send(new FileSystemMsg_DidOpenFile(request_id, file_for_transit)); | 696 |
| 697 quota::QuotaLimitType quota_limit_type = quota::kQuotaLimitTypeUnknown; |
| 698 quota::QuotaManagerProxy* quota_manager_proxy = |
| 699 context_->quota_manager_proxy(); |
| 700 if (quota_manager_proxy) { |
| 701 FileSystemURL url = context_->CrackURL(path); |
| 702 if (quota_manager_proxy->quota_manager()->IsStorageUnlimited( |
| 703 url.origin(), FileSystemTypeToQuotaStorageType(url.type()))) { |
| 704 quota_limit_type = quota::kQuotaLimitTypeUnlimited; |
| 705 } else { |
| 706 quota_limit_type = quota::kQuotaLimitTypeLimited; |
| 707 } |
| 708 } |
| 709 |
| 710 Send(new FileSystemMsg_DidOpenFile(request_id, |
| 711 file_for_transit, |
| 712 quota_limit_type)); |
695 } else { | 713 } else { |
696 Send(new FileSystemMsg_DidFail(request_id, result)); | 714 Send(new FileSystemMsg_DidFail(request_id, |
| 715 result)); |
697 } | 716 } |
698 UnregisterOperation(request_id); | 717 UnregisterOperation(request_id); |
699 } | 718 } |
700 | 719 |
701 void FileAPIMessageFilter::DidWrite(int request_id, | 720 void FileAPIMessageFilter::DidWrite(int request_id, |
702 base::PlatformFileError result, | 721 base::PlatformFileError result, |
703 int64 bytes, | 722 int64 bytes, |
704 bool complete) { | 723 bool complete) { |
705 if (result == base::PLATFORM_FILE_OK) { | 724 if (result == base::PLATFORM_FILE_OK) { |
706 Send(new FileSystemMsg_DidWrite(request_id, bytes, complete)); | 725 Send(new FileSystemMsg_DidWrite(request_id, bytes, complete)); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 Send(new FileSystemMsg_DidFail(request_id, error_code)); | 897 Send(new FileSystemMsg_DidFail(request_id, error_code)); |
879 return NULL; | 898 return NULL; |
880 } | 899 } |
881 | 900 |
882 DCHECK(operation); | 901 DCHECK(operation); |
883 operations_.AddWithID(operation, request_id); | 902 operations_.AddWithID(operation, request_id); |
884 return operation; | 903 return operation; |
885 } | 904 } |
886 | 905 |
887 } // namespace content | 906 } // namespace content |
OLD | NEW |