| 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_context.h" | 5 #include "webkit/fileapi/file_system_context.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 7 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 8 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 9 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste
m.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste
m.h" |
| 12 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 11 #include "webkit/fileapi/file_system_file_util.h" | 13 #include "webkit/fileapi/file_system_file_util.h" |
| 12 #include "webkit/fileapi/file_system_options.h" | 14 #include "webkit/fileapi/file_system_options.h" |
| 13 #include "webkit/fileapi/file_system_quota_client.h" | 15 #include "webkit/fileapi/file_system_quota_client.h" |
| 14 #include "webkit/fileapi/file_system_util.h" | 16 #include "webkit/fileapi/file_system_util.h" |
| 15 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 17 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 16 #include "webkit/quota/quota_manager.h" | 18 #include "webkit/quota/quota_manager.h" |
| 17 #include "webkit/quota/special_storage_policy.h" | 19 #include "webkit/quota/special_storage_policy.h" |
| 18 | 20 |
| 19 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
| 20 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" | 22 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" |
| 21 #endif | 23 #endif |
| 22 | 24 |
| 23 using quota::QuotaClient; | 25 using quota::QuotaClient; |
| 24 | 26 |
| 25 namespace fileapi { | 27 namespace fileapi { |
| 26 | 28 |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| 29 QuotaClient* CreateQuotaClient( | 31 QuotaClient* CreateQuotaClient( |
| 30 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 32 scoped_refptr<base::MessageLoopProxy> file_message_loop, |
| 31 FileSystemContext* context, | 33 FileSystemContext* context, |
| 32 bool is_incognito) { | 34 bool is_incognito) { |
| 33 return new FileSystemQuotaClient(file_message_loop, context, is_incognito); | 35 return new FileSystemQuotaClient(file_message_loop, context, is_incognito); |
| 34 } | 36 } |
| 35 | 37 |
| 38 void DidOpenFileSystem(FileSystemCallbackDispatcher* dispatcher, |
| 39 const GURL& filesystem_root, |
| 40 const std::string& filesystem_name, |
| 41 base::PlatformFileError error) { |
| 42 if (error == base::PLATFORM_FILE_OK) { |
| 43 dispatcher->DidOpenFileSystem(filesystem_name, filesystem_root); |
| 44 } else { |
| 45 dispatcher->DidFail(error); |
| 46 } |
| 47 } |
| 48 |
| 36 } // anonymous namespace | 49 } // anonymous namespace |
| 37 | 50 |
| 38 FileSystemContext::FileSystemContext( | 51 FileSystemContext::FileSystemContext( |
| 39 base::MessageLoopProxy* file_message_loop, | 52 base::MessageLoopProxy* file_message_loop, |
| 40 base::MessageLoopProxy* io_message_loop, | 53 base::MessageLoopProxy* io_message_loop, |
| 41 quota::SpecialStoragePolicy* special_storage_policy, | 54 quota::SpecialStoragePolicy* special_storage_policy, |
| 42 quota::QuotaManagerProxy* quota_manager_proxy, | 55 quota::QuotaManagerProxy* quota_manager_proxy, |
| 43 const FilePath& profile_path, | 56 const FilePath& profile_path, |
| 44 FileSystemOptions* options) | 57 FileSystemOptions* options) |
| 45 : file_message_loop_(file_message_loop), | 58 : file_message_loop_(file_message_loop), |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 146 } |
| 134 | 147 |
| 135 void FileSystemContext::DeleteOnCorrectThread() const { | 148 void FileSystemContext::DeleteOnCorrectThread() const { |
| 136 if (!io_message_loop_->BelongsToCurrentThread()) { | 149 if (!io_message_loop_->BelongsToCurrentThread()) { |
| 137 io_message_loop_->DeleteSoon(FROM_HERE, this); | 150 io_message_loop_->DeleteSoon(FROM_HERE, this); |
| 138 return; | 151 return; |
| 139 } | 152 } |
| 140 delete this; | 153 delete this; |
| 141 } | 154 } |
| 142 | 155 |
| 156 void FileSystemContext::OpenFileSystem( |
| 157 const GURL& origin_url, |
| 158 FileSystemType type, |
| 159 bool create, |
| 160 FileSystemCallbackDispatcher* dispatcher) { |
| 161 DCHECK(dispatcher); |
| 162 |
| 163 GURL root_url = GetFileSystemRootURI(origin_url, type); |
| 164 std::string name = GetFileSystemName(origin_url, type); |
| 165 |
| 166 FileSystemMountPointProvider* mount_point_provider = |
| 167 GetMountPointProvider(type); |
| 168 DCHECK(mount_point_provider); |
| 169 mount_point_provider->ValidateFileSystemRoot( |
| 170 origin_url, type, create, |
| 171 base::Bind(&DidOpenFileSystem, |
| 172 base::Owned(dispatcher), root_url, name)); |
| 173 } |
| 174 |
| 143 } // namespace fileapi | 175 } // namespace fileapi |
| 144 | 176 |
| 145 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeTemporary) == \ | 177 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeTemporary) == \ |
| 146 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); | 178 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); |
| 147 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypePersistent) == \ | 179 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypePersistent) == \ |
| 148 int(fileapi::kFileSystemTypePersistent), mismatching_enums); | 180 int(fileapi::kFileSystemTypePersistent), mismatching_enums); |
| 149 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeExternal) == \ | 181 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeExternal) == \ |
| 150 int(fileapi::kFileSystemTypeExternal), mismatching_enums); | 182 int(fileapi::kFileSystemTypeExternal), mismatching_enums); |
| OLD | NEW |