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

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

Issue 12033093: sync: Implementation of Priority Preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 818
819 if (auto_start_enabled_ && !FirstSetupInProgress()) { 819 if (auto_start_enabled_ && !FirstSetupInProgress()) {
820 // Backend is initialized but we're not in sync setup, so this must be an 820 // Backend is initialized but we're not in sync setup, so this must be an
821 // autostart - mark our sync setup as completed and we'll start syncing 821 // autostart - mark our sync setup as completed and we'll start syncing
822 // below. 822 // below.
823 SetSyncSetupCompleted(); 823 SetSyncSetupCompleted();
824 NotifyObservers(); 824 NotifyObservers();
825 } 825 }
826 826
827 if (HasSyncSetupCompleted()) { 827 if (HasSyncSetupCompleted()) {
828 const syncer::ModelTypeSet priority_types = GetPriorityDataTypes();
Nicolas Zea 2013/02/25 23:47:47 how about just intersecting the preferred datatype
albertb 2013/03/01 22:01:56 Done.
829 data_type_manager_->Configure(priority_types,
830 syncer::CONFIGURE_REASON_RECONFIGURATION);
828 ConfigureDataTypeManager(); 831 ConfigureDataTypeManager();
829 } else { 832 } else {
830 DCHECK(FirstSetupInProgress()); 833 DCHECK(FirstSetupInProgress());
831 } 834 }
832 } 835 }
833 836
834 void ProfileSyncService::OnSyncCycleCompleted() { 837 void ProfileSyncService::OnSyncCycleCompleted() {
835 UpdateLastSyncedTime(); 838 UpdateLastSyncedTime();
836 if (GetSessionModelAssociator()) { 839 if (GetSessionModelAssociator()) {
837 // Trigger garbage collection of old sessions now that we've downloaded 840 // Trigger garbage collection of old sessions now that we've downloaded
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); 1409 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
1407 const syncer::ModelTypeSet registered_preferred_types = 1410 const syncer::ModelTypeSet registered_preferred_types =
1408 Intersection(registered_types, preferred_types); 1411 Intersection(registered_types, preferred_types);
1409 sync_prefs_.SetPreferredDataTypes(registered_types, 1412 sync_prefs_.SetPreferredDataTypes(registered_types,
1410 registered_preferred_types); 1413 registered_preferred_types);
1411 1414
1412 // Now reconfigure the DTM. 1415 // Now reconfigure the DTM.
1413 ReconfigureDatatypeManager(); 1416 ReconfigureDatatypeManager();
1414 } 1417 }
1415 1418
1419 // TODO(albertb): Extract a common method.
1416 syncer::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const { 1420 syncer::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const {
1417 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); 1421 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
1418 const syncer::ModelTypeSet preferred_types = 1422 const syncer::ModelTypeSet preferred_types =
1419 sync_prefs_.GetPreferredDataTypes(registered_types); 1423 sync_prefs_.GetPreferredDataTypes(registered_types);
1420 const syncer::ModelTypeSet failed_types = 1424 const syncer::ModelTypeSet failed_types =
1421 failed_datatypes_handler_.GetFailedTypes(); 1425 failed_datatypes_handler_.GetFailedTypes();
1422 return Difference(preferred_types, failed_types); 1426 return Difference(preferred_types, failed_types);
1423 } 1427 }
1424 1428
1429 syncer::ModelTypeSet ProfileSyncService::GetPriorityDataTypes() const {
1430 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
1431 const syncer::ModelTypeSet preferred_types =
1432 sync_prefs_.GetPreferredDataTypes(registered_types);
1433 const syncer::ModelTypeSet failed_types =
1434 failed_datatypes_handler_.GetFailedTypes();
1435 return Difference(Intersection(preferred_types, syncer::PriorityUserTypes()),
1436 failed_types);
1437 }
1438
1425 syncer::ModelTypeSet ProfileSyncService::GetRegisteredDataTypes() const { 1439 syncer::ModelTypeSet ProfileSyncService::GetRegisteredDataTypes() const {
1426 syncer::ModelTypeSet registered_types; 1440 syncer::ModelTypeSet registered_types;
1427 // The data_type_controllers_ are determined by command-line flags; that's 1441 // The data_type_controllers_ are determined by command-line flags; that's
1428 // effectively what controls the values returned here. 1442 // effectively what controls the values returned here.
1429 for (DataTypeController::TypeMap::const_iterator it = 1443 for (DataTypeController::TypeMap::const_iterator it =
1430 data_type_controllers_.begin(); 1444 data_type_controllers_.begin();
1431 it != data_type_controllers_.end(); ++it) { 1445 it != data_type_controllers_.end(); ++it) {
1432 registered_types.Put(it->first); 1446 registered_types.Put(it->first);
1433 } 1447 }
1434 return registered_types; 1448 return registered_types;
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1978 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1965 ProfileSyncService* old_this = this; 1979 ProfileSyncService* old_this = this;
1966 this->~ProfileSyncService(); 1980 this->~ProfileSyncService();
1967 new(old_this) ProfileSyncService( 1981 new(old_this) ProfileSyncService(
1968 new ProfileSyncComponentsFactoryImpl(profile, 1982 new ProfileSyncComponentsFactoryImpl(profile,
1969 CommandLine::ForCurrentProcess()), 1983 CommandLine::ForCurrentProcess()),
1970 profile, 1984 profile,
1971 signin, 1985 signin,
1972 behavior); 1986 behavior);
1973 } 1987 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698