| 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 AddObserver(&debug_info_event_listener_); | 378 AddObserver(&debug_info_event_listener_); |
| 379 | 379 |
| 380 database_path_ = database_location.Append( | 380 database_path_ = database_location.Append( |
| 381 syncable::Directory::kSyncDatabaseFilename); | 381 syncable::Directory::kSyncDatabaseFilename); |
| 382 encryptor_ = encryptor; | 382 encryptor_ = encryptor; |
| 383 unrecoverable_error_handler_ = unrecoverable_error_handler; | 383 unrecoverable_error_handler_ = unrecoverable_error_handler; |
| 384 report_unrecoverable_error_function_ = report_unrecoverable_error_function; | 384 report_unrecoverable_error_function_ = report_unrecoverable_error_function; |
| 385 | 385 |
| 386 sync_encryption_handler_.reset(new SyncEncryptionHandlerImpl( | 386 sync_encryption_handler_.reset(new SyncEncryptionHandlerImpl( |
| 387 &share_, | 387 &share_, |
| 388 encryptor)); | 388 encryptor, |
| 389 restored_key_for_bootstrapping, |
| 390 restored_keystore_key_for_bootstrapping)); |
| 389 sync_encryption_handler_->AddObserver(this); | 391 sync_encryption_handler_->AddObserver(this); |
| 390 sync_encryption_handler_->AddObserver(&debug_info_event_listener_); | 392 sync_encryption_handler_->AddObserver(&debug_info_event_listener_); |
| 391 sync_encryption_handler_->AddObserver(&js_sync_encryption_handler_observer_); | 393 sync_encryption_handler_->AddObserver(&js_sync_encryption_handler_observer_); |
| 392 | 394 |
| 393 FilePath absolute_db_path(database_path_); | 395 FilePath absolute_db_path(database_path_); |
| 394 file_util::AbsolutePath(&absolute_db_path); | 396 file_util::AbsolutePath(&absolute_db_path); |
| 395 scoped_ptr<syncable::DirectoryBackingStore> backing_store = | 397 scoped_ptr<syncable::DirectoryBackingStore> backing_store = |
| 396 internal_components_factory->BuildDirectoryBackingStore( | 398 internal_components_factory->BuildDirectoryBackingStore( |
| 397 credentials.email, absolute_db_path).Pass(); | 399 credentials.email, absolute_db_path).Pass(); |
| 398 | 400 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 | 460 |
| 459 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE); | 461 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE); |
| 460 | 462 |
| 461 initialized_ = true; | 463 initialized_ = true; |
| 462 | 464 |
| 463 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 465 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| 464 observing_ip_address_changes_ = true; | 466 observing_ip_address_changes_ = true; |
| 465 | 467 |
| 466 UpdateCredentials(credentials); | 468 UpdateCredentials(credentials); |
| 467 | 469 |
| 468 // Cryptographer should only be accessed while holding a | |
| 469 // transaction. Grabbing the user share for the transaction | |
| 470 // checks the initialization state, so this must come after | |
| 471 // |initialized_| is set to true. | |
| 472 ReadTransaction trans(FROM_HERE, GetUserShare()); | |
| 473 trans.GetCryptographer()->Bootstrap(restored_key_for_bootstrapping); | |
| 474 trans.GetCryptographer()->BootstrapKeystoreKey( | |
| 475 restored_keystore_key_for_bootstrapping); | |
| 476 | |
| 477 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 470 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
| 478 OnInitializationComplete( | 471 OnInitializationComplete( |
| 479 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), | 472 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), |
| 480 true, InitialSyncEndedTypes())); | 473 true, InitialSyncEndedTypes())); |
| 481 } | 474 } |
| 482 | 475 |
| 483 void SyncManagerImpl::UpdateSessionNameCallback( | 476 void SyncManagerImpl::UpdateSessionNameCallback( |
| 484 const std::string& chrome_version, | 477 const std::string& chrome_version, |
| 485 const std::string& session_name) { | 478 const std::string& session_name) { |
| 486 WriteTransaction trans(FROM_HERE, GetUserShare()); | 479 WriteTransaction trans(FROM_HERE, GetUserShare()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 PassphraseRequiredReason reason, | 525 PassphraseRequiredReason reason, |
| 533 const sync_pb::EncryptedData& pending_keys) { | 526 const sync_pb::EncryptedData& pending_keys) { |
| 534 // Does nothing. | 527 // Does nothing. |
| 535 } | 528 } |
| 536 | 529 |
| 537 void SyncManagerImpl::OnPassphraseAccepted() { | 530 void SyncManagerImpl::OnPassphraseAccepted() { |
| 538 // Does nothing. | 531 // Does nothing. |
| 539 } | 532 } |
| 540 | 533 |
| 541 void SyncManagerImpl::OnBootstrapTokenUpdated( | 534 void SyncManagerImpl::OnBootstrapTokenUpdated( |
| 542 const std::string& bootstrap_token) { | 535 const std::string& bootstrap_token, |
| 536 BootstrapTokenType type) { |
| 543 // Does nothing. | 537 // Does nothing. |
| 544 } | 538 } |
| 545 | 539 |
| 546 void SyncManagerImpl::OnEncryptedTypesChanged(ModelTypeSet encrypted_types, | 540 void SyncManagerImpl::OnEncryptedTypesChanged(ModelTypeSet encrypted_types, |
| 547 bool encrypt_everything) { | 541 bool encrypt_everything) { |
| 548 allstatus_.SetEncryptedTypes(encrypted_types); | 542 allstatus_.SetEncryptedTypes(encrypted_types); |
| 549 } | 543 } |
| 550 | 544 |
| 551 void SyncManagerImpl::OnEncryptionComplete() { | 545 void SyncManagerImpl::OnEncryptionComplete() { |
| 552 // Does nothing. | 546 // Does nothing. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 invalidator_->UpdateRegisteredIds(handler, ids); | 675 invalidator_->UpdateRegisteredIds(handler, ids); |
| 682 } | 676 } |
| 683 | 677 |
| 684 void SyncManagerImpl::UnregisterInvalidationHandler( | 678 void SyncManagerImpl::UnregisterInvalidationHandler( |
| 685 InvalidationHandler* handler) { | 679 InvalidationHandler* handler) { |
| 686 DCHECK(thread_checker_.CalledOnValidThread()); | 680 DCHECK(thread_checker_.CalledOnValidThread()); |
| 687 DCHECK(initialized_); | 681 DCHECK(initialized_); |
| 688 invalidator_->UnregisterHandler(handler); | 682 invalidator_->UnregisterHandler(handler); |
| 689 } | 683 } |
| 690 | 684 |
| 691 bool SyncManagerImpl::GetKeystoreKeyBootstrapToken(std::string* token) { | |
| 692 ReadTransaction trans(FROM_HERE, GetUserShare()); | |
| 693 return trans.GetCryptographer()->GetKeystoreKeyBootstrapToken(token); | |
| 694 } | |
| 695 | |
| 696 void SyncManagerImpl::AddObserver(SyncManager::Observer* observer) { | 685 void SyncManagerImpl::AddObserver(SyncManager::Observer* observer) { |
| 697 DCHECK(thread_checker_.CalledOnValidThread()); | 686 DCHECK(thread_checker_.CalledOnValidThread()); |
| 698 observers_.AddObserver(observer); | 687 observers_.AddObserver(observer); |
| 699 } | 688 } |
| 700 | 689 |
| 701 void SyncManagerImpl::RemoveObserver(SyncManager::Observer* observer) { | 690 void SyncManagerImpl::RemoveObserver(SyncManager::Observer* observer) { |
| 702 DCHECK(thread_checker_.CalledOnValidThread()); | 691 DCHECK(thread_checker_.CalledOnValidThread()); |
| 703 observers_.RemoveObserver(observer); | 692 observers_.RemoveObserver(observer); |
| 704 } | 693 } |
| 705 | 694 |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1357 int SyncManagerImpl::GetDefaultNudgeDelay() { |
| 1369 return kDefaultNudgeDelayMilliseconds; | 1358 return kDefaultNudgeDelayMilliseconds; |
| 1370 } | 1359 } |
| 1371 | 1360 |
| 1372 // static. | 1361 // static. |
| 1373 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1362 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
| 1374 return kPreferencesNudgeDelayMilliseconds; | 1363 return kPreferencesNudgeDelayMilliseconds; |
| 1375 } | 1364 } |
| 1376 | 1365 |
| 1377 } // namespace syncer | 1366 } // namespace syncer |
| OLD | NEW |