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

Side by Side Diff: sync/internal_api/internal_components_factory_impl.cc

Issue 10837231: sync: add InternalComponentsFactory::Switches to simplify passing switches to internal components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pass switches in test_profile_sync_service.cc Created 8 years, 4 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 (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 "sync/internal_api/public/internal_components_factory_impl.h" 5 #include "sync/internal_api/public/internal_components_factory_impl.h"
6 6
7 #include "sync/engine/backoff_delay_provider.h"
7 #include "sync/engine/syncer.h" 8 #include "sync/engine/syncer.h"
8 #include "sync/engine/sync_scheduler_impl.h" 9 #include "sync/engine/sync_scheduler_impl.h"
9 #include "sync/sessions/sync_session_context.h" 10 #include "sync/sessions/sync_session_context.h"
10 #include "sync/syncable/on_disk_directory_backing_store.h" 11 #include "sync/syncable/on_disk_directory_backing_store.h"
11 12
13 using base::TimeDelta;
14
12 namespace syncer { 15 namespace syncer {
13 16
14 InternalComponentsFactoryImpl::InternalComponentsFactoryImpl() { } 17 InternalComponentsFactoryImpl::InternalComponentsFactoryImpl(
18 const Switches& switches) : switches_(switches) {
19 }
20
15 InternalComponentsFactoryImpl::~InternalComponentsFactoryImpl() { } 21 InternalComponentsFactoryImpl::~InternalComponentsFactoryImpl() { }
16 22
17 scoped_ptr<SyncScheduler> InternalComponentsFactoryImpl::BuildScheduler( 23 scoped_ptr<SyncScheduler> InternalComponentsFactoryImpl::BuildScheduler(
18 const std::string& name, sessions::SyncSessionContext* context) { 24 const std::string& name, sessions::SyncSessionContext* context) {
25
26 scoped_ptr<BackoffDelayProvider> delay(BackoffDelayProvider::FromDefaults());
27
28 if (switches_.backoff_override == BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE)
rlarocque 2012/08/14 19:54:07 nit: Again, I think this would be nicer as an if/e
29 delay.reset(BackoffDelayProvider::WithShortInitialRetryOverride());
30
19 return scoped_ptr<SyncScheduler>( 31 return scoped_ptr<SyncScheduler>(
20 new SyncSchedulerImpl(name, context, new Syncer())); 32 new SyncSchedulerImpl(name, delay.release(), context, new Syncer()));
21 } 33 }
22 34
23 scoped_ptr<sessions::SyncSessionContext> 35 scoped_ptr<sessions::SyncSessionContext>
24 InternalComponentsFactoryImpl::BuildContext( 36 InternalComponentsFactoryImpl::BuildContext(
25 ServerConnectionManager* connection_manager, 37 ServerConnectionManager* connection_manager,
26 syncable::Directory* directory, 38 syncable::Directory* directory,
27 const std::vector<ModelSafeWorker*> workers, 39 const std::vector<ModelSafeWorker*> workers,
28 ExtensionsActivityMonitor* monitor, 40 ExtensionsActivityMonitor* monitor,
29 ThrottledDataTypeTracker* throttled_data_type_tracker, 41 ThrottledDataTypeTracker* throttled_data_type_tracker,
30 const std::vector<SyncEngineEventListener*>& listeners, 42 const std::vector<SyncEngineEventListener*>& listeners,
31 sessions::DebugInfoGetter* debug_info_getter, 43 sessions::DebugInfoGetter* debug_info_getter,
32 TrafficRecorder* traffic_recorder, 44 TrafficRecorder* traffic_recorder) {
33 bool keystore_encryption_enabled) {
34 return scoped_ptr<sessions::SyncSessionContext>( 45 return scoped_ptr<sessions::SyncSessionContext>(
35 new sessions::SyncSessionContext( 46 new sessions::SyncSessionContext(
36 connection_manager, directory, workers, monitor, 47 connection_manager, directory, workers, monitor,
37 throttled_data_type_tracker, listeners, debug_info_getter, 48 throttled_data_type_tracker, listeners, debug_info_getter,
38 traffic_recorder, 49 traffic_recorder,
39 keystore_encryption_enabled)); 50 switches_.encryption_method == ENCRYPTION_KEYSTORE));
40 } 51 }
41 52
42 scoped_ptr<syncable::DirectoryBackingStore> 53 scoped_ptr<syncable::DirectoryBackingStore>
43 InternalComponentsFactoryImpl::BuildDirectoryBackingStore( 54 InternalComponentsFactoryImpl::BuildDirectoryBackingStore(
44 const std::string& dir_name, const FilePath& backing_filepath) { 55 const std::string& dir_name, const FilePath& backing_filepath) {
45 return scoped_ptr<syncable::DirectoryBackingStore>( 56 return scoped_ptr<syncable::DirectoryBackingStore>(
46 new syncable::OnDiskDirectoryBackingStore(dir_name, backing_filepath)); 57 new syncable::OnDiskDirectoryBackingStore(dir_name, backing_filepath));
47 } 58 }
48 59
60 InternalComponentsFactory::Switches
61 InternalComponentsFactoryImpl::GetSwitches() const {
62 return switches_;
63 }
64
49 } // namespace syncer 65 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698