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

Side by Side Diff: chrome/browser/sync_file_system/local/local_file_sync_service.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/local_file_sync_service.h" 5 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 void LocalFileSyncService::OriginChangeMap::SetOriginEnabled( 89 void LocalFileSyncService::OriginChangeMap::SetOriginEnabled(
90 const GURL& origin, bool enabled) { 90 const GURL& origin, bool enabled) {
91 if (enabled) 91 if (enabled)
92 disabled_origins_.erase(origin); 92 disabled_origins_.erase(origin);
93 else 93 else
94 disabled_origins_.insert(origin); 94 disabled_origins_.insert(origin);
95 } 95 }
96 96
97 // LocalFileSyncService ------------------------------------------------------- 97 // LocalFileSyncService -------------------------------------------------------
98 98
99 LocalFileSyncService::LocalFileSyncService(Profile* profile) 99 scoped_ptr<LocalFileSyncService> LocalFileSyncService::Create(
100 : profile_(profile), 100 Profile* profile) {
101 sync_context_(new LocalFileSyncContext( 101 return make_scoped_ptr(new LocalFileSyncService(profile, NULL));
102 profile_->GetPath(), 102 }
103 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get(), 103
104 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO) 104 scoped_ptr<LocalFileSyncService> LocalFileSyncService::CreateForTesting(
105 .get())), 105 Profile* profile,
106 local_change_processor_(NULL) { 106 leveldb::Env* env) {
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 107 return make_scoped_ptr(new LocalFileSyncService(profile, env));
108 sync_context_->AddOriginChangeObserver(this);
109 } 108 }
110 109
111 LocalFileSyncService::~LocalFileSyncService() { 110 LocalFileSyncService::~LocalFileSyncService() {
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 111 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
113 } 112 }
114 113
115 void LocalFileSyncService::Shutdown() { 114 void LocalFileSyncService::Shutdown() {
116 sync_context_->RemoveOriginChangeObserver(this); 115 sync_context_->RemoveOriginChangeObserver(this);
117 sync_context_->ShutdownOnUIThread(); 116 sync_context_->ShutdownOnUIThread();
118 profile_ = NULL; 117 profile_ = NULL;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 FOR_EACH_OBSERVER(Observer, change_observers_, 312 FOR_EACH_OBSERVER(Observer, change_observers_,
314 OnLocalChangeAvailable(num_changes)); 313 OnLocalChangeAvailable(num_changes));
315 } 314 }
316 315
317 void LocalFileSyncService::SetOriginEnabled(const GURL& origin, bool enabled) { 316 void LocalFileSyncService::SetOriginEnabled(const GURL& origin, bool enabled) {
318 if (!ContainsKey(origin_to_contexts_, origin)) 317 if (!ContainsKey(origin_to_contexts_, origin))
319 return; 318 return;
320 origin_change_map_.SetOriginEnabled(origin, enabled); 319 origin_change_map_.SetOriginEnabled(origin, enabled);
321 } 320 }
322 321
322 LocalFileSyncService::LocalFileSyncService(Profile* profile,
323 leveldb::Env* env_override)
324 : profile_(profile),
325 sync_context_(new LocalFileSyncContext(
326 profile_->GetPath(),
327 env_override,
328 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get(),
329 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)
330 .get())),
331 local_change_processor_(NULL) {
332 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
333 sync_context_->AddOriginChangeObserver(this);
334 }
335
323 void LocalFileSyncService::DidInitializeFileSystemContext( 336 void LocalFileSyncService::DidInitializeFileSystemContext(
324 const GURL& app_origin, 337 const GURL& app_origin,
325 fileapi::FileSystemContext* file_system_context, 338 fileapi::FileSystemContext* file_system_context,
326 const SyncStatusCallback& callback, 339 const SyncStatusCallback& callback,
327 SyncStatusCode status) { 340 SyncStatusCode status) {
328 if (status != SYNC_STATUS_OK) { 341 if (status != SYNC_STATUS_OK) {
329 callback.Run(status); 342 callback.Run(status);
330 return; 343 return;
331 } 344 }
332 DCHECK(file_system_context); 345 DCHECK(file_system_context);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 481
469 LocalChangeProcessor* LocalFileSyncService::GetLocalChangeProcessor( 482 LocalChangeProcessor* LocalFileSyncService::GetLocalChangeProcessor(
470 const FileSystemURL& url) { 483 const FileSystemURL& url) {
471 if (!get_local_change_processor_.is_null()) 484 if (!get_local_change_processor_.is_null())
472 return get_local_change_processor_.Run(url.origin()); 485 return get_local_change_processor_.Run(url.origin());
473 DCHECK(local_change_processor_); 486 DCHECK(local_change_processor_);
474 return local_change_processor_; 487 return local_change_processor_;
475 } 488 }
476 489
477 } // namespace sync_file_system 490 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698