| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 previous_types = GetRoutingInfoTypes(session_context_->routing_info()); | 344 previous_types = GetRoutingInfoTypes(session_context_->routing_info()); |
| 345 if (!PurgeDisabledTypes(previous_types, | 345 if (!PurgeDisabledTypes(previous_types, |
| 346 GetRoutingInfoTypes(new_routing_info))) { | 346 GetRoutingInfoTypes(new_routing_info))) { |
| 347 // We failed to cleanup the types. Invoke the ready task without actually | 347 // We failed to cleanup the types. Invoke the ready task without actually |
| 348 // configuring any types. The caller should detect this as a configuration | 348 // configuring any types. The caller should detect this as a configuration |
| 349 // failure and act appropriately. | 349 // failure and act appropriately. |
| 350 ready_task.Run(); | 350 ready_task.Run(); |
| 351 return; | 351 return; |
| 352 } | 352 } |
| 353 | 353 |
| 354 // TODO(zea): set this based on whether cryptographer has keystore | |
| 355 // encryption key or not (requires opening a transaction). crbug.com/129665. | |
| 356 ConfigurationParams::KeystoreKeyStatus keystore_key_status = | |
| 357 ConfigurationParams::KEYSTORE_KEY_UNNECESSARY; | |
| 358 | |
| 359 ConfigurationParams params(GetSourceFromReason(reason), | 354 ConfigurationParams params(GetSourceFromReason(reason), |
| 360 types_to_config, | 355 types_to_config, |
| 361 new_routing_info, | 356 new_routing_info, |
| 362 keystore_key_status, | |
| 363 ready_task); | 357 ready_task); |
| 364 | 358 |
| 365 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE); | 359 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE); |
| 366 if (!scheduler_->ScheduleConfiguration(params)) | 360 if (!scheduler_->ScheduleConfiguration(params)) |
| 367 retry_task.Run(); | 361 retry_task.Run(); |
| 368 | 362 |
| 369 } | 363 } |
| 370 | 364 |
| 371 bool SyncManagerImpl::Init( | 365 bool SyncManagerImpl::Init( |
| 372 const FilePath& database_location, | 366 const FilePath& database_location, |
| 373 const WeakHandle<JsEventHandler>& event_handler, | 367 const WeakHandle<JsEventHandler>& event_handler, |
| 374 const std::string& sync_server_and_path, | 368 const std::string& sync_server_and_path, |
| 375 int port, | 369 int port, |
| 376 bool use_ssl, | 370 bool use_ssl, |
| 377 const scoped_refptr<base::TaskRunner>& blocking_task_runner, | 371 const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
| 378 scoped_ptr<HttpPostProviderFactory> post_factory, | 372 scoped_ptr<HttpPostProviderFactory> post_factory, |
| 379 const std::vector<ModelSafeWorker*>& workers, | 373 const std::vector<ModelSafeWorker*>& workers, |
| 380 ExtensionsActivityMonitor* extensions_activity_monitor, | 374 ExtensionsActivityMonitor* extensions_activity_monitor, |
| 381 SyncManager::ChangeDelegate* change_delegate, | 375 SyncManager::ChangeDelegate* change_delegate, |
| 382 const SyncCredentials& credentials, | 376 const SyncCredentials& credentials, |
| 383 scoped_ptr<SyncNotifier> sync_notifier, | 377 scoped_ptr<SyncNotifier> sync_notifier, |
| 384 const std::string& restored_key_for_bootstrapping, | 378 const std::string& restored_key_for_bootstrapping, |
| 379 bool keystore_encryption_enabled, |
| 385 scoped_ptr<InternalComponentsFactory> internal_components_factory, | 380 scoped_ptr<InternalComponentsFactory> internal_components_factory, |
| 386 Encryptor* encryptor, | 381 Encryptor* encryptor, |
| 387 UnrecoverableErrorHandler* unrecoverable_error_handler, | 382 UnrecoverableErrorHandler* unrecoverable_error_handler, |
| 388 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { | 383 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { |
| 389 CHECK(!initialized_); | 384 CHECK(!initialized_); |
| 390 DCHECK(thread_checker_.CalledOnValidThread()); | 385 DCHECK(thread_checker_.CalledOnValidThread()); |
| 391 DCHECK(post_factory.get()); | 386 DCHECK(post_factory.get()); |
| 392 DCHECK(!credentials.email.empty()); | 387 DCHECK(!credentials.email.empty()); |
| 393 DCHECK(!credentials.sync_token.empty()); | 388 DCHECK(!credentials.sync_token.empty()); |
| 394 DVLOG(1) << "SyncManager starting Init..."; | 389 DVLOG(1) << "SyncManager starting Init..."; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 listeners.push_back(&allstatus_); | 457 listeners.push_back(&allstatus_); |
| 463 listeners.push_back(this); | 458 listeners.push_back(this); |
| 464 session_context_ = internal_components_factory->BuildContext( | 459 session_context_ = internal_components_factory->BuildContext( |
| 465 connection_manager_.get(), | 460 connection_manager_.get(), |
| 466 directory(), | 461 directory(), |
| 467 workers, | 462 workers, |
| 468 extensions_activity_monitor, | 463 extensions_activity_monitor, |
| 469 &throttled_data_type_tracker_, | 464 &throttled_data_type_tracker_, |
| 470 listeners, | 465 listeners, |
| 471 &debug_info_event_listener_, | 466 &debug_info_event_listener_, |
| 472 &traffic_recorder_).Pass(); | 467 &traffic_recorder_, |
| 468 keystore_encryption_enabled).Pass(); |
| 473 session_context_->set_account_name(credentials.email); | 469 session_context_->set_account_name(credentials.email); |
| 474 scheduler_ = internal_components_factory->BuildScheduler( | 470 scheduler_ = internal_components_factory->BuildScheduler( |
| 475 name_, session_context_.get()).Pass(); | 471 name_, session_context_.get()).Pass(); |
| 476 | 472 |
| 477 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE); | 473 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE); |
| 478 | 474 |
| 479 initialized_ = true; | 475 initialized_ = true; |
| 480 | 476 |
| 481 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 477 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| 482 observing_ip_address_changes_ = true; | 478 observing_ip_address_changes_ = true; |
| (...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1873 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1869 int SyncManagerImpl::GetDefaultNudgeDelay() { |
| 1874 return kDefaultNudgeDelayMilliseconds; | 1870 return kDefaultNudgeDelayMilliseconds; |
| 1875 } | 1871 } |
| 1876 | 1872 |
| 1877 // static. | 1873 // static. |
| 1878 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1874 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
| 1879 return kPreferencesNudgeDelayMilliseconds; | 1875 return kPreferencesNudgeDelayMilliseconds; |
| 1880 } | 1876 } |
| 1881 | 1877 |
| 1882 } // namespace syncer | 1878 } // namespace syncer |
| OLD | NEW |