| 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/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 #include "webkit/fileapi/file_system_file_util.h" | 12 #include "webkit/fileapi/file_system_file_util.h" |
| 13 #include "webkit/fileapi/file_system_operation_interface.h" | 13 #include "webkit/fileapi/file_system_operation_interface.h" |
| 14 #include "webkit/fileapi/file_system_options.h" | 14 #include "webkit/fileapi/file_system_options.h" |
| 15 #include "webkit/fileapi/file_system_quota_client.h" | 15 #include "webkit/fileapi/file_system_quota_client.h" |
| 16 #include "webkit/fileapi/file_system_task_runners.h" |
| 16 #include "webkit/fileapi/file_system_url.h" | 17 #include "webkit/fileapi/file_system_url.h" |
| 17 #include "webkit/fileapi/file_system_util.h" | 18 #include "webkit/fileapi/file_system_util.h" |
| 18 #include "webkit/fileapi/isolated_mount_point_provider.h" | 19 #include "webkit/fileapi/isolated_mount_point_provider.h" |
| 19 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 20 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 20 #include "webkit/quota/quota_manager.h" | 21 #include "webkit/quota/quota_manager.h" |
| 21 #include "webkit/quota/special_storage_policy.h" | 22 #include "webkit/quota/special_storage_policy.h" |
| 22 | 23 |
| 23 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
| 24 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" | 25 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" |
| 25 #endif | 26 #endif |
| (...skipping 14 matching lines...) Expand all Loading... |
| 40 const FileSystemContext::OpenFileSystemCallback& callback, | 41 const FileSystemContext::OpenFileSystemCallback& callback, |
| 41 const GURL& filesystem_root, | 42 const GURL& filesystem_root, |
| 42 const std::string& filesystem_name, | 43 const std::string& filesystem_name, |
| 43 base::PlatformFileError error) { | 44 base::PlatformFileError error) { |
| 44 callback.Run(error, filesystem_name, filesystem_root); | 45 callback.Run(error, filesystem_name, filesystem_root); |
| 45 } | 46 } |
| 46 | 47 |
| 47 } // anonymous namespace | 48 } // anonymous namespace |
| 48 | 49 |
| 49 FileSystemContext::FileSystemContext( | 50 FileSystemContext::FileSystemContext( |
| 50 base::SequencedTaskRunner* file_task_runner, | 51 scoped_ptr<FileSystemTaskRunners> task_runners, |
| 51 base::SingleThreadTaskRunner* io_task_runner, | |
| 52 quota::SpecialStoragePolicy* special_storage_policy, | 52 quota::SpecialStoragePolicy* special_storage_policy, |
| 53 quota::QuotaManagerProxy* quota_manager_proxy, | 53 quota::QuotaManagerProxy* quota_manager_proxy, |
| 54 const FilePath& profile_path, | 54 const FilePath& profile_path, |
| 55 const FileSystemOptions& options) | 55 const FileSystemOptions& options) |
| 56 : file_task_runner_(file_task_runner), | 56 : task_runners_(task_runners.Pass()), |
| 57 io_task_runner_(io_task_runner), | |
| 58 quota_manager_proxy_(quota_manager_proxy), | 57 quota_manager_proxy_(quota_manager_proxy), |
| 59 sandbox_provider_( | 58 sandbox_provider_( |
| 60 new SandboxMountPointProvider( | 59 new SandboxMountPointProvider( |
| 61 file_task_runner, | 60 task_runners_->file_task_runner(), |
| 62 profile_path, | 61 profile_path, |
| 63 options)), | 62 options)), |
| 64 isolated_provider_(new IsolatedMountPointProvider(profile_path)) { | 63 isolated_provider_(new IsolatedMountPointProvider(profile_path)) { |
| 64 DCHECK(task_runners_.get()); |
| 65 |
| 65 if (quota_manager_proxy) { | 66 if (quota_manager_proxy) { |
| 66 quota_manager_proxy->RegisterClient(CreateQuotaClient( | 67 quota_manager_proxy->RegisterClient(CreateQuotaClient( |
| 67 this, options.is_incognito())); | 68 this, options.is_incognito())); |
| 68 } | 69 } |
| 69 #if defined(OS_CHROMEOS) | 70 #if defined(OS_CHROMEOS) |
| 70 external_provider_.reset( | 71 external_provider_.reset( |
| 71 new chromeos::CrosMountPointProvider(special_storage_policy)); | 72 new chromeos::CrosMountPointProvider(special_storage_policy)); |
| 72 #endif | 73 #endif |
| 73 } | 74 } |
| 74 | 75 |
| 75 bool FileSystemContext::DeleteDataForOriginOnFileThread( | 76 bool FileSystemContext::DeleteDataForOriginOnFileThread( |
| 76 const GURL& origin_url) { | 77 const GURL& origin_url) { |
| 77 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 78 DCHECK(task_runners_->file_task_runner()->RunsTasksOnCurrentThread()); |
| 78 DCHECK(sandbox_provider()); | 79 DCHECK(sandbox_provider()); |
| 79 | 80 |
| 80 // Delete temporary and persistent data. | 81 // Delete temporary and persistent data. |
| 81 return | 82 return |
| 82 (sandbox_provider()->DeleteOriginDataOnFileThread( | 83 (sandbox_provider()->DeleteOriginDataOnFileThread( |
| 83 this, quota_manager_proxy(), origin_url, kFileSystemTypeTemporary) == | 84 this, quota_manager_proxy(), origin_url, kFileSystemTypeTemporary) == |
| 84 base::PLATFORM_FILE_OK) && | 85 base::PLATFORM_FILE_OK) && |
| 85 (sandbox_provider()->DeleteOriginDataOnFileThread( | 86 (sandbox_provider()->DeleteOriginDataOnFileThread( |
| 86 this, quota_manager_proxy(), origin_url, kFileSystemTypePersistent) == | 87 this, quota_manager_proxy(), origin_url, kFileSystemTypePersistent) == |
| 87 base::PLATFORM_FILE_OK); | 88 base::PLATFORM_FILE_OK); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 FileSystemType type, | 202 FileSystemType type, |
| 202 FileSystemMountPointProvider* provider) { | 203 FileSystemMountPointProvider* provider) { |
| 203 DCHECK(provider); | 204 DCHECK(provider); |
| 204 DCHECK(provider_map_.find(type) == provider_map_.end()); | 205 DCHECK(provider_map_.find(type) == provider_map_.end()); |
| 205 provider_map_[type] = provider; | 206 provider_map_[type] = provider; |
| 206 } | 207 } |
| 207 | 208 |
| 208 FileSystemContext::~FileSystemContext() {} | 209 FileSystemContext::~FileSystemContext() {} |
| 209 | 210 |
| 210 void FileSystemContext::DeleteOnCorrectThread() const { | 211 void FileSystemContext::DeleteOnCorrectThread() const { |
| 211 if (!io_task_runner_->RunsTasksOnCurrentThread() && | 212 if (!task_runners_->io_task_runner()->RunsTasksOnCurrentThread() && |
| 212 io_task_runner_->DeleteSoon(FROM_HERE, this)) { | 213 task_runners_->io_task_runner()->DeleteSoon(FROM_HERE, this)) { |
| 213 return; | 214 return; |
| 214 } | 215 } |
| 215 STLDeleteContainerPairSecondPointers(provider_map_.begin(), | 216 STLDeleteContainerPairSecondPointers(provider_map_.begin(), |
| 216 provider_map_.end()); | 217 provider_map_.end()); |
| 217 delete this; | 218 delete this; |
| 218 } | 219 } |
| 219 | 220 |
| 220 } // namespace fileapi | 221 } // namespace fileapi |
| OLD | NEW |