| OLD | NEW |
| 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/glue/sync_backend_host_impl.h" | 5 #include "chrome/browser/sync/glue/sync_backend_host_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/invalidation/invalidation_service.h" | 9 #include "chrome/browser/invalidation/invalidation_service.h" |
| 10 #include "chrome/browser/invalidation/invalidation_service_factory.h" | 10 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
| 11 #include "chrome/browser/network_time/network_time_tracker.h" | 11 #include "chrome/browser/network_time/network_time_tracker.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/sync/glue/sync_backend_host_core.h" | 13 #include "chrome/browser/sync/glue/sync_backend_host_core.h" |
| 14 #include "chrome/browser/sync/glue/sync_backend_registrar.h" | 14 #include "chrome/browser/sync/glue/sync_backend_registrar.h" |
| 15 #include "chrome/browser/sync/glue/sync_frontend.h" | 15 #include "chrome/browser/sync/glue/sync_frontend.h" |
| 16 #include "chrome/browser/sync/sync_prefs.h" | 16 #include "chrome/browser/sync/sync_prefs.h" |
| 17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
| 20 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 21 #include "sync/internal_api/public/base_transaction.h" | 21 #include "sync/internal_api/public/base_transaction.h" |
| 22 #include "sync/internal_api/public/http_bridge.h" | 22 #include "sync/internal_api/public/http_bridge.h" |
| 23 #include "sync/internal_api/public/http_post_provider_factory.h" |
| 23 #include "sync/internal_api/public/internal_components_factory.h" | 24 #include "sync/internal_api/public/internal_components_factory.h" |
| 24 #include "sync/internal_api/public/internal_components_factory_impl.h" | 25 #include "sync/internal_api/public/internal_components_factory_impl.h" |
| 25 #include "sync/internal_api/public/sync_manager.h" | 26 #include "sync/internal_api/public/sync_manager.h" |
| 26 #include "sync/internal_api/public/sync_manager_factory.h" | 27 #include "sync/internal_api/public/sync_manager_factory.h" |
| 27 #include "sync/internal_api/public/util/experiments.h" | 28 #include "sync/internal_api/public/util/experiments.h" |
| 28 #include "sync/internal_api/public/util/sync_string_conversions.h" | 29 #include "sync/internal_api/public/util/sync_string_conversions.h" |
| 29 | 30 |
| 30 // Helper macros to log with the syncer thread name; useful when there | 31 // Helper macros to log with the syncer thread name; useful when there |
| 31 // are multiple syncers involved. | 32 // are multiple syncers involved. |
| 32 | 33 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 void SyncBackendHostImpl::Initialize( | 72 void SyncBackendHostImpl::Initialize( |
| 72 SyncFrontend* frontend, | 73 SyncFrontend* frontend, |
| 73 scoped_ptr<base::Thread> sync_thread, | 74 scoped_ptr<base::Thread> sync_thread, |
| 74 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 75 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 75 const GURL& sync_service_url, | 76 const GURL& sync_service_url, |
| 76 const syncer::SyncCredentials& credentials, | 77 const syncer::SyncCredentials& credentials, |
| 77 bool delete_sync_data_folder, | 78 bool delete_sync_data_folder, |
| 78 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, | 79 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, |
| 79 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler, | 80 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler, |
| 80 syncer::ReportUnrecoverableErrorFunction | 81 syncer::ReportUnrecoverableErrorFunction |
| 81 report_unrecoverable_error_function) { | 82 report_unrecoverable_error_function, |
| 83 scoped_ptr<syncer::HttpPostProviderFactory> http_post_provider_factory) { |
| 82 registrar_.reset(new browser_sync::SyncBackendRegistrar(name_, | 84 registrar_.reset(new browser_sync::SyncBackendRegistrar(name_, |
| 83 profile_, | 85 profile_, |
| 84 sync_thread.Pass())); | 86 sync_thread.Pass())); |
| 85 CHECK(registrar_->sync_thread()); | 87 CHECK(registrar_->sync_thread()); |
| 86 | 88 |
| 87 frontend_ = frontend; | 89 frontend_ = frontend; |
| 88 DCHECK(frontend); | 90 DCHECK(frontend); |
| 89 | 91 |
| 90 syncer::ModelSafeRoutingInfo routing_info; | 92 syncer::ModelSafeRoutingInfo routing_info; |
| 91 std::vector<syncer::ModelSafeWorker*> workers; | 93 std::vector<syncer::ModelSafeWorker*> workers; |
| 92 registrar_->GetModelSafeRoutingInfo(&routing_info); | 94 registrar_->GetModelSafeRoutingInfo(&routing_info); |
| 93 registrar_->GetWorkers(&workers); | 95 registrar_->GetWorkers(&workers); |
| 94 | 96 |
| 95 InternalComponentsFactory::Switches factory_switches = { | 97 InternalComponentsFactory::Switches factory_switches = { |
| 96 InternalComponentsFactory::ENCRYPTION_KEYSTORE, | 98 InternalComponentsFactory::ENCRYPTION_KEYSTORE, |
| 97 InternalComponentsFactory::BACKOFF_NORMAL | 99 InternalComponentsFactory::BACKOFF_NORMAL |
| 98 }; | 100 }; |
| 99 | 101 |
| 100 CommandLine* cl = CommandLine::ForCurrentProcess(); | 102 CommandLine* cl = CommandLine::ForCurrentProcess(); |
| 101 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) { | 103 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) { |
| 102 factory_switches.backoff_override = | 104 factory_switches.backoff_override = |
| 103 InternalComponentsFactory::BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE; | 105 InternalComponentsFactory::BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE; |
| 104 } | 106 } |
| 105 if (cl->HasSwitch(switches::kSyncEnableGetUpdateAvoidance)) { | 107 if (cl->HasSwitch(switches::kSyncEnableGetUpdateAvoidance)) { |
| 106 factory_switches.pre_commit_updates_policy = | 108 factory_switches.pre_commit_updates_policy = |
| 107 InternalComponentsFactory::FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE; | 109 InternalComponentsFactory::FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE; |
| 108 } | 110 } |
| 109 | 111 |
| 112 http_post_provider_factory->RegisterCancelationSignal( |
| 113 core_->GetRequestContextCancelationSignal()); |
| 114 |
| 110 scoped_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions( | 115 scoped_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions( |
| 111 registrar_->sync_thread()->message_loop(), | 116 registrar_->sync_thread()->message_loop(), |
| 112 registrar_.get(), | 117 registrar_.get(), |
| 113 routing_info, | 118 routing_info, |
| 114 workers, | 119 workers, |
| 115 extensions_activity_monitor_.GetExtensionsActivity(), | 120 extensions_activity_monitor_.GetExtensionsActivity(), |
| 116 event_handler, | 121 event_handler, |
| 117 sync_service_url, | 122 sync_service_url, |
| 118 scoped_ptr<syncer::HttpPostProviderFactory>( | 123 http_post_provider_factory.Pass(), |
| 119 new syncer::HttpBridgeFactory( | |
| 120 make_scoped_refptr(profile_->GetRequestContext()), | |
| 121 NetworkTimeTracker::BuildNotifierUpdateCallback(), | |
| 122 core_->GetRequestContextCancelationSignal())), | |
| 123 credentials, | 124 credentials, |
| 124 invalidator_->GetInvalidatorClientId(), | 125 invalidator_->GetInvalidatorClientId(), |
| 125 sync_manager_factory.Pass(), | 126 sync_manager_factory.Pass(), |
| 126 delete_sync_data_folder, | 127 delete_sync_data_folder, |
| 127 sync_prefs_->GetEncryptionBootstrapToken(), | 128 sync_prefs_->GetEncryptionBootstrapToken(), |
| 128 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), | 129 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), |
| 129 scoped_ptr<InternalComponentsFactory>( | 130 scoped_ptr<InternalComponentsFactory>( |
| 130 new syncer::InternalComponentsFactoryImpl(factory_switches)).Pass(), | 131 new syncer::InternalComponentsFactoryImpl(factory_switches)).Pass(), |
| 131 unrecoverable_error_handler.Pass(), | 132 unrecoverable_error_handler.Pass(), |
| 132 report_unrecoverable_error_function)); | 133 report_unrecoverable_error_function)); |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() { | 755 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() { |
| 755 return registrar_->sync_thread()->message_loop(); | 756 return registrar_->sync_thread()->message_loop(); |
| 756 } | 757 } |
| 757 | 758 |
| 758 } // namespace browser_sync | 759 } // namespace browser_sync |
| 759 | 760 |
| 760 #undef SDVLOG | 761 #undef SDVLOG |
| 761 | 762 |
| 762 #undef SLOG | 763 #undef SLOG |
| 763 | 764 |
| OLD | NEW |