Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: chrome/browser/sync_file_system/local/canned_syncable_file_system.cc

Issue 145693005: [FileAPI] Replace default leveldb::Env with leveldb::MemEnv in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 base::RunLoop run_loop; 198 base::RunLoop run_loop;
199 runner->PostTaskAndReply( 199 runner->PostTaskAndReply(
200 FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure()); 200 FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure());
201 run_loop.Run(); 201 run_loop.Run();
202 } 202 }
203 203
204 } // namespace 204 } // namespace
205 205
206 CannedSyncableFileSystem::CannedSyncableFileSystem( 206 CannedSyncableFileSystem::CannedSyncableFileSystem(
207 const GURL& origin, 207 const GURL& origin,
208 leveldb::Env* env_override,
208 base::SingleThreadTaskRunner* io_task_runner, 209 base::SingleThreadTaskRunner* io_task_runner,
209 base::SingleThreadTaskRunner* file_task_runner) 210 base::SingleThreadTaskRunner* file_task_runner)
210 : origin_(origin), 211 : origin_(origin),
211 type_(fileapi::kFileSystemTypeSyncable), 212 type_(fileapi::kFileSystemTypeSyncable),
212 result_(base::File::FILE_OK), 213 result_(base::File::FILE_OK),
213 sync_status_(sync_file_system::SYNC_STATUS_OK), 214 sync_status_(sync_file_system::SYNC_STATUS_OK),
215 env_override_(env_override),
214 io_task_runner_(io_task_runner), 216 io_task_runner_(io_task_runner),
215 file_task_runner_(file_task_runner), 217 file_task_runner_(file_task_runner),
216 is_filesystem_set_up_(false), 218 is_filesystem_set_up_(false),
217 is_filesystem_opened_(false), 219 is_filesystem_opened_(false),
218 sync_status_observers_(new ObserverList) { 220 sync_status_observers_(new ObserverList) {
219 } 221 }
220 222
221 CannedSyncableFileSystem::~CannedSyncableFileSystem() {} 223 CannedSyncableFileSystem::~CannedSyncableFileSystem() {}
222 224
223 void CannedSyncableFileSystem::SetUp() { 225 void CannedSyncableFileSystem::SetUp() {
224 ASSERT_FALSE(is_filesystem_set_up_); 226 ASSERT_FALSE(is_filesystem_set_up_);
225 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); 227 ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
226 228
227 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = 229 scoped_refptr<quota::SpecialStoragePolicy> storage_policy =
228 new quota::MockSpecialStoragePolicy(); 230 new quota::MockSpecialStoragePolicy();
229 231
230 quota_manager_ = new QuotaManager(false /* is_incognito */, 232 quota_manager_ = new QuotaManager(false /* is_incognito */,
231 data_dir_.path(), 233 data_dir_.path(),
232 io_task_runner_.get(), 234 io_task_runner_.get(),
233 base::MessageLoopProxy::current().get(), 235 base::MessageLoopProxy::current().get(),
234 storage_policy.get()); 236 storage_policy.get());
235 237
236 std::vector<std::string> additional_allowed_schemes; 238 std::vector<std::string> additional_allowed_schemes;
237 additional_allowed_schemes.push_back(origin_.scheme()); 239 additional_allowed_schemes.push_back(origin_.scheme());
238 fileapi::FileSystemOptions options( 240 fileapi::FileSystemOptions options(
239 fileapi::FileSystemOptions::PROFILE_MODE_NORMAL, 241 fileapi::FileSystemOptions::PROFILE_MODE_NORMAL,
240 additional_allowed_schemes); 242 additional_allowed_schemes,
243 env_override_);
241 244
242 ScopedVector<fileapi::FileSystemBackend> additional_backends; 245 ScopedVector<fileapi::FileSystemBackend> additional_backends;
243 additional_backends.push_back(SyncFileSystemBackend::CreateForTesting()); 246 additional_backends.push_back(SyncFileSystemBackend::CreateForTesting());
244 247
245 file_system_context_ = new FileSystemContext( 248 file_system_context_ = new FileSystemContext(
246 io_task_runner_.get(), 249 io_task_runner_.get(),
247 file_task_runner_.get(), 250 file_task_runner_.get(),
248 fileapi::ExternalMountPoints::CreateRefCounted().get(), 251 fileapi::ExternalMountPoints::CreateRefCounted().get(),
249 storage_policy.get(), 252 storage_policy.get(),
250 quota_manager_->proxy(), 253 quota_manager_->proxy(),
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 sync_status_ = status; 742 sync_status_ = status;
740 base::MessageLoop::current()->Quit(); 743 base::MessageLoop::current()->Quit();
741 } 744 }
742 745
743 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { 746 void CannedSyncableFileSystem::InitializeSyncStatusObserver() {
744 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); 747 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread());
745 backend()->sync_context()->sync_status()->AddObserver(this); 748 backend()->sync_context()->sync_status()->AddObserver(this);
746 } 749 }
747 750
748 } // namespace sync_file_system 751 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698