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

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: another rebase 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 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); 1406 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
1407 const syncer::ModelTypeSet registered_preferred_types = 1407 const syncer::ModelTypeSet registered_preferred_types =
1408 Intersection(registered_types, preferred_types); 1408 Intersection(registered_types, preferred_types);
1409 sync_prefs_.SetPreferredDataTypes(registered_types, 1409 sync_prefs_.SetPreferredDataTypes(registered_types,
1410 registered_preferred_types); 1410 registered_preferred_types);
1411 1411
1412 // Now reconfigure the DTM. 1412 // Now reconfigure the DTM.
1413 ReconfigureDatatypeManager(); 1413 ReconfigureDatatypeManager();
1414 } 1414 }
1415 1415
1416 // TODO(albertb): Extract a common method.
1416 syncer::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const { 1417 syncer::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const {
1417 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); 1418 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
1418 const syncer::ModelTypeSet preferred_types = 1419 const syncer::ModelTypeSet preferred_types =
1419 sync_prefs_.GetPreferredDataTypes(registered_types); 1420 sync_prefs_.GetPreferredDataTypes(registered_types);
1420 const syncer::ModelTypeSet failed_types = 1421 const syncer::ModelTypeSet failed_types =
1421 failed_datatypes_handler_.GetFailedTypes(); 1422 failed_datatypes_handler_.GetFailedTypes();
1422 return Difference(preferred_types, failed_types); 1423 return Difference(preferred_types, failed_types);
1423 } 1424 }
1424 1425
1426 syncer::ModelTypeSet ProfileSyncService::GetPriorityDataTypes() const {
1427 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
1428 const syncer::ModelTypeSet preferred_types =
1429 sync_prefs_.GetPreferredDataTypes(registered_types);
1430 const syncer::ModelTypeSet failed_types =
1431 failed_datatypes_handler_.GetFailedTypes();
1432 return Difference(Intersection(preferred_types, syncer::PriorityUserTypes()),
1433 failed_types);
1434 }
1435
1425 syncer::ModelTypeSet ProfileSyncService::GetRegisteredDataTypes() const { 1436 syncer::ModelTypeSet ProfileSyncService::GetRegisteredDataTypes() const {
1426 syncer::ModelTypeSet registered_types; 1437 syncer::ModelTypeSet registered_types;
1427 // The data_type_controllers_ are determined by command-line flags; that's 1438 // The data_type_controllers_ are determined by command-line flags; that's
1428 // effectively what controls the values returned here. 1439 // effectively what controls the values returned here.
1429 for (DataTypeController::TypeMap::const_iterator it = 1440 for (DataTypeController::TypeMap::const_iterator it =
1430 data_type_controllers_.begin(); 1441 data_type_controllers_.begin();
1431 it != data_type_controllers_.end(); ++it) { 1442 it != data_type_controllers_.end(); ++it) {
1432 registered_types.Put(it->first); 1443 registered_types.Put(it->first);
1433 } 1444 }
1434 return registered_types; 1445 return registered_types;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 base::Unretained(this)))); 1498 base::Unretained(this))));
1488 } 1499 }
1489 1500
1490 #if defined(OS_ANDROID) 1501 #if defined(OS_ANDROID)
1491 if (GetPreferredDataTypes().Has(syncer::PASSWORDS) && 1502 if (GetPreferredDataTypes().Has(syncer::PASSWORDS) &&
1492 !ShouldEnablePasswordSyncForAndroid()) { 1503 !ShouldEnablePasswordSyncForAndroid()) {
1493 DisableBrokenDatatype(syncer::PASSWORDS, FROM_HERE, "Not supported."); 1504 DisableBrokenDatatype(syncer::PASSWORDS, FROM_HERE, "Not supported.");
1494 } 1505 }
1495 #endif 1506 #endif
1496 1507
1508 const syncer::ModelTypeSet priority_types = GetPriorityDataTypes();
1509 data_type_manager_->Configure(priority_types,
Nicolas Zea 2013/02/21 23:41:11 hmm, I'm not sure this is the right place to do th
albertb 2013/02/22 20:08:47 Done.
1510 syncer::CONFIGURE_REASON_RECONFIGURATION);
1511
1497 const syncer::ModelTypeSet types = GetPreferredDataTypes(); 1512 const syncer::ModelTypeSet types = GetPreferredDataTypes();
1498 if (IsPassphraseRequiredForDecryption()) { 1513 if (IsPassphraseRequiredForDecryption()) {
1499 // We need a passphrase still. We don't bother to attempt to configure 1514 // We need a passphrase still. We don't bother to attempt to configure
1500 // until we receive an OnPassphraseAccepted (which triggers a configure). 1515 // until we receive an OnPassphraseAccepted (which triggers a configure).
1501 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " 1516 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out "
1502 << "because a passphrase required"; 1517 << "because a passphrase required";
1503 NotifyObservers(); 1518 NotifyObservers();
1504 return; 1519 return;
1505 } 1520 }
1506 syncer::ConfigureReason reason = syncer::CONFIGURE_REASON_UNKNOWN; 1521 syncer::ConfigureReason reason = syncer::CONFIGURE_REASON_UNKNOWN;
(...skipping 457 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. 1979 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1965 ProfileSyncService* old_this = this; 1980 ProfileSyncService* old_this = this;
1966 this->~ProfileSyncService(); 1981 this->~ProfileSyncService();
1967 new(old_this) ProfileSyncService( 1982 new(old_this) ProfileSyncService(
1968 new ProfileSyncComponentsFactoryImpl(profile, 1983 new ProfileSyncComponentsFactoryImpl(profile,
1969 CommandLine::ForCurrentProcess()), 1984 CommandLine::ForCurrentProcess()),
1970 profile, 1985 profile,
1971 signin, 1986 signin,
1972 behavior); 1987 behavior);
1973 } 1988 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698