Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Side by Side Diff: components/browser_sync/profile_sync_service.cc

Issue 2624943002: [Sync] Move snapshot cache from SBHI to PSS. (Closed)
Patch Set: Address comments. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browser_sync/profile_sync_service.h" 5 #include "components/browser_sync/profile_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 sync_enabled_weak_factory_.InvalidateWeakPtrs(); 775 sync_enabled_weak_factory_.InvalidateWeakPtrs();
776 776
777 startup_controller_->Reset(GetRegisteredDataTypes()); 777 startup_controller_->Reset(GetRegisteredDataTypes());
778 778
779 // If the sync DB is getting destroyed, the local DeviceInfo is no longer 779 // If the sync DB is getting destroyed, the local DeviceInfo is no longer
780 // valid and should be cleared from the cache. 780 // valid and should be cleared from the cache.
781 if (reason == syncer::ShutdownReason::DISABLE_SYNC) { 781 if (reason == syncer::ShutdownReason::DISABLE_SYNC) {
782 local_device_->Clear(); 782 local_device_->Clear();
783 } 783 }
784 784
785 // Clear various flags. 785 // Clear various state.
786 expect_sync_configuration_aborted_ = false; 786 expect_sync_configuration_aborted_ = false;
787 is_auth_in_progress_ = false; 787 is_auth_in_progress_ = false;
788 engine_initialized_ = false; 788 engine_initialized_ = false;
789 cached_passphrase_.clear(); 789 cached_passphrase_.clear();
790 encryption_pending_ = false; 790 encryption_pending_ = false;
791 encrypt_everything_ = false; 791 encrypt_everything_ = false;
792 encrypted_types_ = syncer::SyncEncryptionHandler::SensitiveTypes(); 792 encrypted_types_ = syncer::SyncEncryptionHandler::SensitiveTypes();
793 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; 793 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED;
794 catch_up_configure_in_progress_ = false; 794 catch_up_configure_in_progress_ = false;
795 access_token_.clear(); 795 access_token_.clear();
796 request_access_token_retry_timer_.Stop(); 796 request_access_token_retry_timer_.Stop();
797 last_snapshot_ = syncer::SyncCycleSnapshot();
797 // Revert to "no auth error". 798 // Revert to "no auth error".
798 if (last_auth_error_.state() != GoogleServiceAuthError::NONE) 799 if (last_auth_error_.state() != GoogleServiceAuthError::NONE)
799 UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone()); 800 UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone());
800 801
801 NotifyObservers(); 802 NotifyObservers();
802 803
803 // Mark this as a clean shutdown(without crash). 804 // Mark this as a clean shutdown(without crash).
804 sync_prefs_.SetCleanShutdown(true); 805 sync_prefs_.SetCleanShutdown(true);
805 } 806 }
806 807
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 OnGaiaAccountsInCookieUpdated(accounts, signed_out_accounts, error); 1017 OnGaiaAccountsInCookieUpdated(accounts, signed_out_accounts, error);
1017 } 1018 }
1018 1019
1019 NotifyObservers(); 1020 NotifyObservers();
1020 1021
1021 // Nobody will call us to start if no sign in is going to happen. 1022 // Nobody will call us to start if no sign in is going to happen.
1022 if (IsLocalSyncEnabled()) 1023 if (IsLocalSyncEnabled())
1023 RequestStart(); 1024 RequestStart();
1024 } 1025 }
1025 1026
1026 void ProfileSyncService::OnSyncCycleCompleted() { 1027 void ProfileSyncService::OnSyncCycleCompleted(
1028 const syncer::SyncCycleSnapshot& snapshot) {
1027 DCHECK(thread_checker_.CalledOnValidThread()); 1029 DCHECK(thread_checker_.CalledOnValidThread());
1030
1031 last_snapshot_ = snapshot;
1032
1028 UpdateLastSyncedTime(); 1033 UpdateLastSyncedTime();
1029 const syncer::SyncCycleSnapshot snapshot = GetLastCycleSnapshot(); 1034 if (!snapshot.poll_finish_time().is_null())
1035 sync_prefs_.SetLastPollTime(snapshot.poll_finish_time());
1036
1030 if (IsDataTypeControllerRunning(syncer::SESSIONS) && 1037 if (IsDataTypeControllerRunning(syncer::SESSIONS) &&
1031 snapshot.model_neutral_state().get_updates_request_types.Has( 1038 snapshot.model_neutral_state().get_updates_request_types.Has(
1032 syncer::SESSIONS) && 1039 syncer::SESSIONS) &&
1033 !syncer::HasSyncerError(snapshot.model_neutral_state())) { 1040 !syncer::HasSyncerError(snapshot.model_neutral_state())) {
1034 // Trigger garbage collection of old sessions now that we've downloaded 1041 // Trigger garbage collection of old sessions now that we've downloaded
1035 // any new session data. 1042 // any new session data.
1036 base::ThreadTaskRunnerHandle::Get()->PostTask( 1043 base::ThreadTaskRunnerHandle::Get()->PostTask(
1037 FROM_HERE, base::Bind(&SessionsSyncManager::DoGarbageCollection, 1044 FROM_HERE, base::Bind(&SessionsSyncManager::DoGarbageCollection,
1038 base::AsWeakPtr(sessions_sync_manager_.get()))); 1045 base::AsWeakPtr(sessions_sync_manager_.get())));
1039 } 1046 }
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 DCHECK(thread_checker_.CalledOnValidThread()); 1866 DCHECK(thread_checker_.CalledOnValidThread());
1860 if (engine_ && engine_initialized_) { 1867 if (engine_ && engine_initialized_) {
1861 return engine_->GetUserShare(); 1868 return engine_->GetUserShare();
1862 } 1869 }
1863 NOTREACHED(); 1870 NOTREACHED();
1864 return nullptr; 1871 return nullptr;
1865 } 1872 }
1866 1873
1867 syncer::SyncCycleSnapshot ProfileSyncService::GetLastCycleSnapshot() const { 1874 syncer::SyncCycleSnapshot ProfileSyncService::GetLastCycleSnapshot() const {
1868 DCHECK(thread_checker_.CalledOnValidThread()); 1875 DCHECK(thread_checker_.CalledOnValidThread());
1869 if (engine_) 1876 return last_snapshot_;
1870 return engine_->GetLastCycleSnapshot();
1871 return syncer::SyncCycleSnapshot();
1872 } 1877 }
1873 1878
1874 bool ProfileSyncService::HasUnsyncedItems() const { 1879 bool ProfileSyncService::HasUnsyncedItems() const {
1875 DCHECK(thread_checker_.CalledOnValidThread()); 1880 DCHECK(thread_checker_.CalledOnValidThread());
1876 if (HasSyncingEngine() && engine_initialized_) { 1881 if (HasSyncingEngine() && engine_initialized_) {
1877 return engine_->HasUnsyncedItems(); 1882 return engine_->HasUnsyncedItems();
1878 } 1883 }
1879 NOTREACHED(); 1884 NOTREACHED();
1880 return false; 1885 return false;
1881 } 1886 }
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 2633
2629 DCHECK(startup_controller_->IsSetupInProgress()); 2634 DCHECK(startup_controller_->IsSetupInProgress());
2630 startup_controller_->SetSetupInProgress(false); 2635 startup_controller_->SetSetupInProgress(false);
2631 2636
2632 if (IsEngineInitialized()) 2637 if (IsEngineInitialized())
2633 ReconfigureDatatypeManager(); 2638 ReconfigureDatatypeManager();
2634 NotifyObservers(); 2639 NotifyObservers();
2635 } 2640 }
2636 2641
2637 } // namespace browser_sync 2642 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/browser_sync/profile_sync_service.h ('k') | components/browser_sync/profile_sync_service_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698