| 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/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 206 } |
| 207 | 207 |
| 208 ExternalFileSystemMountPointProvider* | 208 ExternalFileSystemMountPointProvider* |
| 209 FileSystemContext::external_provider() const { | 209 FileSystemContext::external_provider() const { |
| 210 return external_provider_.get(); | 210 return external_provider_.get(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void FileSystemContext::OpenFileSystem( | 213 void FileSystemContext::OpenFileSystem( |
| 214 const GURL& origin_url, | 214 const GURL& origin_url, |
| 215 FileSystemType type, | 215 FileSystemType type, |
| 216 bool create, | 216 OpenFileSystemMode mode, |
| 217 const OpenFileSystemCallback& callback) { | 217 const OpenFileSystemCallback& callback) { |
| 218 DCHECK(!callback.is_null()); | 218 DCHECK(!callback.is_null()); |
| 219 | 219 |
| 220 FileSystemMountPointProvider* mount_point_provider = | 220 FileSystemMountPointProvider* mount_point_provider = |
| 221 GetMountPointProvider(type); | 221 GetMountPointProvider(type); |
| 222 if (!mount_point_provider) { | 222 if (!mount_point_provider) { |
| 223 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, std::string(), GURL()); | 223 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, std::string(), GURL()); |
| 224 return; | 224 return; |
| 225 } | 225 } |
| 226 | 226 |
| 227 GURL root_url = GetFileSystemRootURI(origin_url, type); | 227 GURL root_url = GetFileSystemRootURI(origin_url, type); |
| 228 std::string name = GetFileSystemName(origin_url, type); | 228 std::string name = GetFileSystemName(origin_url, type); |
| 229 | 229 |
| 230 mount_point_provider->ValidateFileSystemRoot( | 230 mount_point_provider->OpenFileSystem( |
| 231 origin_url, type, create, | 231 origin_url, type, mode, |
| 232 base::Bind(&DidOpenFileSystem, callback, root_url, name)); | 232 base::Bind(&DidOpenFileSystem, callback, root_url, name)); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void FileSystemContext::OpenSyncableFileSystem( | 235 void FileSystemContext::OpenSyncableFileSystem( |
| 236 const std::string& mount_name, | 236 const std::string& mount_name, |
| 237 const GURL& origin_url, | 237 const GURL& origin_url, |
| 238 FileSystemType type, | 238 FileSystemType type, |
| 239 bool create, | 239 OpenFileSystemMode mode, |
| 240 const OpenFileSystemCallback& callback) { | 240 const OpenFileSystemCallback& callback) { |
| 241 DCHECK(!callback.is_null()); | 241 DCHECK(!callback.is_null()); |
| 242 | 242 |
| 243 DCHECK(type == kFileSystemTypeSyncable); | 243 DCHECK(type == kFileSystemTypeSyncable); |
| 244 | 244 |
| 245 GURL root_url = sync_file_system::GetSyncableFileSystemRootURI( | 245 GURL root_url = sync_file_system::GetSyncableFileSystemRootURI( |
| 246 origin_url, mount_name); | 246 origin_url, mount_name); |
| 247 std::string name = GetFileSystemName(origin_url, kFileSystemTypeSyncable); | 247 std::string name = GetFileSystemName(origin_url, kFileSystemTypeSyncable); |
| 248 | 248 |
| 249 FileSystemMountPointProvider* mount_point_provider = | 249 FileSystemMountPointProvider* mount_point_provider = |
| 250 GetMountPointProvider(type); | 250 GetMountPointProvider(type); |
| 251 DCHECK(mount_point_provider); | 251 DCHECK(mount_point_provider); |
| 252 mount_point_provider->ValidateFileSystemRoot( | 252 mount_point_provider->OpenFileSystem( |
| 253 origin_url, type, create, | 253 origin_url, type, mode, |
| 254 base::Bind(&DidOpenFileSystem, callback, root_url, name)); | 254 base::Bind(&DidOpenFileSystem, callback, root_url, name)); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void FileSystemContext::DeleteFileSystem( | 257 void FileSystemContext::DeleteFileSystem( |
| 258 const GURL& origin_url, | 258 const GURL& origin_url, |
| 259 FileSystemType type, | 259 FileSystemType type, |
| 260 const DeleteFileSystemCallback& callback) { | 260 const DeleteFileSystemCallback& callback) { |
| 261 DCHECK(origin_url == origin_url.GetOrigin()); | 261 DCHECK(origin_url == origin_url.GetOrigin()); |
| 262 FileSystemMountPointProvider* mount_point_provider = | 262 FileSystemMountPointProvider* mount_point_provider = |
| 263 GetMountPointProvider(type); | 263 GetMountPointProvider(type); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 FileSystemType type = static_cast<FileSystemType>(t); | 412 FileSystemType type = static_cast<FileSystemType>(t); |
| 413 if (provider->CanHandleType(type)) { | 413 if (provider->CanHandleType(type)) { |
| 414 const bool inserted = provider_map_.insert( | 414 const bool inserted = provider_map_.insert( |
| 415 std::make_pair(type, provider)).second; | 415 std::make_pair(type, provider)).second; |
| 416 DCHECK(inserted); | 416 DCHECK(inserted); |
| 417 } | 417 } |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 | 420 |
| 421 } // namespace fileapi | 421 } // namespace fileapi |
| OLD | NEW |