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 "sync/internal_api/sync_manager_impl.h" | 5 #include "sync/internal_api/sync_manager_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 } | 362 } |
363 | 363 |
364 bool SyncManagerImpl::Init( | 364 bool SyncManagerImpl::Init( |
365 const FilePath& database_location, | 365 const FilePath& database_location, |
366 const WeakHandle<JsEventHandler>& event_handler, | 366 const WeakHandle<JsEventHandler>& event_handler, |
367 const std::string& sync_server_and_path, | 367 const std::string& sync_server_and_path, |
368 int port, | 368 int port, |
369 bool use_ssl, | 369 bool use_ssl, |
370 const scoped_refptr<base::TaskRunner>& blocking_task_runner, | 370 const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
371 scoped_ptr<HttpPostProviderFactory> post_factory, | 371 scoped_ptr<HttpPostProviderFactory> post_factory, |
372 const ModelSafeRoutingInfo& model_safe_routing_info, | |
373 const std::vector<ModelSafeWorker*>& workers, | 372 const std::vector<ModelSafeWorker*>& workers, |
374 ExtensionsActivityMonitor* extensions_activity_monitor, | 373 ExtensionsActivityMonitor* extensions_activity_monitor, |
375 SyncManager::ChangeDelegate* change_delegate, | 374 SyncManager::ChangeDelegate* change_delegate, |
376 const SyncCredentials& credentials, | 375 const SyncCredentials& credentials, |
377 scoped_ptr<SyncNotifier> sync_notifier, | 376 scoped_ptr<SyncNotifier> sync_notifier, |
378 const std::string& restored_key_for_bootstrapping, | 377 const std::string& restored_key_for_bootstrapping, |
379 scoped_ptr<InternalComponentsFactory> internal_components_factory, | 378 scoped_ptr<InternalComponentsFactory> internal_components_factory, |
380 Encryptor* encryptor, | 379 Encryptor* encryptor, |
381 UnrecoverableErrorHandler* unrecoverable_error_handler, | 380 UnrecoverableErrorHandler* unrecoverable_error_handler, |
382 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { | 381 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 backing_store.release())); | 417 backing_store.release())); |
419 | 418 |
420 connection_manager_.reset(new SyncAPIServerConnectionManager( | 419 connection_manager_.reset(new SyncAPIServerConnectionManager( |
421 sync_server_and_path, port, use_ssl, post_factory.release())); | 420 sync_server_and_path, port, use_ssl, post_factory.release())); |
422 | 421 |
423 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 422 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
424 observing_ip_address_changes_ = true; | 423 observing_ip_address_changes_ = true; |
425 | 424 |
426 connection_manager_->AddListener(this); | 425 connection_manager_->AddListener(this); |
427 | 426 |
| 427 bool success = SignIn(credentials); |
| 428 |
428 // Build a SyncSessionContext and store the worker in it. | 429 // Build a SyncSessionContext and store the worker in it. |
429 DVLOG(1) << "Sync is bringing up SyncSessionContext."; | 430 DVLOG(1) << "Sync is bringing up SyncSessionContext."; |
430 std::vector<SyncEngineEventListener*> listeners; | 431 std::vector<SyncEngineEventListener*> listeners; |
431 listeners.push_back(&allstatus_); | 432 listeners.push_back(&allstatus_); |
432 listeners.push_back(this); | 433 listeners.push_back(this); |
433 session_context_ = internal_components_factory->BuildContext( | 434 session_context_ = internal_components_factory->BuildContext( |
434 connection_manager_.get(), | 435 connection_manager_.get(), |
435 directory(), | 436 directory(), |
436 model_safe_routing_info, | |
437 workers, | 437 workers, |
438 extensions_activity_monitor, | 438 extensions_activity_monitor, |
439 &throttled_data_type_tracker_, | 439 &throttled_data_type_tracker_, |
440 listeners, | 440 listeners, |
441 &debug_info_event_listener_, | 441 &debug_info_event_listener_, |
442 &traffic_recorder_).Pass(); | 442 &traffic_recorder_).Pass(); |
443 session_context_->set_account_name(credentials.email); | 443 session_context_->set_account_name(credentials.email); |
444 scheduler_ = internal_components_factory->BuildScheduler( | 444 scheduler_ = internal_components_factory->BuildScheduler( |
445 name_, session_context_.get()).Pass(); | 445 name_, session_context_.get()).Pass(); |
446 | 446 |
447 bool success = SignIn(credentials); | |
448 | |
449 if (success) { | 447 if (success) { |
450 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE); | 448 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE); |
451 | 449 |
452 initialized_ = true; | 450 initialized_ = true; |
453 | 451 |
454 // Unapplied datatypes (those that do not have initial sync ended set) get | 452 // Unapplied datatypes (those that do not have initial sync ended set) get |
455 // re-downloaded during any configuration. But, it's possible for a datatype | 453 // re-downloaded during any configuration. But, it's possible for a datatype |
456 // to have a progress marker but not have initial sync ended yet, making | 454 // to have a progress marker but not have initial sync ended yet, making |
457 // it a candidate for migration. This is a problem, as the DataTypeManager | 455 // it a candidate for migration. This is a problem, as the DataTypeManager |
458 // does not support a migration while it's already in the middle of a | 456 // does not support a migration while it's already in the middle of a |
(...skipping 16 matching lines...) Expand all Loading... |
475 } | 473 } |
476 | 474 |
477 // Notify that initialization is complete. Note: This should be the last to | 475 // Notify that initialization is complete. Note: This should be the last to |
478 // execute if |signed_in| is false. Reason being in that case we would | 476 // execute if |signed_in| is false. Reason being in that case we would |
479 // post a task to shutdown sync. But if this function posts any other tasks | 477 // post a task to shutdown sync. But if this function posts any other tasks |
480 // on the UI thread and if shutdown wins then that tasks would execute on | 478 // on the UI thread and if shutdown wins then that tasks would execute on |
481 // a freed pointer. This is because UI thread is not shut down. | 479 // a freed pointer. This is because UI thread is not shut down. |
482 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 480 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
483 OnInitializationComplete( | 481 OnInitializationComplete( |
484 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), | 482 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), |
485 success)); | 483 success, success ? InitialSyncEndedTypes() |
| 484 : syncer::ModelTypeSet())); |
486 if (!success) | 485 if (!success) |
487 return false; | 486 return false; |
488 | 487 |
489 sync_notifier_->AddObserver(this); | 488 sync_notifier_->AddObserver(this); |
490 | 489 |
491 return success; | 490 return success; |
492 } | 491 } |
493 | 492 |
494 void SyncManagerImpl::RefreshNigori(const std::string& chrome_version, | 493 void SyncManagerImpl::RefreshNigori(const std::string& chrome_version, |
495 const base::Closure& done_callback) { | 494 const base::Closure& done_callback) { |
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1890 int SyncManagerImpl::GetDefaultNudgeDelay() { |
1892 return kDefaultNudgeDelayMilliseconds; | 1891 return kDefaultNudgeDelayMilliseconds; |
1893 } | 1892 } |
1894 | 1893 |
1895 // static. | 1894 // static. |
1896 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1895 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
1897 return kPreferencesNudgeDelayMilliseconds; | 1896 return kPreferencesNudgeDelayMilliseconds; |
1898 } | 1897 } |
1899 | 1898 |
1900 } // namespace syncer | 1899 } // namespace syncer |
OLD | NEW |