| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" | 5 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 env_override_(env_override), | 215 env_override_(env_override), |
| 216 io_task_runner_(io_task_runner), | 216 io_task_runner_(io_task_runner), |
| 217 file_task_runner_(file_task_runner), | 217 file_task_runner_(file_task_runner), |
| 218 is_filesystem_set_up_(false), | 218 is_filesystem_set_up_(false), |
| 219 is_filesystem_opened_(false), | 219 is_filesystem_opened_(false), |
| 220 sync_status_observers_(new ObserverList) { | 220 sync_status_observers_(new ObserverList) { |
| 221 } | 221 } |
| 222 | 222 |
| 223 CannedSyncableFileSystem::~CannedSyncableFileSystem() {} | 223 CannedSyncableFileSystem::~CannedSyncableFileSystem() {} |
| 224 | 224 |
| 225 void CannedSyncableFileSystem::SetUp() { | 225 void CannedSyncableFileSystem::SetUp(QuotaMode quota_mode) { |
| 226 ASSERT_FALSE(is_filesystem_set_up_); | 226 ASSERT_FALSE(is_filesystem_set_up_); |
| 227 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 227 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
| 228 | 228 |
| 229 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 229 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = |
| 230 new quota::MockSpecialStoragePolicy(); | 230 new quota::MockSpecialStoragePolicy(); |
| 231 | 231 |
| 232 quota_manager_ = new QuotaManager(false /* is_incognito */, | 232 if (quota_mode == QUOTA_ENABLED) { |
| 233 data_dir_.path(), | 233 quota_manager_ = new QuotaManager(false /* is_incognito */, |
| 234 io_task_runner_.get(), | 234 data_dir_.path(), |
| 235 base::MessageLoopProxy::current().get(), | 235 io_task_runner_.get(), |
| 236 storage_policy.get()); | 236 base::MessageLoopProxy::current().get(), |
| 237 storage_policy.get()); |
| 238 } |
| 237 | 239 |
| 238 std::vector<std::string> additional_allowed_schemes; | 240 std::vector<std::string> additional_allowed_schemes; |
| 239 additional_allowed_schemes.push_back(origin_.scheme()); | 241 additional_allowed_schemes.push_back(origin_.scheme()); |
| 240 fileapi::FileSystemOptions options( | 242 fileapi::FileSystemOptions options( |
| 241 fileapi::FileSystemOptions::PROFILE_MODE_NORMAL, | 243 fileapi::FileSystemOptions::PROFILE_MODE_NORMAL, |
| 242 additional_allowed_schemes, | 244 additional_allowed_schemes, |
| 243 env_override_); | 245 env_override_); |
| 244 | 246 |
| 245 ScopedVector<fileapi::FileSystemBackend> additional_backends; | 247 ScopedVector<fileapi::FileSystemBackend> additional_backends; |
| 246 additional_backends.push_back(SyncFileSystemBackend::CreateForTesting()); | 248 additional_backends.push_back(SyncFileSystemBackend::CreateForTesting()); |
| 247 | 249 |
| 248 file_system_context_ = new FileSystemContext( | 250 file_system_context_ = new FileSystemContext( |
| 249 io_task_runner_.get(), | 251 io_task_runner_.get(), |
| 250 file_task_runner_.get(), | 252 file_task_runner_.get(), |
| 251 fileapi::ExternalMountPoints::CreateRefCounted().get(), | 253 fileapi::ExternalMountPoints::CreateRefCounted().get(), |
| 252 storage_policy.get(), | 254 storage_policy.get(), |
| 253 quota_manager_->proxy(), | 255 quota_manager_ ? quota_manager_->proxy() : NULL, |
| 254 additional_backends.Pass(), | 256 additional_backends.Pass(), |
| 255 data_dir_.path(), options); | 257 data_dir_.path(), options); |
| 256 | 258 |
| 257 is_filesystem_set_up_ = true; | 259 is_filesystem_set_up_ = true; |
| 258 } | 260 } |
| 259 | 261 |
| 260 void CannedSyncableFileSystem::TearDown() { | 262 void CannedSyncableFileSystem::TearDown() { |
| 261 quota_manager_ = NULL; | 263 quota_manager_ = NULL; |
| 262 file_system_context_ = NULL; | 264 file_system_context_ = NULL; |
| 263 | 265 |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 base::Bind(&WriteHelper::DidWrite, | 703 base::Bind(&WriteHelper::DidWrite, |
| 702 base::Owned(helper), callback)); | 704 base::Owned(helper), callback)); |
| 703 } | 705 } |
| 704 | 706 |
| 705 void CannedSyncableFileSystem::DoGetUsageAndQuota( | 707 void CannedSyncableFileSystem::DoGetUsageAndQuota( |
| 706 int64* usage, | 708 int64* usage, |
| 707 int64* quota, | 709 int64* quota, |
| 708 const quota::StatusCallback& callback) { | 710 const quota::StatusCallback& callback) { |
| 709 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 711 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 710 EXPECT_TRUE(is_filesystem_opened_); | 712 EXPECT_TRUE(is_filesystem_opened_); |
| 713 DCHECK(quota_manager_); |
| 711 quota_manager_->GetUsageAndQuota( | 714 quota_manager_->GetUsageAndQuota( |
| 712 origin_, storage_type(), | 715 origin_, storage_type(), |
| 713 base::Bind(&DidGetUsageAndQuota, callback, usage, quota)); | 716 base::Bind(&DidGetUsageAndQuota, callback, usage, quota)); |
| 714 } | 717 } |
| 715 | 718 |
| 716 void CannedSyncableFileSystem::DidOpenFileSystem( | 719 void CannedSyncableFileSystem::DidOpenFileSystem( |
| 717 base::SingleThreadTaskRunner* original_task_runner, | 720 base::SingleThreadTaskRunner* original_task_runner, |
| 718 const GURL& root, | 721 const GURL& root, |
| 719 const std::string& name, | 722 const std::string& name, |
| 720 File::Error result) { | 723 File::Error result) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 742 sync_status_ = status; | 745 sync_status_ = status; |
| 743 base::MessageLoop::current()->Quit(); | 746 base::MessageLoop::current()->Quit(); |
| 744 } | 747 } |
| 745 | 748 |
| 746 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { | 749 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { |
| 747 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 750 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 748 backend()->sync_context()->sync_status()->AddObserver(this); | 751 backend()->sync_context()->sync_status()->AddObserver(this); |
| 749 } | 752 } |
| 750 | 753 |
| 751 } // namespace sync_file_system | 754 } // namespace sync_file_system |
| OLD | NEW |