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 "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/signin/chrome_signin_client_factory.h" | |
12 #include "chrome/browser/sync/glue/sync_backend_host_core.h" | 13 #include "chrome/browser/sync/glue/sync_backend_host_core.h" |
13 #include "chrome/browser/sync/glue/sync_backend_registrar.h" | 14 #include "chrome/browser/sync/glue/sync_backend_registrar.h" |
14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
15 #include "components/invalidation/invalidation_service.h" | 16 #include "components/invalidation/invalidation_service.h" |
16 #include "components/network_time/network_time_tracker.h" | 17 #include "components/network_time/network_time_tracker.h" |
18 #include "components/signin/core/browser/signin_client.h" | |
17 #include "components/sync_driver/sync_frontend.h" | 19 #include "components/sync_driver/sync_frontend.h" |
18 #include "components/sync_driver/sync_prefs.h" | 20 #include "components/sync_driver/sync_prefs.h" |
19 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/notification_details.h" | 22 #include "content/public/browser/notification_details.h" |
21 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
22 #include "sync/internal_api/public/base_transaction.h" | 24 #include "sync/internal_api/public/base_transaction.h" |
23 #include "sync/internal_api/public/events/protocol_event.h" | 25 #include "sync/internal_api/public/events/protocol_event.h" |
24 #include "sync/internal_api/public/http_bridge.h" | 26 #include "sync/internal_api/public/http_bridge.h" |
25 #include "sync/internal_api/public/internal_components_factory.h" | 27 #include "sync/internal_api/public/internal_components_factory.h" |
26 #include "sync/internal_api/public/internal_components_factory_impl.h" | 28 #include "sync/internal_api/public/internal_components_factory_impl.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 CommandLine* cl = CommandLine::ForCurrentProcess(); | 127 CommandLine* cl = CommandLine::ForCurrentProcess(); |
126 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) { | 128 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) { |
127 factory_switches.backoff_override = | 129 factory_switches.backoff_override = |
128 InternalComponentsFactory::BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE; | 130 InternalComponentsFactory::BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE; |
129 } | 131 } |
130 if (cl->HasSwitch(switches::kSyncEnableGetUpdateAvoidance)) { | 132 if (cl->HasSwitch(switches::kSyncEnableGetUpdateAvoidance)) { |
131 factory_switches.pre_commit_updates_policy = | 133 factory_switches.pre_commit_updates_policy = |
132 InternalComponentsFactory::FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE; | 134 InternalComponentsFactory::FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE; |
133 } | 135 } |
134 | 136 |
137 SigninClient* signin_client = | |
138 ChromeSigninClientFactory::GetForProfile(profile_); | |
139 std::string signin_scoped_device_id = | |
140 signin_client->GetSigninScopedDeviceId(); | |
rlarocque
2014/07/16 00:44:31
Is this guaranteed to succeed? If it can fail, wh
pavely
2014/07/16 21:35:59
profile_ is always valid, it is dereferenced in mu
rlarocque
2014/07/16 21:39:48
I think it was the empty string case that worried
| |
141 | |
135 scoped_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions( | 142 scoped_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions( |
136 registrar_->sync_thread()->message_loop(), | 143 registrar_->sync_thread()->message_loop(), |
137 registrar_.get(), | 144 registrar_.get(), |
138 routing_info, | 145 routing_info, |
139 workers, | 146 workers, |
140 extensions_activity_monitor_.GetExtensionsActivity(), | 147 extensions_activity_monitor_.GetExtensionsActivity(), |
141 event_handler, | 148 event_handler, |
142 sync_service_url, | 149 sync_service_url, |
143 network_resources->GetHttpPostProviderFactory( | 150 network_resources->GetHttpPostProviderFactory( |
144 make_scoped_refptr(profile_->GetRequestContext()), | 151 make_scoped_refptr(profile_->GetRequestContext()), |
145 base::Bind(&UpdateNetworkTime), | 152 base::Bind(&UpdateNetworkTime), |
146 core_->GetRequestContextCancelationSignal()), | 153 core_->GetRequestContextCancelationSignal()), |
147 credentials, | 154 credentials, |
148 invalidator_ ? invalidator_->GetInvalidatorClientId() : "", | 155 invalidator_ ? invalidator_->GetInvalidatorClientId() : "", |
149 sync_manager_factory.Pass(), | 156 sync_manager_factory.Pass(), |
150 delete_sync_data_folder, | 157 delete_sync_data_folder, |
151 sync_prefs_->GetEncryptionBootstrapToken(), | 158 sync_prefs_->GetEncryptionBootstrapToken(), |
152 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), | 159 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), |
153 scoped_ptr<InternalComponentsFactory>( | 160 scoped_ptr<InternalComponentsFactory>( |
154 new syncer::InternalComponentsFactoryImpl(factory_switches)).Pass(), | 161 new syncer::InternalComponentsFactoryImpl(factory_switches)).Pass(), |
155 unrecoverable_error_handler.Pass(), | 162 unrecoverable_error_handler.Pass(), |
156 report_unrecoverable_error_function)); | 163 report_unrecoverable_error_function, |
164 signin_scoped_device_id)); | |
157 InitCore(init_opts.Pass()); | 165 InitCore(init_opts.Pass()); |
158 } | 166 } |
159 | 167 |
160 void SyncBackendHostImpl::UpdateCredentials( | 168 void SyncBackendHostImpl::UpdateCredentials( |
161 const syncer::SyncCredentials& credentials) { | 169 const syncer::SyncCredentials& credentials) { |
162 DCHECK(registrar_->sync_thread()->IsRunning()); | 170 DCHECK(registrar_->sync_thread()->IsRunning()); |
163 registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE, | 171 registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE, |
164 base::Bind(&SyncBackendHostCore::DoUpdateCredentials, | 172 base::Bind(&SyncBackendHostCore::DoUpdateCredentials, |
165 core_.get(), | 173 core_.get(), |
166 credentials)); | 174 credentials)); |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
876 | 884 |
877 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() { | 885 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() { |
878 return registrar_->sync_thread()->message_loop(); | 886 return registrar_->sync_thread()->message_loop(); |
879 } | 887 } |
880 | 888 |
881 } // namespace browser_sync | 889 } // namespace browser_sync |
882 | 890 |
883 #undef SDVLOG | 891 #undef SDVLOG |
884 | 892 |
885 #undef SLOG | 893 #undef SLOG |
OLD | NEW |