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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host_impl.cc

Issue 1410013008: [Sync] Remove some http-related chrome deps from SyncBackendHostImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 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 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 "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/signin/chrome_signin_client_factory.h"
15 #include "chrome/browser/sync/glue/sync_backend_host_core.h" 13 #include "chrome/browser/sync/glue/sync_backend_host_core.h"
16 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
17 #include "components/invalidation/public/invalidation_service.h" 15 #include "components/invalidation/public/invalidation_service.h"
18 #include "components/invalidation/public/object_id_invalidation_map.h" 16 #include "components/invalidation/public/object_id_invalidation_map.h"
19 #include "components/network_time/network_time_tracker.h"
20 #include "components/signin/core/browser/signin_client.h" 17 #include "components/signin/core/browser/signin_client.h"
21 #include "components/sync_driver/glue/sync_backend_registrar.h" 18 #include "components/sync_driver/glue/sync_backend_registrar.h"
22 #include "components/sync_driver/invalidation_helper.h" 19 #include "components/sync_driver/invalidation_helper.h"
23 #include "components/sync_driver/sync_client.h" 20 #include "components/sync_driver/sync_client.h"
24 #include "components/sync_driver/sync_driver_switches.h" 21 #include "components/sync_driver/sync_driver_switches.h"
25 #include "components/sync_driver/sync_frontend.h" 22 #include "components/sync_driver/sync_frontend.h"
26 #include "components/sync_driver/sync_prefs.h" 23 #include "components/sync_driver/sync_prefs.h"
27 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
28 #include "content/public/browser/notification_source.h" 25 #include "content/public/browser/notification_source.h"
29 #include "sync/internal_api/public/activation_context.h" 26 #include "sync/internal_api/public/activation_context.h"
30 #include "sync/internal_api/public/base_transaction.h" 27 #include "sync/internal_api/public/base_transaction.h"
31 #include "sync/internal_api/public/events/protocol_event.h" 28 #include "sync/internal_api/public/events/protocol_event.h"
32 #include "sync/internal_api/public/http_bridge.h" 29 #include "sync/internal_api/public/http_bridge.h"
33 #include "sync/internal_api/public/internal_components_factory.h" 30 #include "sync/internal_api/public/internal_components_factory.h"
34 #include "sync/internal_api/public/internal_components_factory_impl.h" 31 #include "sync/internal_api/public/internal_components_factory_impl.h"
35 #include "sync/internal_api/public/network_resources.h"
36 #include "sync/internal_api/public/sync_manager.h" 32 #include "sync/internal_api/public/sync_manager.h"
37 #include "sync/internal_api/public/sync_manager_factory.h" 33 #include "sync/internal_api/public/sync_manager_factory.h"
38 #include "sync/internal_api/public/util/experiments.h" 34 #include "sync/internal_api/public/util/experiments.h"
39 #include "sync/internal_api/public/util/sync_string_conversions.h" 35 #include "sync/internal_api/public/util/sync_string_conversions.h"
40 36
41 // Helper macros to log with the syncer thread name; useful when there 37 // Helper macros to log with the syncer thread name; useful when there
42 // are multiple syncers involved. 38 // are multiple syncers involved.
43 39
44 #define SLOG(severity) LOG(severity) << name_ << ": " 40 #define SLOG(severity) LOG(severity) << name_ << ": "
45 41
46 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " 42 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": "
47 43
48 using syncer::InternalComponentsFactory; 44 using syncer::InternalComponentsFactory;
49 45
50 namespace browser_sync { 46 namespace browser_sync {
51 47
52 namespace {
53
54 void UpdateNetworkTimeOnUIThread(base::Time network_time,
55 base::TimeDelta resolution,
56 base::TimeDelta latency,
57 base::TimeTicks post_time) {
58 g_browser_process->network_time_tracker()->UpdateNetworkTime(
59 network_time, resolution, latency, post_time);
60 }
61
62 void UpdateNetworkTime(
63 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
64 const base::Time& network_time,
65 const base::TimeDelta& resolution,
66 const base::TimeDelta& latency) {
67 ui_thread->PostTask(FROM_HERE,
68 base::Bind(&UpdateNetworkTimeOnUIThread, network_time,
69 resolution, latency, base::TimeTicks::Now()));
70 }
71
72 } // namespace
73
74 SyncBackendHostImpl::SyncBackendHostImpl( 48 SyncBackendHostImpl::SyncBackendHostImpl(
75 const std::string& name, 49 const std::string& name,
76 Profile* profile, 50 Profile* profile,
77 sync_driver::SyncClient* sync_client, 51 sync_driver::SyncClient* sync_client,
78 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, 52 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
79 invalidation::InvalidationService* invalidator, 53 invalidation::InvalidationService* invalidator,
80 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, 54 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs,
81 const base::FilePath& sync_folder) 55 const base::FilePath& sync_folder)
82 : frontend_loop_(base::MessageLoop::current()), 56 : frontend_loop_(base::MessageLoop::current()),
83 profile_(profile), 57 profile_(profile),
(...skipping 26 matching lines...) Expand all
110 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread, 84 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread,
111 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 85 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
112 const GURL& sync_service_url, 86 const GURL& sync_service_url,
113 const std::string& sync_user_agent, 87 const std::string& sync_user_agent,
114 const syncer::SyncCredentials& credentials, 88 const syncer::SyncCredentials& credentials,
115 bool delete_sync_data_folder, 89 bool delete_sync_data_folder,
116 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, 90 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory,
117 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& 91 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>&
118 unrecoverable_error_handler, 92 unrecoverable_error_handler,
119 const base::Closure& report_unrecoverable_error_function, 93 const base::Closure& report_unrecoverable_error_function,
120 syncer::NetworkResources* network_resources, 94 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter,
121 scoped_ptr<syncer::SyncEncryptionHandler::NigoriState> saved_nigori_state) { 95 scoped_ptr<syncer::SyncEncryptionHandler::NigoriState> saved_nigori_state) {
122 registrar_.reset(new browser_sync::SyncBackendRegistrar( 96 registrar_.reset(new browser_sync::SyncBackendRegistrar(
123 name_, sync_client_, sync_thread.Pass(), ui_thread_, db_thread, 97 name_, sync_client_, sync_thread.Pass(), ui_thread_, db_thread,
124 file_thread)); 98 file_thread));
125 CHECK(registrar_->sync_thread()); 99 CHECK(registrar_->sync_thread());
126 100
127 frontend_ = frontend; 101 frontend_ = frontend;
128 DCHECK(frontend); 102 DCHECK(frontend);
129 103
130 syncer::ModelSafeRoutingInfo routing_info; 104 syncer::ModelSafeRoutingInfo routing_info;
(...skipping 20 matching lines...) Expand all
151 if (cl->HasSwitch(switches::kSyncEnableClearDataOnPassphraseEncryption)) 125 if (cl->HasSwitch(switches::kSyncEnableClearDataOnPassphraseEncryption))
152 clear_data_option = syncer::PASSPHRASE_TRANSITION_CLEAR_DATA; 126 clear_data_option = syncer::PASSPHRASE_TRANSITION_CLEAR_DATA;
153 127
154 std::map<syncer::ModelType, int64> invalidation_versions; 128 std::map<syncer::ModelType, int64> invalidation_versions;
155 sync_prefs_->GetInvalidationVersions(&invalidation_versions); 129 sync_prefs_->GetInvalidationVersions(&invalidation_versions);
156 130
157 scoped_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions( 131 scoped_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions(
158 registrar_->sync_thread()->message_loop(), registrar_.get(), routing_info, 132 registrar_->sync_thread()->message_loop(), registrar_.get(), routing_info,
159 workers, sync_client_->GetExtensionsActivity(), event_handler, 133 workers, sync_client_->GetExtensionsActivity(), event_handler,
160 sync_service_url, sync_user_agent, 134 sync_service_url, sync_user_agent,
161 network_resources->GetHttpPostProviderFactory( 135 http_post_provider_factory_getter.Run(
162 make_scoped_refptr(profile_->GetRequestContext()),
163 base::Bind(&UpdateNetworkTime, ui_thread_),
164 core_->GetRequestContextCancelationSignal()), 136 core_->GetRequestContextCancelationSignal()),
165 credentials, invalidator_ ? invalidator_->GetInvalidatorClientId() : "", 137 credentials, invalidator_ ? invalidator_->GetInvalidatorClientId() : "",
166 sync_manager_factory.Pass(), delete_sync_data_folder, 138 sync_manager_factory.Pass(), delete_sync_data_folder,
167 sync_prefs_->GetEncryptionBootstrapToken(), 139 sync_prefs_->GetEncryptionBootstrapToken(),
168 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), 140 sync_prefs_->GetKeystoreEncryptionBootstrapToken(),
169 scoped_ptr<InternalComponentsFactory>( 141 scoped_ptr<InternalComponentsFactory>(
170 new syncer::InternalComponentsFactoryImpl(factory_switches)) 142 new syncer::InternalComponentsFactoryImpl(factory_switches))
171 .Pass(), 143 .Pass(),
172 unrecoverable_error_handler, report_unrecoverable_error_function, 144 unrecoverable_error_handler, report_unrecoverable_error_function,
173 saved_nigori_state.Pass(), clear_data_option, invalidation_versions)); 145 saved_nigori_state.Pass(), clear_data_option, invalidation_versions));
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 const syncer::SyncManager::ClearServerDataCallback& frontend_callback) { 883 const syncer::SyncManager::ClearServerDataCallback& frontend_callback) {
912 DCHECK(ui_thread_->BelongsToCurrentThread()); 884 DCHECK(ui_thread_->BelongsToCurrentThread());
913 frontend_callback.Run(); 885 frontend_callback.Run();
914 } 886 }
915 887
916 } // namespace browser_sync 888 } // namespace browser_sync
917 889
918 #undef SDVLOG 890 #undef SDVLOG
919 891
920 #undef SLOG 892 #undef SLOG
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host_impl.h ('k') | chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698