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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 1024553010: [Sync] Add support for immediately enabling wallet datatype (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests Created 5 years, 9 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 "chrome/browser/sync/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 directory_data_type_manager_->ResetDataTypeErrors(); 951 directory_data_type_manager_->ResetDataTypeErrors();
952 952
953 } 953 }
954 954
955 void ProfileSyncService::ClearUnrecoverableError() { 955 void ProfileSyncService::ClearUnrecoverableError() {
956 unrecoverable_error_reason_ = ERROR_REASON_UNSET; 956 unrecoverable_error_reason_ = ERROR_REASON_UNSET;
957 unrecoverable_error_message_.clear(); 957 unrecoverable_error_message_.clear();
958 unrecoverable_error_location_ = tracked_objects::Location(); 958 unrecoverable_error_location_ = tracked_objects::Location();
959 } 959 }
960 960
961 void ProfileSyncService::RegisterNewDataType(syncer::ModelType data_type) {
962 if (directory_data_type_controllers_.count(data_type) > 0)
963 return;
964 NOTREACHED();
965 }
966
967 // An invariant has been violated. Transition to an error state where we try 961 // An invariant has been violated. Transition to an error state where we try
968 // to do as little work as possible, to avoid further corruption or crashes. 962 // to do as little work as possible, to avoid further corruption or crashes.
969 void ProfileSyncService::OnUnrecoverableError( 963 void ProfileSyncService::OnUnrecoverableError(
970 const tracked_objects::Location& from_here, 964 const tracked_objects::Location& from_here,
971 const std::string& message) { 965 const std::string& message) {
972 // Unrecoverable errors that arrive via the syncer::UnrecoverableErrorHandler 966 // Unrecoverable errors that arrive via the syncer::UnrecoverableErrorHandler
973 // interface are assumed to originate within the syncer. 967 // interface are assumed to originate within the syncer.
974 unrecoverable_error_reason_ = ERROR_REASON_SYNCER; 968 unrecoverable_error_reason_ = ERROR_REASON_SYNCER;
975 OnUnrecoverableErrorImpl(from_here, message, true); 969 OnUnrecoverableErrorImpl(from_here, message, true);
976 } 970 }
(...skipping 17 matching lines...) Expand all
994 988
995 // Shut all data types down. 989 // Shut all data types down.
996 base::MessageLoop::current()->PostTask(FROM_HERE, 990 base::MessageLoop::current()->PostTask(FROM_HERE,
997 base::Bind(&ProfileSyncService::ShutdownImpl, 991 base::Bind(&ProfileSyncService::ShutdownImpl,
998 weak_factory_.GetWeakPtr(), 992 weak_factory_.GetWeakPtr(),
999 delete_sync_database ? 993 delete_sync_database ?
1000 syncer::DISABLE_SYNC : syncer::STOP_SYNC)); 994 syncer::DISABLE_SYNC : syncer::STOP_SYNC));
1001 } 995 }
1002 996
1003 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) { 997 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) {
1004 DCHECK(backend_initialized_); 998 if (!backend_initialized_)
999 return;
1005 directory_data_type_manager_->ReenableType(type); 1000 directory_data_type_manager_->ReenableType(type);
1006 } 1001 }
1007 1002
1008 void ProfileSyncService::UpdateBackendInitUMA(bool success) { 1003 void ProfileSyncService::UpdateBackendInitUMA(bool success) {
1009 if (backend_mode_ != SYNC) 1004 if (backend_mode_ != SYNC)
1010 return; 1005 return;
1011 1006
1012 is_first_time_sync_configure_ = !HasSyncSetupCompleted(); 1007 is_first_time_sync_configure_ = !HasSyncSetupCompleted();
1013 1008
1014 if (is_first_time_sync_configure_) { 1009 if (is_first_time_sync_configure_) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 1147
1153 void ProfileSyncService::OnExperimentsChanged( 1148 void ProfileSyncService::OnExperimentsChanged(
1154 const syncer::Experiments& experiments) { 1149 const syncer::Experiments& experiments) {
1155 if (current_experiments_.Matches(experiments)) 1150 if (current_experiments_.Matches(experiments))
1156 return; 1151 return;
1157 1152
1158 current_experiments_ = experiments; 1153 current_experiments_ = experiments;
1159 1154
1160 profile()->GetPrefs()->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, 1155 profile()->GetPrefs()->SetBoolean(prefs::kInvalidationServiceUseGCMChannel,
1161 experiments.gcm_invalidations_enabled); 1156 experiments.gcm_invalidations_enabled);
1162 profile()->GetPrefs()->SetBoolean( 1157 // profile()->GetPrefs()->SetBoolean(
maniscalco 2015/03/25 00:31:48 Is this intentionally commented out or should it b
Nicolas Zea 2015/03/25 00:41:17 Blarg, this was from manual testing before uploadi
1163 autofill::prefs::kAutofillWalletSyncExperimentEnabled, 1158 // autofill::prefs::kAutofillWalletSyncExperimentEnabled,
1164 experiments.wallet_sync_enabled); 1159 // experiments.wallet_sync_enabled);
1165
1166 // If this is a first time sync for a client, this will be called before
1167 // OnBackendInitialized() to ensure the new datatypes are available at sync
1168 // setup. As a result, the migrator won't exist yet. This is fine because for
1169 // first time sync cases we're only concerned with making the datatype
1170 // available.
1171 if (migrator_.get() &&
1172 migrator_->state() != browser_sync::BackendMigrator::IDLE) {
1173 DVLOG(1) << "Dropping OnExperimentsChanged due to migrator busy.";
1174 return;
1175 }
1176
1177 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
1178 syncer::ModelTypeSet to_add;
1179 const syncer::ModelTypeSet to_register =
1180 Difference(to_add, registered_types);
1181 DVLOG(2) << "OnExperimentsChanged called with types: "
1182 << syncer::ModelTypeSetToString(to_add);
1183 DVLOG(2) << "Enabling types: " << syncer::ModelTypeSetToString(to_register);
maniscalco 2015/03/25 00:31:47 Was autofill wallet the only type for which we wan
Nicolas Zea 2015/03/25 00:41:17 Yes. This code was effectively dead code previousl
1184
1185 for (syncer::ModelTypeSet::Iterator it = to_register.First();
1186 it.Good(); it.Inc()) {
1187 // Received notice to enable experimental type. Check if the type is
1188 // registered, and if not register a new datatype controller.
1189 RegisterNewDataType(it.Get());
1190 }
1191
1192 // Check if the user has "Keep Everything Synced" enabled. If so, we want
1193 // to turn on all experimental types if they're not already on. Otherwise we
1194 // leave them off.
1195 // Note: if any types are already registered, we don't turn them on. This
1196 // covers the case where we're already in the process of reconfiguring
1197 // to turn an experimental type on.
1198 if (sync_prefs_.HasKeepEverythingSynced()) {
1199 // Mark all data types as preferred.
1200 sync_prefs_.SetPreferredDataTypes(registered_types, registered_types);
1201
1202 // Only automatically turn on types if we have already finished set up.
1203 // Otherwise, just leave the experimental types on by default.
1204 if (!to_register.Empty() && HasSyncSetupCompleted() && migrator_) {
1205 DVLOG(1) << "Dynamically enabling new datatypes: "
1206 << syncer::ModelTypeSetToString(to_register);
1207 OnMigrationNeededForTypes(to_register);
1208 }
1209 }
1210 } 1160 }
1211 1161
1212 void ProfileSyncService::UpdateAuthErrorState(const AuthError& error) { 1162 void ProfileSyncService::UpdateAuthErrorState(const AuthError& error) {
1213 is_auth_in_progress_ = false; 1163 is_auth_in_progress_ = false;
1214 last_auth_error_ = error; 1164 last_auth_error_ = error;
1215 1165
1216 NotifyObservers(); 1166 NotifyObservers();
1217 } 1167 }
1218 1168
1219 namespace { 1169 namespace {
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 std::string birthday; 2710 std::string birthday;
2761 syncer::UserShare* user_share = GetUserShare(); 2711 syncer::UserShare* user_share = GetUserShare();
2762 if (user_share && user_share->directory.get()) { 2712 if (user_share && user_share->directory.get()) {
2763 birthday = user_share->directory->store_birthday(); 2713 birthday = user_share->directory->store_birthday();
2764 } 2714 }
2765 if (!access_token_.empty() && !cache_guid.empty() && !birthday.empty()) { 2715 if (!access_token_.empty() && !cache_guid.empty() && !birthday.empty()) {
2766 sync_stopped_reporter_->ReportSyncStopped( 2716 sync_stopped_reporter_->ReportSyncStopped(
2767 access_token_, cache_guid, birthday); 2717 access_token_, cache_guid, birthday);
2768 } 2718 }
2769 } 2719 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698