Chromium Code Reviews| 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/sandbox_mount_point_provider.h" | 5 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 bool SandboxMountPointProvider::IsSandboxType(FileSystemType type) { | 134 bool SandboxMountPointProvider::IsSandboxType(FileSystemType type) { |
| 135 return type == kFileSystemTypeTemporary || | 135 return type == kFileSystemTypeTemporary || |
| 136 type == kFileSystemTypePersistent || | 136 type == kFileSystemTypePersistent || |
| 137 type == kFileSystemTypeSyncable; | 137 type == kFileSystemTypeSyncable; |
| 138 } | 138 } |
| 139 | 139 |
| 140 SandboxMountPointProvider::SandboxMountPointProvider( | 140 SandboxMountPointProvider::SandboxMountPointProvider( |
| 141 quota::QuotaManagerProxy* quota_manager_proxy, | 141 quota::QuotaManagerProxy* quota_manager_proxy, |
| 142 base::SequencedTaskRunner* file_task_runner, | 142 base::SequencedTaskRunner* file_task_runner, |
| 143 const base::FilePath& profile_path, | 143 const base::FilePath& profile_path, |
| 144 const FileSystemOptions& file_system_options) | 144 const FileSystemOptions& file_system_options, |
| 145 quota::SpecialStoragePolicy* special_storage_policy) | |
| 145 : file_task_runner_(file_task_runner), | 146 : file_task_runner_(file_task_runner), |
| 146 profile_path_(profile_path), | 147 profile_path_(profile_path), |
| 147 file_system_options_(file_system_options), | 148 file_system_options_(file_system_options), |
| 148 enable_temporary_file_system_in_incognito_(false), | 149 enable_temporary_file_system_in_incognito_(false), |
| 149 sandbox_file_util_( | 150 sandbox_file_util_( |
| 150 new AsyncFileUtilAdapter( | 151 new AsyncFileUtilAdapter( |
| 151 new ObfuscatedFileUtil( | 152 new ObfuscatedFileUtil( |
| 152 profile_path.Append(kFileSystemDirectory)))), | 153 profile_path.Append(kFileSystemDirectory)))), |
| 153 file_system_usage_cache_(new FileSystemUsageCache(file_task_runner)), | 154 file_system_usage_cache_(new FileSystemUsageCache(file_task_runner)), |
| 154 quota_observer_(new SandboxQuotaObserver( | 155 quota_observer_(new SandboxQuotaObserver( |
| 155 quota_manager_proxy, | 156 quota_manager_proxy, |
| 156 file_task_runner, | 157 file_task_runner, |
| 157 sandbox_sync_file_util(), | 158 sandbox_sync_file_util(), |
| 158 file_system_usage_cache_.get())), | 159 file_system_usage_cache_.get())), |
| 159 enable_usage_tracking_( | 160 enable_usage_tracking_( |
| 160 !CommandLine::ForCurrentProcess()->HasSwitch( | 161 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 161 kDisableUsageTracking)), | 162 kDisableUsageTracking)), |
| 163 special_storage_policy_(special_storage_policy), | |
| 162 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 164 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 163 // Set quota observers. | 165 // Set quota observers. |
| 164 UpdateObserverList::Source update_observers_src; | 166 UpdateObserverList::Source update_observers_src; |
| 165 AccessObserverList::Source access_observers_src; | 167 AccessObserverList::Source access_observers_src; |
| 166 | 168 |
| 167 if (enable_usage_tracking_) { | 169 if (enable_usage_tracking_) { |
| 168 update_observers_src.AddObserver(quota_observer_.get(), file_task_runner_); | 170 update_observers_src.AddObserver(quota_observer_.get(), file_task_runner_); |
| 169 access_observers_src.AddObserver(quota_observer_.get(), NULL); | 171 access_observers_src.AddObserver(quota_observer_.get(), NULL); |
| 170 } | 172 } |
| 171 | 173 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 operation_context->set_update_observers(syncable_update_observers_); | 327 operation_context->set_update_observers(syncable_update_observers_); |
| 326 operation_context->set_change_observers(syncable_change_observers_); | 328 operation_context->set_change_observers(syncable_change_observers_); |
| 327 operation_context->set_access_observers(access_observers_); | 329 operation_context->set_access_observers(access_observers_); |
| 328 return new sync_file_system::SyncableFileSystemOperation( | 330 return new sync_file_system::SyncableFileSystemOperation( |
| 329 context, operation_context.Pass()); | 331 context, operation_context.Pass()); |
| 330 } | 332 } |
| 331 | 333 |
| 332 // For regular sandboxed types. | 334 // For regular sandboxed types. |
| 333 operation_context->set_update_observers(update_observers_); | 335 operation_context->set_update_observers(update_observers_); |
| 334 operation_context->set_access_observers(access_observers_); | 336 operation_context->set_access_observers(access_observers_); |
| 337 | |
| 338 if (special_storage_policy_ && | |
|
kinuko
2013/04/26 07:27:37
nit: I think you can also check this without passi
tzik
2013/04/26 07:36:27
Done.
| |
| 339 special_storage_policy_->IsStorageUnlimited(url.origin())) { | |
| 340 operation_context->set_quota_limit_type(quota::kQuotaLimitTypeUnlimited); | |
| 341 } else { | |
| 342 operation_context->set_quota_limit_type(quota::kQuotaLimitTypeLimited); | |
| 343 } | |
| 344 | |
| 335 return new LocalFileSystemOperation(context, operation_context.Pass()); | 345 return new LocalFileSystemOperation(context, operation_context.Pass()); |
| 336 } | 346 } |
| 337 | 347 |
| 338 scoped_ptr<webkit_blob::FileStreamReader> | 348 scoped_ptr<webkit_blob::FileStreamReader> |
| 339 SandboxMountPointProvider::CreateFileStreamReader( | 349 SandboxMountPointProvider::CreateFileStreamReader( |
| 340 const FileSystemURL& url, | 350 const FileSystemURL& url, |
| 341 int64 offset, | 351 int64 offset, |
| 342 const base::Time& expected_modification_time, | 352 const base::Time& expected_modification_time, |
| 343 FileSystemContext* context) const { | 353 FileSystemContext* context) const { |
| 344 return scoped_ptr<webkit_blob::FileStreamReader>( | 354 return scoped_ptr<webkit_blob::FileStreamReader>( |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 647 FileSystemType type, | 657 FileSystemType type, |
| 648 FileSystemUsageCache* usage_cache) { | 658 FileSystemUsageCache* usage_cache) { |
| 649 base::PlatformFileError error = base::PLATFORM_FILE_OK; | 659 base::PlatformFileError error = base::PLATFORM_FILE_OK; |
| 650 base::FilePath usage_cache_path = GetUsageCachePathForOriginAndType( | 660 base::FilePath usage_cache_path = GetUsageCachePathForOriginAndType( |
| 651 file_util, origin, type, &error); | 661 file_util, origin, type, &error); |
| 652 if (error == base::PLATFORM_FILE_OK) | 662 if (error == base::PLATFORM_FILE_OK) |
| 653 usage_cache->IncrementDirty(usage_cache_path); | 663 usage_cache->IncrementDirty(usage_cache_path); |
| 654 } | 664 } |
| 655 | 665 |
| 656 } // namespace fileapi | 666 } // namespace fileapi |
| OLD | NEW |