engine_components_factory_impl.cc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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
  3. // found in the LICENSE file.
  4. #include "components/sync/engine/engine_components_factory_impl.h"
  5. #include <map>
  6. #include <utility>
  7. #include "components/sync/engine/backoff_delay_provider.h"
  8. #include "components/sync/engine/cycle/sync_cycle_context.h"
  9. #include "components/sync/engine/sync_scheduler_impl.h"
  10. #include "components/sync/engine/syncer.h"
  11. namespace syncer {
  12. EngineComponentsFactoryImpl::EngineComponentsFactoryImpl(
  13. const Switches& switches)
  14. : switches_(switches) {}
  15. std::unique_ptr<SyncScheduler> EngineComponentsFactoryImpl::BuildScheduler(
  16. const std::string& name,
  17. SyncCycleContext* context,
  18. CancelationSignal* cancelation_signal,
  19. bool ignore_auth_credentials) {
  20. std::unique_ptr<BackoffDelayProvider> delay =
  21. (switches_.backoff_override == BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE)
  22. ? BackoffDelayProvider::WithShortInitialRetryOverride()
  23. : BackoffDelayProvider::FromDefaults();
  24. std::unique_ptr<SyncSchedulerImpl> scheduler =
  25. std::make_unique<SyncSchedulerImpl>(
  26. name, std::move(delay), context,
  27. std::make_unique<Syncer>(cancelation_signal),
  28. ignore_auth_credentials);
  29. if (switches_.force_short_nudge_delay_for_test) {
  30. scheduler->ForceShortNudgeDelayForTest();
  31. }
  32. return std::move(scheduler);
  33. }
  34. std::unique_ptr<SyncCycleContext> EngineComponentsFactoryImpl::BuildContext(
  35. ServerConnectionManager* connection_manager,
  36. ExtensionsActivity* extensions_activity,
  37. const std::vector<SyncEngineEventListener*>& listeners,
  38. DebugInfoGetter* debug_info_getter,
  39. ModelTypeRegistry* model_type_registry,
  40. const std::string& invalidation_client_id,
  41. const std::string& cache_guid,
  42. const std::string& store_birthday,
  43. const std::string& bag_of_chips,
  44. base::TimeDelta poll_interval) {
  45. return std::make_unique<SyncCycleContext>(
  46. connection_manager, extensions_activity, listeners, debug_info_getter,
  47. model_type_registry, invalidation_client_id, cache_guid, store_birthday,
  48. bag_of_chips, poll_interval);
  49. }
  50. } // namespace syncer