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

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

Issue 10387158: Merge 136934 - Notify sync observers whenever preferred types change (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1132/src/
Patch Set: Created 8 years, 7 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 | « no previous file | chrome/browser/sync/profile_sync_service_harness.h » ('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 "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 <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 456 }
457 457
458 registrar_.Remove( 458 registrar_.Remove(
459 this, 459 this,
460 chrome::NOTIFICATION_SYNC_CONFIGURE_START, 460 chrome::NOTIFICATION_SYNC_CONFIGURE_START,
461 content::Source<DataTypeManager>(data_type_manager_.get())); 461 content::Source<DataTypeManager>(data_type_manager_.get()));
462 registrar_.Remove( 462 registrar_.Remove(
463 this, 463 this,
464 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, 464 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE,
465 content::Source<DataTypeManager>(data_type_manager_.get())); 465 content::Source<DataTypeManager>(data_type_manager_.get()));
466 registrar_.Remove(
467 this,
468 chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED,
469 content::Source<DataTypeManager>(data_type_manager_.get()));
466 data_type_manager_.reset(); 470 data_type_manager_.reset();
467 } 471 }
468 472
469 // Shutdown the migrator before the backend to ensure it doesn't pull a null 473 // Shutdown the migrator before the backend to ensure it doesn't pull a null
470 // snapshot. 474 // snapshot.
471 migrator_.reset(); 475 migrator_.reset();
472 sync_js_controller_.AttachJsBackend(WeakHandle<JsBackend>()); 476 sync_js_controller_.AttachJsBackend(WeakHandle<JsBackend>());
473 477
474 // Move aside the backend so nobody else tries to use it while we are 478 // Move aside the backend so nobody else tries to use it while we are
475 // shutting it down. 479 // shutting it down.
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 NOTREACHED(); 1125 NOTREACHED();
1122 return; 1126 return;
1123 } 1127 }
1124 1128
1125 UpdateSelectedTypesHistogram(sync_everything, chosen_types); 1129 UpdateSelectedTypesHistogram(sync_everything, chosen_types);
1126 sync_prefs_.SetKeepEverythingSynced(sync_everything); 1130 sync_prefs_.SetKeepEverythingSynced(sync_everything);
1127 1131
1128 failed_datatypes_handler_.OnUserChoseDatatypes(); 1132 failed_datatypes_handler_.OnUserChoseDatatypes();
1129 ChangePreferredDataTypes(chosen_types); 1133 ChangePreferredDataTypes(chosen_types);
1130 AcknowledgeSyncedTypes(); 1134 AcknowledgeSyncedTypes();
1135 NotifyObservers();
1131 } 1136 }
1132 1137
1133 void ProfileSyncService::ChangePreferredDataTypes( 1138 void ProfileSyncService::ChangePreferredDataTypes(
1134 syncable::ModelTypeSet preferred_types) { 1139 syncable::ModelTypeSet preferred_types) {
1135 1140
1136 DVLOG(1) << "ChangePreferredDataTypes invoked"; 1141 DVLOG(1) << "ChangePreferredDataTypes invoked";
1137 const syncable::ModelTypeSet registered_types = GetRegisteredDataTypes(); 1142 const syncable::ModelTypeSet registered_types = GetRegisteredDataTypes();
1138 const syncable::ModelTypeSet registered_preferred_types = 1143 const syncable::ModelTypeSet registered_preferred_types =
1139 Intersection(registered_types, preferred_types); 1144 Intersection(registered_types, preferred_types);
1140 sync_prefs_.SetPreferredDataTypes(registered_types, 1145 sync_prefs_.SetPreferredDataTypes(registered_types,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 restart = true; 1191 restart = true;
1187 data_type_manager_.reset( 1192 data_type_manager_.reset(
1188 factory_->CreateDataTypeManager(backend_.get(), 1193 factory_->CreateDataTypeManager(backend_.get(),
1189 &data_type_controllers_)); 1194 &data_type_controllers_));
1190 registrar_.Add(this, 1195 registrar_.Add(this,
1191 chrome::NOTIFICATION_SYNC_CONFIGURE_START, 1196 chrome::NOTIFICATION_SYNC_CONFIGURE_START,
1192 content::Source<DataTypeManager>(data_type_manager_.get())); 1197 content::Source<DataTypeManager>(data_type_manager_.get()));
1193 registrar_.Add(this, 1198 registrar_.Add(this,
1194 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, 1199 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE,
1195 content::Source<DataTypeManager>(data_type_manager_.get())); 1200 content::Source<DataTypeManager>(data_type_manager_.get()));
1201 registrar_.Add(this,
1202 chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED,
1203 content::Source<DataTypeManager>(data_type_manager_.get()));
1196 1204
1197 // We create the migrator at the same time. 1205 // We create the migrator at the same time.
1198 migrator_.reset( 1206 migrator_.reset(
1199 new browser_sync::BackendMigrator( 1207 new browser_sync::BackendMigrator(
1200 profile_->GetDebugName(), GetUserShare(), 1208 profile_->GetDebugName(), GetUserShare(),
1201 this, data_type_manager_.get(), 1209 this, data_type_manager_.get(),
1202 base::Bind(&ProfileSyncService::StartSyncingWithServer, 1210 base::Bind(&ProfileSyncService::StartSyncingWithServer,
1203 base::Unretained(this)))); 1211 base::Unretained(this))));
1204 } 1212 }
1205 1213
1206 const syncable::ModelTypeSet types = GetPreferredDataTypes(); 1214 const syncable::ModelTypeSet types = GetPreferredDataTypes();
1207 if (IsPassphraseRequiredForDecryption()) { 1215 if (IsPassphraseRequiredForDecryption()) {
1208 // We need a passphrase still. We don't bother to attempt to configure 1216 // We need a passphrase still. We don't bother to attempt to configure
1209 // until we receive an OnPassphraseAccepted (which triggers a configure). 1217 // until we receive an OnPassphraseAccepted (which triggers a configure).
1210 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " 1218 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out "
1211 << "because a passphrase required"; 1219 << "because a passphrase required";
1220 NotifyObservers();
1212 return; 1221 return;
1213 } 1222 }
1214 sync_api::ConfigureReason reason = sync_api::CONFIGURE_REASON_UNKNOWN; 1223 sync_api::ConfigureReason reason = sync_api::CONFIGURE_REASON_UNKNOWN;
1215 if (!HasSyncSetupCompleted()) { 1224 if (!HasSyncSetupCompleted()) {
1216 reason = sync_api::CONFIGURE_REASON_NEW_CLIENT; 1225 reason = sync_api::CONFIGURE_REASON_NEW_CLIENT;
1217 } else if (restart == false || 1226 } else if (restart == false ||
1218 sync_api::InitialSyncEndedForTypes(types, GetUserShare())) { 1227 sync_api::InitialSyncEndedForTypes(types, GetUserShare())) {
1219 reason = sync_api::CONFIGURE_REASON_RECONFIGURATION; 1228 reason = sync_api::CONFIGURE_REASON_RECONFIGURATION;
1220 } else { 1229 } else {
1221 DCHECK(restart); 1230 DCHECK(restart);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 DisableForUser(); 1392 DisableForUser();
1384 } else if (HasSyncSetupCompleted() && AreCredentialsAvailable()) { 1393 } else if (HasSyncSetupCompleted() && AreCredentialsAvailable()) {
1385 StartUp(); 1394 StartUp();
1386 } 1395 }
1387 } 1396 }
1388 1397
1389 void ProfileSyncService::Observe(int type, 1398 void ProfileSyncService::Observe(int type,
1390 const content::NotificationSource& source, 1399 const content::NotificationSource& source,
1391 const content::NotificationDetails& details) { 1400 const content::NotificationDetails& details) {
1392 switch (type) { 1401 switch (type) {
1393 case chrome::NOTIFICATION_SYNC_CONFIGURE_START: { 1402 case chrome::NOTIFICATION_SYNC_CONFIGURE_START:
1403 case chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED:
1394 NotifyObservers(); 1404 NotifyObservers();
1395 // TODO(sync): Maybe toast? 1405 // TODO(sync): Maybe toast?
1396 break; 1406 break;
1397 }
1398 case chrome::NOTIFICATION_SYNC_CONFIGURE_DONE: { 1407 case chrome::NOTIFICATION_SYNC_CONFIGURE_DONE: {
1399 // We should have cleared our cached passphrase before we get here (in 1408 // We should have cleared our cached passphrase before we get here (in
1400 // OnBackendInitialized()). 1409 // OnBackendInitialized()).
1401 DCHECK(cached_passphrase_.empty()); 1410 DCHECK(cached_passphrase_.empty());
1402 1411
1403 DataTypeManager::ConfigureResult* result = 1412 DataTypeManager::ConfigureResult* result =
1404 content::Details<DataTypeManager::ConfigureResult>(details).ptr(); 1413 content::Details<DataTypeManager::ConfigureResult>(details).ptr();
1405 1414
1406 configure_status_ = result->status; 1415 configure_status_ = result->status;
1407 DVLOG(1) << "PSS SYNC_CONFIGURE_DONE called with status: " 1416 DVLOG(1) << "PSS SYNC_CONFIGURE_DONE called with status: "
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1664 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1656 ProfileSyncService* old_this = this; 1665 ProfileSyncService* old_this = this;
1657 this->~ProfileSyncService(); 1666 this->~ProfileSyncService();
1658 new(old_this) ProfileSyncService( 1667 new(old_this) ProfileSyncService(
1659 new ProfileSyncComponentsFactoryImpl(profile, 1668 new ProfileSyncComponentsFactoryImpl(profile,
1660 CommandLine::ForCurrentProcess()), 1669 CommandLine::ForCurrentProcess()),
1661 profile, 1670 profile,
1662 signin, 1671 signin,
1663 behavior); 1672 behavior);
1664 } 1673 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/profile_sync_service_harness.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698