| 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/file_system_context.h" | 5 #include "webkit/fileapi/file_system_context.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 11 #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" | 12 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 13 #include "webkit/fileapi/file_system_file_util.h" | 13 #include "webkit/fileapi/file_system_file_util.h" |
| 14 #include "webkit/fileapi/file_system_operation_interface.h" |
| 14 #include "webkit/fileapi/file_system_options.h" | 15 #include "webkit/fileapi/file_system_options.h" |
| 15 #include "webkit/fileapi/file_system_quota_client.h" | 16 #include "webkit/fileapi/file_system_quota_client.h" |
| 16 #include "webkit/fileapi/file_system_util.h" | 17 #include "webkit/fileapi/file_system_util.h" |
| 17 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 18 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 18 #include "webkit/quota/quota_manager.h" | 19 #include "webkit/quota/quota_manager.h" |
| 19 #include "webkit/quota/special_storage_policy.h" | 20 #include "webkit/quota/special_storage_policy.h" |
| 20 | 21 |
| 21 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
| 22 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" | 23 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" |
| 23 #endif | 24 #endif |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 153 } |
| 153 delete this; | 154 delete this; |
| 154 } | 155 } |
| 155 | 156 |
| 156 void FileSystemContext::OpenFileSystem( | 157 void FileSystemContext::OpenFileSystem( |
| 157 const GURL& origin_url, | 158 const GURL& origin_url, |
| 158 FileSystemType type, | 159 FileSystemType type, |
| 159 bool create, | 160 bool create, |
| 160 scoped_ptr<FileSystemCallbackDispatcher> dispatcher) { | 161 scoped_ptr<FileSystemCallbackDispatcher> dispatcher) { |
| 161 DCHECK(dispatcher.get()); | 162 DCHECK(dispatcher.get()); |
| 163 |
| 162 FileSystemMountPointProvider* mount_point_provider = | 164 FileSystemMountPointProvider* mount_point_provider = |
| 163 GetMountPointProvider(type); | 165 GetMountPointProvider(type); |
| 164 if (!mount_point_provider) { | 166 if (!mount_point_provider) { |
| 165 dispatcher->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); | 167 dispatcher->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); |
| 166 return; | 168 return; |
| 167 } | 169 } |
| 168 | 170 |
| 169 GURL root_url = GetFileSystemRootURI(origin_url, type); | 171 GURL root_url = GetFileSystemRootURI(origin_url, type); |
| 170 std::string name = GetFileSystemName(origin_url, type); | 172 std::string name = GetFileSystemName(origin_url, type); |
| 171 | 173 |
| 172 mount_point_provider->ValidateFileSystemRoot( | 174 mount_point_provider->ValidateFileSystemRoot( |
| 173 origin_url, type, create, | 175 origin_url, type, create, |
| 174 base::Bind(&DidOpenFileSystem, | 176 base::Bind(&DidOpenFileSystem, |
| 175 base::Passed(&dispatcher), root_url, name)); | 177 base::Passed(&dispatcher), root_url, name)); |
| 176 } | 178 } |
| 177 | 179 |
| 180 FileSystemOperationInterface* FileSystemContext::CreateFileSystemOperation( |
| 181 const GURL& url, |
| 182 scoped_ptr<FileSystemCallbackDispatcher> dispatcher, |
| 183 base::MessageLoopProxy* file_proxy) { |
| 184 GURL origin_url; |
| 185 FileSystemType file_system_type = kFileSystemTypeUnknown; |
| 186 FilePath file_path; |
| 187 if (!CrackFileSystemURL(url, &origin_url, &file_system_type, &file_path)) |
| 188 return NULL; |
| 189 FileSystemMountPointProvider* mount_point_provider = |
| 190 GetMountPointProvider(file_system_type); |
| 191 if (!mount_point_provider) |
| 192 return NULL; |
| 193 return mount_point_provider->CreateFileSystemOperation( |
| 194 origin_url, file_system_type, file_path, |
| 195 dispatcher.Pass(), file_proxy, this); |
| 196 } |
| 197 |
| 178 } // namespace fileapi | 198 } // namespace fileapi |
| 179 | 199 |
| 180 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeTemporary) == \ | 200 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeTemporary) == \ |
| 181 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); | 201 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); |
| 182 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypePersistent) == \ | 202 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypePersistent) == \ |
| 183 int(fileapi::kFileSystemTypePersistent), mismatching_enums); | 203 int(fileapi::kFileSystemTypePersistent), mismatching_enums); |
| 184 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeExternal) == \ | 204 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeExternal) == \ |
| 185 int(fileapi::kFileSystemTypeExternal), mismatching_enums); | 205 int(fileapi::kFileSystemTypeExternal), mismatching_enums); |
| OLD | NEW |