 Chromium Code Reviews
 Chromium Code Reviews Issue 12033093:
  sync: Implementation of Priority Preferences.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 12033093:
  sync: Implementation of Priority Preferences.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 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 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 817 if (auto_start_enabled_ && !FirstSetupInProgress()) { | 817 if (auto_start_enabled_ && !FirstSetupInProgress()) { | 
| 818 // Backend is initialized but we're not in sync setup, so this must be an | 818 // Backend is initialized but we're not in sync setup, so this must be an | 
| 819 // autostart - mark our sync setup as completed and we'll start syncing | 819 // autostart - mark our sync setup as completed and we'll start syncing | 
| 820 // below. | 820 // below. | 
| 821 SetSyncSetupCompleted(); | 821 SetSyncSetupCompleted(); | 
| 822 NotifyObservers(); | 822 NotifyObservers(); | 
| 823 } | 823 } | 
| 824 | 824 | 
| 825 if (HasSyncSetupCompleted()) { | 825 if (HasSyncSetupCompleted()) { | 
| 826 ConfigureDataTypeManager(); | 826 ConfigureDataTypeManager(); | 
| 827 ConfigurePriorityDataTypes(); | |
| 
Nicolas Zea
2013/03/05 01:15:44
this should be before the normal types
 
albertb
2013/03/15 21:08:45
Done.
 | |
| 827 } else { | 828 } else { | 
| 828 DCHECK(FirstSetupInProgress()); | 829 DCHECK(FirstSetupInProgress()); | 
| 829 } | 830 } | 
| 830 } | 831 } | 
| 831 | 832 | 
| 832 void ProfileSyncService::OnSyncCycleCompleted() { | 833 void ProfileSyncService::OnSyncCycleCompleted() { | 
| 833 UpdateLastSyncedTime(); | 834 UpdateLastSyncedTime(); | 
| 834 if (GetSessionModelAssociator()) { | 835 if (GetSessionModelAssociator()) { | 
| 835 // Trigger garbage collection of old sessions now that we've downloaded | 836 // Trigger garbage collection of old sessions now that we've downloaded | 
| 836 // any new session data. TODO(zea): Have this be a notification the session | 837 // any new session data. TODO(zea): Have this be a notification the session | 
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1261 | 1262 | 
| 1262 bool ProfileSyncService::FirstSetupInProgress() const { | 1263 bool ProfileSyncService::FirstSetupInProgress() const { | 
| 1263 return !HasSyncSetupCompleted() && setup_in_progress_; | 1264 return !HasSyncSetupCompleted() && setup_in_progress_; | 
| 1264 } | 1265 } | 
| 1265 | 1266 | 
| 1266 void ProfileSyncService::SetSetupInProgress(bool setup_in_progress) { | 1267 void ProfileSyncService::SetSetupInProgress(bool setup_in_progress) { | 
| 1267 bool was_in_progress = setup_in_progress_; | 1268 bool was_in_progress = setup_in_progress_; | 
| 1268 setup_in_progress_ = setup_in_progress; | 1269 setup_in_progress_ = setup_in_progress; | 
| 1269 if (!setup_in_progress && was_in_progress) { | 1270 if (!setup_in_progress && was_in_progress) { | 
| 1270 if (sync_initialized()) { | 1271 if (sync_initialized()) { | 
| 1272 ConfigurePriorityDataTypes(); | |
| 1271 ReconfigureDatatypeManager(); | 1273 ReconfigureDatatypeManager(); | 
| 1272 } | 1274 } | 
| 1273 } | 1275 } | 
| 1274 NotifyObservers(); | 1276 NotifyObservers(); | 
| 1275 } | 1277 } | 
| 1276 | 1278 | 
| 1277 bool ProfileSyncService::sync_initialized() const { | 1279 bool ProfileSyncService::sync_initialized() const { | 
| 1278 return backend_initialized_; | 1280 return backend_initialized_; | 
| 1279 } | 1281 } | 
| 1280 | 1282 | 
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1404 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); | 1406 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); | 
| 1405 const syncer::ModelTypeSet registered_preferred_types = | 1407 const syncer::ModelTypeSet registered_preferred_types = | 
| 1406 Intersection(registered_types, preferred_types); | 1408 Intersection(registered_types, preferred_types); | 
| 1407 sync_prefs_.SetPreferredDataTypes(registered_types, | 1409 sync_prefs_.SetPreferredDataTypes(registered_types, | 
| 1408 registered_preferred_types); | 1410 registered_preferred_types); | 
| 1409 | 1411 | 
| 1410 // Now reconfigure the DTM. | 1412 // Now reconfigure the DTM. | 
| 1411 ReconfigureDatatypeManager(); | 1413 ReconfigureDatatypeManager(); | 
| 1412 } | 1414 } | 
| 1413 | 1415 | 
| 1416 // TODO(albertb): Extract a common method. | |
| 1414 syncer::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const { | 1417 syncer::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const { | 
| 1415 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); | 1418 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); | 
| 1416 const syncer::ModelTypeSet preferred_types = | 1419 const syncer::ModelTypeSet preferred_types = | 
| 1417 sync_prefs_.GetPreferredDataTypes(registered_types); | 1420 sync_prefs_.GetPreferredDataTypes(registered_types); | 
| 1418 const syncer::ModelTypeSet failed_types = | 1421 const syncer::ModelTypeSet failed_types = | 
| 1419 failed_datatypes_handler_.GetFailedTypes(); | 1422 failed_datatypes_handler_.GetFailedTypes(); | 
| 1420 return Difference(preferred_types, failed_types); | 1423 return Difference(preferred_types, failed_types); | 
| 1421 } | 1424 } | 
| 1422 | 1425 | 
| 1423 syncer::ModelTypeSet ProfileSyncService::GetRegisteredDataTypes() const { | 1426 syncer::ModelTypeSet ProfileSyncService::GetRegisteredDataTypes() const { | 
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1450 const syncer::BaseTransaction* trans) const { | 1453 const syncer::BaseTransaction* trans) const { | 
| 1451 return backend_.get() && backend_->IsCryptographerReady(trans); | 1454 return backend_.get() && backend_->IsCryptographerReady(trans); | 
| 1452 } | 1455 } | 
| 1453 | 1456 | 
| 1454 SyncBackendHost* ProfileSyncService::GetBackendForTest() { | 1457 SyncBackendHost* ProfileSyncService::GetBackendForTest() { | 
| 1455 // We don't check |backend_initialized_|; we assume the test class | 1458 // We don't check |backend_initialized_|; we assume the test class | 
| 1456 // knows what it's doing. | 1459 // knows what it's doing. | 
| 1457 return backend_.get(); | 1460 return backend_.get(); | 
| 1458 } | 1461 } | 
| 1459 | 1462 | 
| 1463 void ProfileSyncService::ConfigurePriorityDataTypes() { | |
| 1464 const syncer::ModelTypeSet priority_types = | |
| 1465 Intersection(GetPreferredDataTypes(), syncer::PriorityUserTypes()); | |
| 1466 data_type_manager_->Configure(priority_types, | |
| 1467 syncer::CONFIGURE_REASON_RECONFIGURATION); | |
| 1468 } | |
| 1469 | |
| 1460 void ProfileSyncService::ConfigureDataTypeManager() { | 1470 void ProfileSyncService::ConfigureDataTypeManager() { | 
| 1461 // Don't configure datatypes if the setup UI is still on the screen - this | 1471 // Don't configure datatypes if the setup UI is still on the screen - this | 
| 1462 // is to help multi-screen setting UIs (like iOS) where they don't want to | 1472 // is to help multi-screen setting UIs (like iOS) where they don't want to | 
| 1463 // start syncing data until the user is done configuring encryption options, | 1473 // start syncing data until the user is done configuring encryption options, | 
| 1464 // etc. ReconfigureDatatypeManager() will get called again once the UI calls | 1474 // etc. ReconfigureDatatypeManager() will get called again once the UI calls | 
| 1465 // SetSetupInProgress(false). | 1475 // SetSetupInProgress(false). | 
| 1466 if (setup_in_progress_) | 1476 if (setup_in_progress_) | 
| 1467 return; | 1477 return; | 
| 1468 | 1478 | 
| 1469 bool restart = false; | 1479 bool restart = false; | 
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1962 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. | 1972 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. | 
| 1963 ProfileSyncService* old_this = this; | 1973 ProfileSyncService* old_this = this; | 
| 1964 this->~ProfileSyncService(); | 1974 this->~ProfileSyncService(); | 
| 1965 new(old_this) ProfileSyncService( | 1975 new(old_this) ProfileSyncService( | 
| 1966 new ProfileSyncComponentsFactoryImpl(profile, | 1976 new ProfileSyncComponentsFactoryImpl(profile, | 
| 1967 CommandLine::ForCurrentProcess()), | 1977 CommandLine::ForCurrentProcess()), | 
| 1968 profile, | 1978 profile, | 
| 1969 signin, | 1979 signin, | 
| 1970 behavior); | 1980 behavior); | 
| 1971 } | 1981 } | 
| OLD | NEW |