| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/internal_api/sync_manager.h" | 5 #include "chrome/browser/sync/internal_api/sync_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 | 671 |
| 672 void SyncManager::EncryptDataTypes( | 672 void SyncManager::EncryptDataTypes( |
| 673 const syncable::ModelTypeSet& encrypted_types) { | 673 const syncable::ModelTypeSet& encrypted_types) { |
| 674 data_->EncryptDataTypes(encrypted_types); | 674 data_->EncryptDataTypes(encrypted_types); |
| 675 } | 675 } |
| 676 | 676 |
| 677 bool SyncManager::IsUsingExplicitPassphrase() { | 677 bool SyncManager::IsUsingExplicitPassphrase() { |
| 678 return data_ && data_->IsUsingExplicitPassphrase(); | 678 return data_ && data_->IsUsingExplicitPassphrase(); |
| 679 } | 679 } |
| 680 | 680 |
| 681 void SyncManager::RequestCleanupDisabledTypes() { | 681 void SyncManager::RequestCleanupDisabledTypes(const base::Closure& callback) { |
| 682 if (data_->scheduler()) | 682 if (data_->scheduler()) |
| 683 data_->scheduler()->ScheduleCleanupDisabledTypes(); | 683 data_->scheduler()->ScheduleCleanupDisabledTypes(callback); |
| 684 } | 684 } |
| 685 | 685 |
| 686 void SyncManager::RequestClearServerData() { | 686 void SyncManager::RequestClearServerData() { |
| 687 if (data_->scheduler()) | 687 if (data_->scheduler()) |
| 688 data_->scheduler()->ScheduleClearUserData(); | 688 data_->scheduler()->ScheduleClearUserData(); |
| 689 } | 689 } |
| 690 | 690 |
| 691 void SyncManager::RequestConfig(const syncable::ModelTypeBitSet& types, | 691 void SyncManager::RequestConfig(const syncable::ModelTypeBitSet& types, |
| 692 ConfigureReason reason) { | 692 ConfigureReason reason) { |
| 693 if (!data_->scheduler()) { | 693 if (!data_->scheduler()) { |
| 694 LOG(INFO) | 694 LOG(INFO) |
| 695 << "SyncManager::RequestConfig: bailing out because scheduler is " | 695 << "SyncManager::RequestConfig: bailing out because scheduler is " |
| 696 << "null"; | 696 << "null"; |
| 697 return; | 697 return; |
| 698 } | 698 } |
| 699 StartConfigurationMode(NULL); | 699 StartConfigurationMode(base::Closure()); |
| 700 data_->scheduler()->ScheduleConfig(types, reason); | 700 data_->scheduler()->ScheduleConfig(types, reason); |
| 701 } | 701 } |
| 702 | 702 |
| 703 void SyncManager::StartConfigurationMode(ModeChangeCallback* callback) { | 703 void SyncManager::StartConfigurationMode(const base::Closure& callback) { |
| 704 if (!data_->scheduler()) { | 704 if (!data_->scheduler()) { |
| 705 LOG(INFO) | 705 LOG(INFO) |
| 706 << "SyncManager::StartConfigurationMode: could not start " | 706 << "SyncManager::StartConfigurationMode: could not start " |
| 707 << "configuration mode because because scheduler is null"; | 707 << "configuration mode because because scheduler is null"; |
| 708 return; | 708 return; |
| 709 } | 709 } |
| 710 data_->scheduler()->Start( | 710 data_->scheduler()->Start( |
| 711 browser_sync::SyncScheduler::CONFIGURATION_MODE, callback); | 711 browser_sync::SyncScheduler::CONFIGURATION_MODE, callback); |
| 712 } | 712 } |
| 713 | 713 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 listeners); | 775 listeners); |
| 776 context->set_account_name(credentials.email); | 776 context->set_account_name(credentials.email); |
| 777 // The SyncScheduler takes ownership of |context|. | 777 // The SyncScheduler takes ownership of |context|. |
| 778 scheduler_.reset(new SyncScheduler(name_, context, new Syncer())); | 778 scheduler_.reset(new SyncScheduler(name_, context, new Syncer())); |
| 779 } | 779 } |
| 780 | 780 |
| 781 bool signed_in = SignIn(credentials); | 781 bool signed_in = SignIn(credentials); |
| 782 | 782 |
| 783 if (signed_in && scheduler()) { | 783 if (signed_in && scheduler()) { |
| 784 scheduler()->Start( | 784 scheduler()->Start( |
| 785 browser_sync::SyncScheduler::CONFIGURATION_MODE, NULL); | 785 browser_sync::SyncScheduler::CONFIGURATION_MODE, base::Closure()); |
| 786 } | 786 } |
| 787 | 787 |
| 788 initialized_ = true; | 788 initialized_ = true; |
| 789 | 789 |
| 790 // Notify that initialization is complete. | 790 // Notify that initialization is complete. |
| 791 ObserverList<SyncManager::Observer> temp_obs_list; | 791 ObserverList<SyncManager::Observer> temp_obs_list; |
| 792 CopyObservers(&temp_obs_list); | 792 CopyObservers(&temp_obs_list); |
| 793 FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list, | 793 FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list, |
| 794 OnInitializationComplete( | 794 OnInitializationComplete( |
| 795 WeakHandle<JsBackend>(weak_ptr_factory_.GetWeakPtr()))); | 795 WeakHandle<JsBackend>(weak_ptr_factory_.GetWeakPtr()))); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys()); | 845 allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys()); |
| 846 | 846 |
| 847 return cryptographer->is_ready(); | 847 return cryptographer->is_ready(); |
| 848 } | 848 } |
| 849 | 849 |
| 850 void SyncManager::SyncInternal::StartSyncingNormally() { | 850 void SyncManager::SyncInternal::StartSyncingNormally() { |
| 851 // Start the sync scheduler. This won't actually result in any | 851 // Start the sync scheduler. This won't actually result in any |
| 852 // syncing until at least the DirectoryManager broadcasts the OPENED | 852 // syncing until at least the DirectoryManager broadcasts the OPENED |
| 853 // event, and a valid server connection is detected. | 853 // event, and a valid server connection is detected. |
| 854 if (scheduler()) // NULL during certain unittests. | 854 if (scheduler()) // NULL during certain unittests. |
| 855 scheduler()->Start(SyncScheduler::NORMAL_MODE, NULL); | 855 scheduler()->Start(SyncScheduler::NORMAL_MODE, base::Closure()); |
| 856 } | 856 } |
| 857 | 857 |
| 858 bool SyncManager::SyncInternal::OpenDirectory() { | 858 bool SyncManager::SyncInternal::OpenDirectory() { |
| 859 DCHECK(!initialized_) << "Should only happen once"; | 859 DCHECK(!initialized_) << "Should only happen once"; |
| 860 | 860 |
| 861 bool share_opened = dir_manager()->Open(username_for_share(), this); | 861 bool share_opened = dir_manager()->Open(username_for_share(), this); |
| 862 DCHECK(share_opened); | 862 DCHECK(share_opened); |
| 863 if (!share_opened) { | 863 if (!share_opened) { |
| 864 ObserverList<SyncManager::Observer> temp_obs_list; | 864 ObserverList<SyncManager::Observer> temp_obs_list; |
| 865 CopyObservers(&temp_obs_list); | 865 CopyObservers(&temp_obs_list); |
| (...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2054 | 2054 |
| 2055 for (syncable::ModelTypeSet::const_iterator i = types.begin(); | 2055 for (syncable::ModelTypeSet::const_iterator i = types.begin(); |
| 2056 i != types.end(); ++i) { | 2056 i != types.end(); ++i) { |
| 2057 if (!lookup->initial_sync_ended_for_type(*i)) | 2057 if (!lookup->initial_sync_ended_for_type(*i)) |
| 2058 return false; | 2058 return false; |
| 2059 } | 2059 } |
| 2060 return true; | 2060 return true; |
| 2061 } | 2061 } |
| 2062 | 2062 |
| 2063 } // namespace sync_api | 2063 } // namespace sync_api |
| OLD | NEW |