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

Side by Side Diff: sync/internal_api/sync_manager.cc

Issue 10689185: Revert 146262 - Revert "Revert 142517 - [Sync] Refactor sync configuration logic." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « sync/internal_api/public/sync_manager.h ('k') | sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "sync/internal_api/public/sync_manager.h" 5 #include "sync/internal_api/public/sync_manager.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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 UnrecoverableErrorHandler* unrecoverable_error_handler, 190 UnrecoverableErrorHandler* unrecoverable_error_handler,
191 ReportUnrecoverableErrorFunction 191 ReportUnrecoverableErrorFunction
192 report_unrecoverable_error_function); 192 report_unrecoverable_error_function);
193 193
194 // Sign into sync with given credentials. 194 // Sign into sync with given credentials.
195 // We do not verify the tokens given. After this call, the tokens are set 195 // We do not verify the tokens given. After this call, the tokens are set
196 // and the sync DB is open. True if successful, false if something 196 // and the sync DB is open. True if successful, false if something
197 // went wrong. 197 // went wrong.
198 bool SignIn(const SyncCredentials& credentials); 198 bool SignIn(const SyncCredentials& credentials);
199 199
200 // Purge from the directory those types with non-empty progress markers
201 // but without initial synced ended set.
202 // Returns false if an error occurred, true otherwise.
203 bool PurgePartiallySyncedTypes();
204
205 // Update tokens that we're using in Sync. Email must stay the same. 200 // Update tokens that we're using in Sync. Email must stay the same.
206 void UpdateCredentials(const SyncCredentials& credentials); 201 void UpdateCredentials(const SyncCredentials& credentials);
207 202
208 // Called when the user disables or enables a sync type. 203 // Called when the user disables or enables a sync type.
209 void UpdateEnabledTypes(const ModelTypeSet& enabled_types); 204 void UpdateEnabledTypes(const ModelTypeSet& enabled_types);
210 205
211 // Tell the sync engine to start the syncing process. 206 // Tell the sync engine to start the syncing process.
212 void StartSyncingNormally( 207 void StartSyncingNormally(
213 const syncer::ModelSafeRoutingInfo& routing_info); 208 const syncer::ModelSafeRoutingInfo& routing_info);
214 209
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 syncer::ModelType type, 350 syncer::ModelType type,
356 ChangeReorderBuffer* buffer, 351 ChangeReorderBuffer* buffer,
357 Cryptographer* cryptographer, 352 Cryptographer* cryptographer,
358 const syncable::EntryKernel& original, 353 const syncable::EntryKernel& original,
359 bool existed_before, 354 bool existed_before,
360 bool exists_now); 355 bool exists_now);
361 356
362 // Called only by our NetworkChangeNotifier. 357 // Called only by our NetworkChangeNotifier.
363 virtual void OnIPAddressChanged() OVERRIDE; 358 virtual void OnIPAddressChanged() OVERRIDE;
364 359
365 ModelTypeSet GetTypesWithEmptyProgressMarkerToken(ModelTypeSet types) {
366 DCHECK(initialized_);
367 syncer::ModelTypeSet result;
368 for (syncer::ModelTypeSet::Iterator i = types.First();
369 i.Good(); i.Inc()) {
370 sync_pb::DataTypeProgressMarker marker;
371 directory()->GetDownloadProgress(i.Get(), &marker);
372
373 if (marker.token().empty())
374 result.Put(i.Get());
375
376 }
377 return result;
378 }
379
380 syncer::ModelTypeSet InitialSyncEndedTypes() { 360 syncer::ModelTypeSet InitialSyncEndedTypes() {
381 DCHECK(initialized_); 361 DCHECK(initialized_);
382 return directory()->initial_sync_ended_types(); 362 return directory()->initial_sync_ended_types();
383 } 363 }
384 364
385 // SyncEngineEventListener implementation. 365 // SyncEngineEventListener implementation.
386 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE; 366 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE;
387 367
388 // ServerConnectionEventListener implementation. 368 // ServerConnectionEventListener implementation.
389 virtual void OnServerConnectionEvent( 369 virtual void OnServerConnectionEvent(
390 const ServerConnectionEvent& event) OVERRIDE; 370 const ServerConnectionEvent& event) OVERRIDE;
391 371
392 // JsBackend implementation. 372 // JsBackend implementation.
393 virtual void SetJsEventHandler( 373 virtual void SetJsEventHandler(
394 const WeakHandle<JsEventHandler>& event_handler) OVERRIDE; 374 const WeakHandle<JsEventHandler>& event_handler) OVERRIDE;
395 virtual void ProcessJsMessage( 375 virtual void ProcessJsMessage(
396 const std::string& name, const JsArgList& args, 376 const std::string& name, const JsArgList& args,
397 const WeakHandle<JsReplyHandler>& reply_handler) OVERRIDE; 377 const WeakHandle<JsReplyHandler>& reply_handler) OVERRIDE;
398 378
399 void SetSyncSchedulerForTest(scoped_ptr<SyncScheduler> scheduler);
400
401 private: 379 private:
402 struct NotificationInfo { 380 struct NotificationInfo {
403 int total_count; 381 int total_count;
404 std::string payload; 382 std::string payload;
405 383
406 NotificationInfo() : total_count(0) {} 384 NotificationInfo() : total_count(0) {}
407 385
408 ~NotificationInfo() {} 386 ~NotificationInfo() {}
409 387
410 // Returned pointer owned by the caller. 388 // Returned pointer owned by the caller.
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 DCHECK(thread_checker_.CalledOnValidThread()); 742 DCHECK(thread_checker_.CalledOnValidThread());
765 ReadTransaction trans(FROM_HERE, GetUserShare()); 743 ReadTransaction trans(FROM_HERE, GetUserShare());
766 trans.GetWrappedTrans()->OnUnrecoverableError( 744 trans.GetWrappedTrans()->OnUnrecoverableError(
767 FROM_HERE, "Simulating unrecoverable error for testing purposes."); 745 FROM_HERE, "Simulating unrecoverable error for testing purposes.");
768 } 746 }
769 747
770 syncer::ModelTypeSet SyncManager::InitialSyncEndedTypes() { 748 syncer::ModelTypeSet SyncManager::InitialSyncEndedTypes() {
771 return data_->InitialSyncEndedTypes(); 749 return data_->InitialSyncEndedTypes();
772 } 750 }
773 751
774 syncer::ModelTypeSet SyncManager::GetTypesWithEmptyProgressMarkerToken(
775 syncer::ModelTypeSet types) {
776 return data_->GetTypesWithEmptyProgressMarkerToken(types);
777 }
778
779 bool SyncManager::PurgePartiallySyncedTypes() {
780 return data_->PurgePartiallySyncedTypes();
781 }
782
783 void SyncManager::StartSyncingNormally( 752 void SyncManager::StartSyncingNormally(
784 const syncer::ModelSafeRoutingInfo& routing_info) { 753 const syncer::ModelSafeRoutingInfo& routing_info) {
785 DCHECK(thread_checker_.CalledOnValidThread()); 754 DCHECK(thread_checker_.CalledOnValidThread());
786 data_->StartSyncingNormally(routing_info); 755 data_->StartSyncingNormally(routing_info);
787 } 756 }
788 757
789 void SyncManager::SetEncryptionPassphrase(const std::string& passphrase, 758 void SyncManager::SetEncryptionPassphrase(const std::string& passphrase,
790 bool is_explicit) { 759 bool is_explicit) {
791 DCHECK(thread_checker_.CalledOnValidThread()); 760 DCHECK(thread_checker_.CalledOnValidThread());
792 data_->SetEncryptionPassphrase(passphrase, is_explicit); 761 data_->SetEncryptionPassphrase(passphrase, is_explicit);
(...skipping 24 matching lines...) Expand all
817 786
818 bool SyncManager::EncryptEverythingEnabledForTest() const { 787 bool SyncManager::EncryptEverythingEnabledForTest() const {
819 ReadTransaction trans(FROM_HERE, GetUserShare()); 788 ReadTransaction trans(FROM_HERE, GetUserShare());
820 return trans.GetCryptographer()->encrypt_everything(); 789 return trans.GetCryptographer()->encrypt_everything();
821 } 790 }
822 791
823 bool SyncManager::IsUsingExplicitPassphrase() { 792 bool SyncManager::IsUsingExplicitPassphrase() {
824 return data_ && data_->IsUsingExplicitPassphrase(); 793 return data_ && data_->IsUsingExplicitPassphrase();
825 } 794 }
826 795
827 void SyncManager::ConfigureSyncer( 796 void SyncManager::RequestCleanupDisabledTypes(
828 ConfigureReason reason, 797 const syncer::ModelSafeRoutingInfo& routing_info) {
829 const syncer::ModelTypeSet& types_to_config,
830 const syncer::ModelSafeRoutingInfo& new_routing_info,
831 const base::Closure& ready_task,
832 const base::Closure& retry_task) {
833 DCHECK(thread_checker_.CalledOnValidThread()); 798 DCHECK(thread_checker_.CalledOnValidThread());
834 DCHECK(!ready_task.is_null()); 799 if (data_->scheduler()) {
835 DCHECK(!retry_task.is_null()); 800 data_->session_context()->set_routing_info(routing_info);
801 data_->scheduler()->CleanupDisabledTypes();
802 }
803 }
836 804
837 // TODO(zea): set this based on whether cryptographer has keystore 805 void SyncManager::RequestConfig(
838 // encryption key or not (requires opening a transaction). crbug.com/129665. 806 const syncer::ModelSafeRoutingInfo& routing_info,
839 ConfigurationParams::KeystoreKeyStatus keystore_key_status = 807 const ModelTypeSet& types, ConfigureReason reason) {
840 ConfigurationParams::KEYSTORE_KEY_UNNECESSARY; 808 DCHECK(thread_checker_.CalledOnValidThread());
841
842 ConfigurationParams params(GetSourceFromReason(reason),
843 types_to_config,
844 new_routing_info,
845 keystore_key_status,
846 ready_task);
847
848 if (!data_->scheduler()) { 809 if (!data_->scheduler()) {
849 LOG(INFO) 810 LOG(INFO)
850 << "SyncManager::ConfigureSyncer: could not configure because " 811 << "SyncManager::RequestConfig: bailing out because scheduler is "
851 << "scheduler is null"; 812 << "null";
852 params.ready_task.Run();
853 return; 813 return;
854 } 814 }
815 StartConfigurationMode(base::Closure());
816 data_->session_context()->set_routing_info(routing_info);
817 data_->scheduler()->ScheduleConfiguration(types, GetSourceFromReason(reason));
818 }
855 819
856 data_->scheduler()->Start(syncer::SyncScheduler::CONFIGURATION_MODE); 820 void SyncManager::StartConfigurationMode(const base::Closure& callback) {
857 if (!data_->scheduler()->ScheduleConfiguration(params)) 821 DCHECK(thread_checker_.CalledOnValidThread());
858 retry_task.Run(); 822 if (!data_->scheduler()) {
859 823 LOG(INFO)
824 << "SyncManager::StartConfigurationMode: could not start "
825 << "configuration mode because because scheduler is null";
826 return;
827 }
828 data_->scheduler()->Start(
829 syncer::SyncScheduler::CONFIGURATION_MODE, callback);
860 } 830 }
861 831
862 bool SyncManager::SyncInternal::Init( 832 bool SyncManager::SyncInternal::Init(
863 const FilePath& database_location, 833 const FilePath& database_location,
864 const WeakHandle<JsEventHandler>& event_handler, 834 const WeakHandle<JsEventHandler>& event_handler,
865 const std::string& sync_server_and_path, 835 const std::string& sync_server_and_path,
866 int port, 836 int port,
867 bool use_ssl, 837 bool use_ssl,
868 const scoped_refptr<base::TaskRunner>& blocking_task_runner, 838 const scoped_refptr<base::TaskRunner>& blocking_task_runner,
869 HttpPostProviderFactory* post_factory, 839 HttpPostProviderFactory* post_factory,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 workers, 916 workers,
947 extensions_activity_monitor, 917 extensions_activity_monitor,
948 &throttled_data_type_tracker_, 918 &throttled_data_type_tracker_,
949 listeners, 919 listeners,
950 &debug_info_event_listener_, 920 &debug_info_event_listener_,
951 &traffic_recorder_)); 921 &traffic_recorder_));
952 session_context()->set_account_name(credentials.email); 922 session_context()->set_account_name(credentials.email);
953 scheduler_.reset(new SyncScheduler(name_, session_context(), new Syncer())); 923 scheduler_.reset(new SyncScheduler(name_, session_context(), new Syncer()));
954 } 924 }
955 925
956 bool success = SignIn(credentials); 926 bool signed_in = SignIn(credentials);
957 927
958 if (success) { 928 if (signed_in) {
959 if (scheduler()) { 929 if (scheduler()) {
960 scheduler()->Start(syncer::SyncScheduler::CONFIGURATION_MODE); 930 scheduler()->Start(
931 syncer::SyncScheduler::CONFIGURATION_MODE, base::Closure());
961 } 932 }
962 933
963 initialized_ = true; 934 initialized_ = true;
964 935
965 // Unapplied datatypes (those that do not have initial sync ended set) get
966 // re-downloaded during any configuration. But, it's possible for a datatype
967 // to have a progress marker but not have initial sync ended yet, making
968 // it a candidate for migration. This is a problem, as the DataTypeManager
969 // does not support a migration while it's already in the middle of a
970 // configuration. As a result, any partially synced datatype can stall the
971 // DTM, waiting for the configuration to complete, which it never will due
972 // to the migration error. In addition, a partially synced nigori will
973 // trigger the migration logic before the backend is initialized, resulting
974 // in crashes. We therefore detect and purge any partially synced types as
975 // part of initialization.
976 if (!PurgePartiallySyncedTypes())
977 success = false;
978
979 // Cryptographer should only be accessed while holding a 936 // Cryptographer should only be accessed while holding a
980 // transaction. Grabbing the user share for the transaction 937 // transaction. Grabbing the user share for the transaction
981 // checks the initialization state, so this must come after 938 // checks the initialization state, so this must come after
982 // |initialized_| is set to true. 939 // |initialized_| is set to true.
983 ReadTransaction trans(FROM_HERE, GetUserShare()); 940 ReadTransaction trans(FROM_HERE, GetUserShare());
984 trans.GetCryptographer()->Bootstrap(restored_key_for_bootstrapping); 941 trans.GetCryptographer()->Bootstrap(restored_key_for_bootstrapping);
985 trans.GetCryptographer()->AddObserver(this); 942 trans.GetCryptographer()->AddObserver(this);
986 } 943 }
987 944
988 // Notify that initialization is complete. Note: This should be the last to 945 // Notify that initialization is complete. Note: This should be the last to
989 // execute if |signed_in| is false. Reason being in that case we would 946 // execute if |signed_in| is false. Reason being in that case we would
990 // post a task to shutdown sync. But if this function posts any other tasks 947 // post a task to shutdown sync. But if this function posts any other tasks
991 // on the UI thread and if shutdown wins then that tasks would execute on 948 // on the UI thread and if shutdown wins then that tasks would execute on
992 // a freed pointer. This is because UI thread is not shut down. 949 // a freed pointer. This is because UI thread is not shut down.
993 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, 950 FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
994 OnInitializationComplete( 951 OnInitializationComplete(
995 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), 952 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()),
996 success)); 953 signed_in));
997 954
998 if (!success && testing_mode_ == NON_TEST) 955 if (!signed_in && testing_mode_ == NON_TEST)
999 return false; 956 return false;
1000 957
1001 sync_notifier_->AddObserver(this); 958 sync_notifier_->AddObserver(this);
1002 959
1003 return success; 960 return signed_in;
1004 } 961 }
1005 962
1006 void SyncManager::SyncInternal::UpdateCryptographerAndNigori( 963 void SyncManager::SyncInternal::UpdateCryptographerAndNigori(
1007 const std::string& chrome_version, 964 const std::string& chrome_version,
1008 const base::Closure& done_callback) { 965 const base::Closure& done_callback) {
1009 DCHECK(initialized_); 966 DCHECK(initialized_);
1010 syncer::GetSessionName( 967 syncer::GetSessionName(
1011 blocking_task_runner_, 968 blocking_task_runner_,
1012 base::Bind( 969 base::Bind(
1013 &SyncManager::SyncInternal::UpdateCryptographerAndNigoriCallback, 970 &SyncManager::SyncInternal::UpdateCryptographerAndNigoriCallback,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 allstatus_.SetCryptographerReady(cryptographer->is_ready()); 1095 allstatus_.SetCryptographerReady(cryptographer->is_ready());
1139 allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys()); 1096 allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys());
1140 debug_info_event_listener_.SetCryptographerReady(cryptographer->is_ready()); 1097 debug_info_event_listener_.SetCryptographerReady(cryptographer->is_ready());
1141 debug_info_event_listener_.SetCrytographerHasPendingKeys( 1098 debug_info_event_listener_.SetCrytographerHasPendingKeys(
1142 cryptographer->has_pending_keys()); 1099 cryptographer->has_pending_keys());
1143 } 1100 }
1144 1101
1145 void SyncManager::SyncInternal::StartSyncingNormally( 1102 void SyncManager::SyncInternal::StartSyncingNormally(
1146 const syncer::ModelSafeRoutingInfo& routing_info) { 1103 const syncer::ModelSafeRoutingInfo& routing_info) {
1147 // Start the sync scheduler. 1104 // Start the sync scheduler.
1148 if (scheduler()) { // NULL during certain unittests. 1105 if (scheduler()) { // NULL during certain unittests.
1149 // TODO(sync): We always want the newest set of routes when we switch back
1150 // to normal mode. Figure out how to enforce set_routing_info is always
1151 // appropriately set and that it's only modified when switching to normal
1152 // mode.
1153 session_context()->set_routing_info(routing_info); 1106 session_context()->set_routing_info(routing_info);
1154 scheduler()->Start(SyncScheduler::NORMAL_MODE); 1107 scheduler()->Start(SyncScheduler::NORMAL_MODE, base::Closure());
1155 } 1108 }
1156 } 1109 }
1157 1110
1158 bool SyncManager::SyncInternal::OpenDirectory() { 1111 bool SyncManager::SyncInternal::OpenDirectory() {
1159 DCHECK(!initialized_) << "Should only happen once"; 1112 DCHECK(!initialized_) << "Should only happen once";
1160 1113
1161 // Set before Open(). 1114 // Set before Open().
1162 change_observer_ = 1115 change_observer_ =
1163 syncer::MakeWeakHandle(js_mutation_event_observer_.AsWeakPtr()); 1116 syncer::MakeWeakHandle(js_mutation_event_observer_.AsWeakPtr());
1164 WeakHandle<syncable::TransactionObserver> transaction_observer( 1117 WeakHandle<syncable::TransactionObserver> transaction_observer(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 allstatus_.SetUniqueId(unique_id); 1151 allstatus_.SetUniqueId(unique_id);
1199 sync_notifier_->SetUniqueId(unique_id); 1152 sync_notifier_->SetUniqueId(unique_id);
1200 // TODO(tim): Remove once invalidation state has been migrated to new 1153 // TODO(tim): Remove once invalidation state has been migrated to new
1201 // InvalidationStateTracker store. Bug 124140. 1154 // InvalidationStateTracker store. Bug 124140.
1202 sync_notifier_->SetStateDeprecated(state); 1155 sync_notifier_->SetStateDeprecated(state);
1203 1156
1204 UpdateCredentials(credentials); 1157 UpdateCredentials(credentials);
1205 return true; 1158 return true;
1206 } 1159 }
1207 1160
1208 bool SyncManager::SyncInternal::PurgePartiallySyncedTypes() {
1209 syncer::ModelTypeSet partially_synced_types =
1210 syncer::ModelTypeSet::All();
1211 partially_synced_types.RemoveAll(InitialSyncEndedTypes());
1212 partially_synced_types.RemoveAll(GetTypesWithEmptyProgressMarkerToken(
1213 syncer::ModelTypeSet::All()));
1214
1215 UMA_HISTOGRAM_COUNTS("Sync.PartiallySyncedTypes",
1216 partially_synced_types.Size());
1217 if (partially_synced_types.Empty())
1218 return true;
1219 return directory()->PurgeEntriesWithTypeIn(partially_synced_types);
1220 }
1221
1222 void SyncManager::SyncInternal::UpdateCredentials( 1161 void SyncManager::SyncInternal::UpdateCredentials(
1223 const SyncCredentials& credentials) { 1162 const SyncCredentials& credentials) {
1224 DCHECK(thread_checker_.CalledOnValidThread()); 1163 DCHECK(thread_checker_.CalledOnValidThread());
1225 DCHECK_EQ(credentials.email, share_.name); 1164 DCHECK_EQ(credentials.email, share_.name);
1226 DCHECK(!credentials.email.empty()); 1165 DCHECK(!credentials.email.empty());
1227 DCHECK(!credentials.sync_token.empty()); 1166 DCHECK(!credentials.sync_token.empty());
1228 1167
1229 observing_ip_address_changes_ = true; 1168 observing_ip_address_changes_ = true;
1230 if (connection_manager()->set_auth_token(credentials.sync_token)) { 1169 if (connection_manager()->set_auth_token(credentials.sync_token)) {
1231 sync_notifier_->UpdateCredentials( 1170 sync_notifier_->UpdateCredentials(
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 void SyncManager::SyncInternal::AddObserver( 2333 void SyncManager::SyncInternal::AddObserver(
2395 SyncManager::Observer* observer) { 2334 SyncManager::Observer* observer) {
2396 observers_.AddObserver(observer); 2335 observers_.AddObserver(observer);
2397 } 2336 }
2398 2337
2399 void SyncManager::SyncInternal::RemoveObserver( 2338 void SyncManager::SyncInternal::RemoveObserver(
2400 SyncManager::Observer* observer) { 2339 SyncManager::Observer* observer) {
2401 observers_.RemoveObserver(observer); 2340 observers_.RemoveObserver(observer);
2402 } 2341 }
2403 2342
2404 void SyncManager::SyncInternal::SetSyncSchedulerForTest(
2405 scoped_ptr<SyncScheduler> sync_scheduler) {
2406 scheduler_ = sync_scheduler.Pass();
2407 }
2408
2409 SyncStatus SyncManager::GetDetailedStatus() const { 2343 SyncStatus SyncManager::GetDetailedStatus() const {
2410 return data_->GetStatus(); 2344 return data_->GetStatus();
2411 } 2345 }
2412 2346
2413 void SyncManager::SaveChanges() { 2347 void SyncManager::SaveChanges() {
2414 DCHECK(thread_checker_.CalledOnValidThread()); 2348 DCHECK(thread_checker_.CalledOnValidThread());
2415 data_->SaveChanges(); 2349 data_->SaveChanges();
2416 } 2350 }
2417 2351
2418 void SyncManager::SyncInternal::SaveChanges() { 2352 void SyncManager::SyncInternal::SaveChanges() {
(...skipping 10 matching lines...) Expand all
2429 data_->UpdateCryptographerAndNigori( 2363 data_->UpdateCryptographerAndNigori(
2430 chrome_version, 2364 chrome_version,
2431 done_callback); 2365 done_callback);
2432 } 2366 }
2433 2367
2434 TimeDelta SyncManager::GetNudgeDelayTimeDelta( 2368 TimeDelta SyncManager::GetNudgeDelayTimeDelta(
2435 const ModelType& model_type) { 2369 const ModelType& model_type) {
2436 return data_->GetNudgeDelayTimeDelta(model_type); 2370 return data_->GetNudgeDelayTimeDelta(model_type);
2437 } 2371 }
2438 2372
2439 void SyncManager::SetSyncSchedulerForTest(scoped_ptr<SyncScheduler> scheduler) {
2440 data_->SetSyncSchedulerForTest(scheduler.Pass());
2441 }
2442
2443 syncer::ModelTypeSet SyncManager::GetEncryptedDataTypesForTest() const { 2373 syncer::ModelTypeSet SyncManager::GetEncryptedDataTypesForTest() const {
2444 ReadTransaction trans(FROM_HERE, GetUserShare()); 2374 ReadTransaction trans(FROM_HERE, GetUserShare());
2445 return GetEncryptedTypes(&trans); 2375 return GetEncryptedTypes(&trans);
2446 } 2376 }
2447 2377
2448 bool SyncManager::ReceivedExperiment(syncer::Experiments* experiments) 2378 bool SyncManager::ReceivedExperiment(syncer::Experiments* experiments)
2449 const { 2379 const {
2450 ReadTransaction trans(FROM_HERE, GetUserShare()); 2380 ReadTransaction trans(FROM_HERE, GetUserShare());
2451 ReadNode node(&trans); 2381 ReadNode node(&trans);
2452 if (node.InitByTagLookup(kNigoriTag) != syncer::BaseNode::INIT_OK) { 2382 if (node.InitByTagLookup(kNigoriTag) != syncer::BaseNode::INIT_OK) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2522 bool InitialSyncEndedForTypes(syncer::ModelTypeSet types, 2452 bool InitialSyncEndedForTypes(syncer::ModelTypeSet types,
2523 syncer::UserShare* share) { 2453 syncer::UserShare* share) {
2524 for (syncer::ModelTypeSet::Iterator i = types.First(); 2454 for (syncer::ModelTypeSet::Iterator i = types.First();
2525 i.Good(); i.Inc()) { 2455 i.Good(); i.Inc()) {
2526 if (!share->directory->initial_sync_ended_for_type(i.Get())) 2456 if (!share->directory->initial_sync_ended_for_type(i.Get()))
2527 return false; 2457 return false;
2528 } 2458 }
2529 return true; 2459 return true;
2530 } 2460 }
2531 2461
2462 syncer::ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
2463 syncer::ModelTypeSet types,
2464 syncer::UserShare* share) {
2465 syncer::ModelTypeSet result;
2466 for (syncer::ModelTypeSet::Iterator i = types.First();
2467 i.Good(); i.Inc()) {
2468 sync_pb::DataTypeProgressMarker marker;
2469 share->directory->GetDownloadProgress(i.Get(), &marker);
2470
2471 if (marker.token().empty())
2472 result.Put(i.Get());
2473
2474 }
2475 return result;
2476 }
2477
2532 } // namespace syncer 2478 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/public/sync_manager.h ('k') | sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698