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

Side by Side Diff: components/sync/engine/engine_components_factory_impl.cc

Issue 2494633005: Revert of [sync] "TwoClientBookmarksSyncTest.Sanity" is flaky (Closed)
Patch Set: Created 4 years, 1 month 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
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 "components/sync/engine/engine_components_factory_impl.h" 5 #include "components/sync/engine/engine_components_factory_impl.h"
6 6
7 #include "base/memory/ptr_util.h"
8 #include "components/sync/engine_impl/backoff_delay_provider.h" 7 #include "components/sync/engine_impl/backoff_delay_provider.h"
9 #include "components/sync/engine_impl/cycle/sync_cycle_context.h" 8 #include "components/sync/engine_impl/cycle/sync_cycle_context.h"
10 #include "components/sync/engine_impl/sync_scheduler_impl.h" 9 #include "components/sync/engine_impl/sync_scheduler_impl.h"
11 #include "components/sync/engine_impl/syncer.h" 10 #include "components/sync/engine_impl/syncer.h"
12 #include "components/sync/syncable/on_disk_directory_backing_store.h" 11 #include "components/sync/syncable/on_disk_directory_backing_store.h"
13 12
14 using base::TimeDelta; 13 using base::TimeDelta;
15 14
16 namespace {
17 const int kShortNudgeDelayDurationMS = 1;
18 }
19
20 namespace syncer { 15 namespace syncer {
21 16
22 EngineComponentsFactoryImpl::EngineComponentsFactoryImpl( 17 EngineComponentsFactoryImpl::EngineComponentsFactoryImpl(
23 const Switches& switches) 18 const Switches& switches)
24 : switches_(switches) {} 19 : switches_(switches) {}
25 20
26 EngineComponentsFactoryImpl::~EngineComponentsFactoryImpl() {} 21 EngineComponentsFactoryImpl::~EngineComponentsFactoryImpl() {}
27 22
28 std::unique_ptr<SyncScheduler> EngineComponentsFactoryImpl::BuildScheduler( 23 std::unique_ptr<SyncScheduler> EngineComponentsFactoryImpl::BuildScheduler(
29 const std::string& name, 24 const std::string& name,
30 SyncCycleContext* context, 25 SyncCycleContext* context,
31 CancelationSignal* cancelation_signal) { 26 CancelationSignal* cancelation_signal) {
32 std::unique_ptr<BackoffDelayProvider> delay( 27 std::unique_ptr<BackoffDelayProvider> delay(
33 BackoffDelayProvider::FromDefaults()); 28 BackoffDelayProvider::FromDefaults());
34 29
35 if (switches_.backoff_override == BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE) { 30 if (switches_.backoff_override == BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE)
36 delay.reset(BackoffDelayProvider::WithShortInitialRetryOverride()); 31 delay.reset(BackoffDelayProvider::WithShortInitialRetryOverride());
37 }
38 32
39 std::unique_ptr<SyncSchedulerImpl> scheduler = 33 return std::unique_ptr<SyncScheduler>(new SyncSchedulerImpl(
40 base::MakeUnique<SyncSchedulerImpl>(name, delay.release(), context, 34 name, delay.release(), context, new Syncer(cancelation_signal)));
41 new Syncer(cancelation_signal));
42 if (switches_.nudge_delay == NudgeDelay::SHORT_NUDGE_DELAY) {
43 // Set the default nudge delay to 0 because the default is used as a floor
44 // for override values, and we don't want the below override to be ignored.
45 scheduler->SetDefaultNudgeDelay(TimeDelta::FromMilliseconds(0));
46 // Only protocol types can have their delay customized.
47 ModelTypeSet protocol_types = syncer::ProtocolTypes();
48 std::map<ModelType, base::TimeDelta> nudge_delays;
49 for (ModelTypeSet::Iterator it = protocol_types.First(); it.Good();
50 it.Inc()) {
51 nudge_delays[it.Get()] =
52 TimeDelta::FromMilliseconds(kShortNudgeDelayDurationMS);
53 }
54 scheduler->OnReceivedCustomNudgeDelays(nudge_delays);
55 }
56 return std::move(scheduler);
57 } 35 }
58 36
59 std::unique_ptr<SyncCycleContext> EngineComponentsFactoryImpl::BuildContext( 37 std::unique_ptr<SyncCycleContext> EngineComponentsFactoryImpl::BuildContext(
60 ServerConnectionManager* connection_manager, 38 ServerConnectionManager* connection_manager,
61 syncable::Directory* directory, 39 syncable::Directory* directory,
62 ExtensionsActivity* extensions_activity, 40 ExtensionsActivity* extensions_activity,
63 const std::vector<SyncEngineEventListener*>& listeners, 41 const std::vector<SyncEngineEventListener*>& listeners,
64 DebugInfoGetter* debug_info_getter, 42 DebugInfoGetter* debug_info_getter,
65 ModelTypeRegistry* model_type_registry, 43 ModelTypeRegistry* model_type_registry,
66 const std::string& invalidation_client_id) { 44 const std::string& invalidation_client_id) {
(...skipping 19 matching lines...) Expand all
86 return std::unique_ptr<syncable::DirectoryBackingStore>(); 64 return std::unique_ptr<syncable::DirectoryBackingStore>();
87 } 65 }
88 } 66 }
89 67
90 EngineComponentsFactory::Switches EngineComponentsFactoryImpl::GetSwitches() 68 EngineComponentsFactory::Switches EngineComponentsFactoryImpl::GetSwitches()
91 const { 69 const {
92 return switches_; 70 return switches_;
93 } 71 }
94 72
95 } // namespace syncer 73 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine/engine_components_factory.h ('k') | components/sync/engine_impl/sync_scheduler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698