OLD | NEW |
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_impl/sync_manager_impl.h" | 5 #include "components/sync/engine_impl/sync_manager_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 233 |
234 AddObserver(&debug_info_event_listener_); | 234 AddObserver(&debug_info_event_listener_); |
235 | 235 |
236 database_path_ = args->database_location.Append( | 236 database_path_ = args->database_location.Append( |
237 syncable::Directory::kSyncDatabaseFilename); | 237 syncable::Directory::kSyncDatabaseFilename); |
238 report_unrecoverable_error_function_ = | 238 report_unrecoverable_error_function_ = |
239 args->report_unrecoverable_error_function; | 239 args->report_unrecoverable_error_function; |
240 | 240 |
241 allstatus_.SetHasKeystoreKey( | 241 allstatus_.SetHasKeystoreKey( |
242 !args->restored_keystore_key_for_bootstrapping.empty()); | 242 !args->restored_keystore_key_for_bootstrapping.empty()); |
243 sync_encryption_handler_.reset(new SyncEncryptionHandlerImpl( | 243 sync_encryption_handler_ = base::MakeUnique<SyncEncryptionHandlerImpl>( |
244 &share_, args->encryptor, args->restored_key_for_bootstrapping, | 244 &share_, args->encryptor, args->restored_key_for_bootstrapping, |
245 args->restored_keystore_key_for_bootstrapping)); | 245 args->restored_keystore_key_for_bootstrapping); |
246 sync_encryption_handler_->AddObserver(this); | 246 sync_encryption_handler_->AddObserver(this); |
247 sync_encryption_handler_->AddObserver(&debug_info_event_listener_); | 247 sync_encryption_handler_->AddObserver(&debug_info_event_listener_); |
248 sync_encryption_handler_->AddObserver(&js_sync_encryption_handler_observer_); | 248 sync_encryption_handler_->AddObserver(&js_sync_encryption_handler_observer_); |
249 | 249 |
250 base::FilePath absolute_db_path = database_path_; | 250 base::FilePath absolute_db_path = database_path_; |
251 DCHECK(absolute_db_path.IsAbsolute()); | 251 DCHECK(absolute_db_path.IsAbsolute()); |
252 | 252 |
253 std::unique_ptr<syncable::DirectoryBackingStore> backing_store = | 253 std::unique_ptr<syncable::DirectoryBackingStore> backing_store = |
254 args->engine_components_factory->BuildDirectoryBackingStore( | 254 args->engine_components_factory->BuildDirectoryBackingStore( |
255 EngineComponentsFactory::STORAGE_ON_DISK, | 255 EngineComponentsFactory::STORAGE_ON_DISK, |
256 args->credentials.account_id, absolute_db_path); | 256 args->credentials.account_id, absolute_db_path); |
257 | 257 |
258 DCHECK(backing_store.get()); | 258 DCHECK(backing_store.get()); |
259 share_.directory.reset(new syncable::Directory( | 259 share_.directory = base::MakeUnique<syncable::Directory>( |
260 backing_store.release(), args->unrecoverable_error_handler, | 260 backing_store.release(), args->unrecoverable_error_handler, |
261 report_unrecoverable_error_function_, sync_encryption_handler_.get(), | 261 report_unrecoverable_error_function_, sync_encryption_handler_.get(), |
262 sync_encryption_handler_->GetCryptographerUnsafe())); | 262 sync_encryption_handler_->GetCryptographerUnsafe()); |
263 share_.sync_credentials = args->credentials; | 263 share_.sync_credentials = args->credentials; |
264 | 264 |
265 // UserShare is accessible to a lot of code that doesn't need access to the | 265 // UserShare is accessible to a lot of code that doesn't need access to the |
266 // sync token so clear sync_token from the UserShare. | 266 // sync token so clear sync_token from the UserShare. |
267 share_.sync_credentials.sync_token = ""; | 267 share_.sync_credentials.sync_token = ""; |
268 | 268 |
269 DVLOG(1) << "Username: " << args->credentials.email; | 269 DVLOG(1) << "Username: " << args->credentials.email; |
270 DVLOG(1) << "AccountId: " << args->credentials.account_id; | 270 DVLOG(1) << "AccountId: " << args->credentials.account_id; |
271 if (!OpenDirectory(args->credentials.account_id)) { | 271 if (!OpenDirectory(args->credentials.account_id)) { |
272 NotifyInitializationFailure(); | 272 NotifyInitializationFailure(); |
273 LOG(ERROR) << "Sync manager initialization failed!"; | 273 LOG(ERROR) << "Sync manager initialization failed!"; |
274 return; | 274 return; |
275 } | 275 } |
276 | 276 |
277 // Now that we have opened the Directory we can restore any previously saved | 277 // Now that we have opened the Directory we can restore any previously saved |
278 // nigori specifics. | 278 // nigori specifics. |
279 if (args->saved_nigori_state) { | 279 if (args->saved_nigori_state) { |
280 sync_encryption_handler_->RestoreNigori(*args->saved_nigori_state); | 280 sync_encryption_handler_->RestoreNigori(*args->saved_nigori_state); |
281 args->saved_nigori_state.reset(); | 281 args->saved_nigori_state.reset(); |
282 } | 282 } |
283 | 283 |
284 connection_manager_.reset(new SyncServerConnectionManager( | 284 connection_manager_ = base::MakeUnique<SyncServerConnectionManager>( |
285 args->service_url.host() + args->service_url.path(), | 285 args->service_url.host() + args->service_url.path(), |
286 args->service_url.EffectiveIntPort(), | 286 args->service_url.EffectiveIntPort(), |
287 args->service_url.SchemeIsCryptographic(), args->post_factory.release(), | 287 args->service_url.SchemeIsCryptographic(), args->post_factory.release(), |
288 args->cancelation_signal)); | 288 args->cancelation_signal); |
289 connection_manager_->set_client_id(directory()->cache_guid()); | 289 connection_manager_->set_client_id(directory()->cache_guid()); |
290 connection_manager_->AddListener(this); | 290 connection_manager_->AddListener(this); |
291 | 291 |
292 std::string sync_id = directory()->cache_guid(); | 292 std::string sync_id = directory()->cache_guid(); |
293 | 293 |
294 DVLOG(1) << "Setting sync client ID: " << sync_id; | 294 DVLOG(1) << "Setting sync client ID: " << sync_id; |
295 allstatus_.SetSyncId(sync_id); | 295 allstatus_.SetSyncId(sync_id); |
296 DVLOG(1) << "Setting invalidator client ID: " << args->invalidator_client_id; | 296 DVLOG(1) << "Setting invalidator client ID: " << args->invalidator_client_id; |
297 allstatus_.SetInvalidatorClientId(args->invalidator_client_id); | 297 allstatus_.SetInvalidatorClientId(args->invalidator_client_id); |
298 | 298 |
299 model_type_registry_.reset( | 299 model_type_registry_ = |
300 new ModelTypeRegistry(args->workers, directory(), this)); | 300 base::MakeUnique<ModelTypeRegistry>(args->workers, directory(), this); |
301 sync_encryption_handler_->AddObserver(model_type_registry_.get()); | 301 sync_encryption_handler_->AddObserver(model_type_registry_.get()); |
302 | 302 |
303 // Build a SyncCycleContext and store the worker in it. | 303 // Build a SyncCycleContext and store the worker in it. |
304 DVLOG(1) << "Sync is bringing up SyncCycleContext."; | 304 DVLOG(1) << "Sync is bringing up SyncCycleContext."; |
305 std::vector<SyncEngineEventListener*> listeners; | 305 std::vector<SyncEngineEventListener*> listeners; |
306 listeners.push_back(&allstatus_); | 306 listeners.push_back(&allstatus_); |
307 listeners.push_back(this); | 307 listeners.push_back(this); |
308 cycle_context_ = args->engine_components_factory->BuildContext( | 308 cycle_context_ = args->engine_components_factory->BuildContext( |
309 connection_manager_.get(), directory(), args->extensions_activity, | 309 connection_manager_.get(), directory(), args->extensions_activity, |
310 listeners, &debug_info_event_listener_, model_type_registry_.get(), | 310 listeners, &debug_info_event_listener_, model_type_registry_.get(), |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 } | 995 } |
996 | 996 |
997 void SyncManagerImpl::OnCookieJarChanged(bool account_mismatch, | 997 void SyncManagerImpl::OnCookieJarChanged(bool account_mismatch, |
998 bool empty_jar) { | 998 bool empty_jar) { |
999 DCHECK(thread_checker_.CalledOnValidThread()); | 999 DCHECK(thread_checker_.CalledOnValidThread()); |
1000 cycle_context_->set_cookie_jar_mismatch(account_mismatch); | 1000 cycle_context_->set_cookie_jar_mismatch(account_mismatch); |
1001 cycle_context_->set_cookie_jar_empty(empty_jar); | 1001 cycle_context_->set_cookie_jar_empty(empty_jar); |
1002 } | 1002 } |
1003 | 1003 |
1004 } // namespace syncer | 1004 } // namespace syncer |
OLD | NEW |