| 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 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 const syncer::BaseTransaction* trans) const { | 1506 const syncer::BaseTransaction* trans) const { |
| 1507 return backend_.get() && backend_->IsCryptographerReady(trans); | 1507 return backend_.get() && backend_->IsCryptographerReady(trans); |
| 1508 } | 1508 } |
| 1509 | 1509 |
| 1510 SyncBackendHost* ProfileSyncService::GetBackendForTest() { | 1510 SyncBackendHost* ProfileSyncService::GetBackendForTest() { |
| 1511 // We don't check |backend_initialized_|; we assume the test class | 1511 // We don't check |backend_initialized_|; we assume the test class |
| 1512 // knows what it's doing. | 1512 // knows what it's doing. |
| 1513 return backend_.get(); | 1513 return backend_.get(); |
| 1514 } | 1514 } |
| 1515 | 1515 |
| 1516 void ProfileSyncService::ConfigurePriorityDataTypes() { |
| 1517 const syncer::ModelTypeSet priority_types = |
| 1518 Intersection(GetPreferredDataTypes(), syncer::PriorityUserTypes()); |
| 1519 if (!priority_types.Empty()) { |
| 1520 data_type_manager_->Configure(priority_types, |
| 1521 syncer::CONFIGURE_REASON_RECONFIGURATION); |
| 1522 } |
| 1523 } |
| 1524 |
| 1516 void ProfileSyncService::ConfigureDataTypeManager() { | 1525 void ProfileSyncService::ConfigureDataTypeManager() { |
| 1517 // Don't configure datatypes if the setup UI is still on the screen - this | 1526 // Don't configure datatypes if the setup UI is still on the screen - this |
| 1518 // is to help multi-screen setting UIs (like iOS) where they don't want to | 1527 // is to help multi-screen setting UIs (like iOS) where they don't want to |
| 1519 // start syncing data until the user is done configuring encryption options, | 1528 // start syncing data until the user is done configuring encryption options, |
| 1520 // etc. ReconfigureDatatypeManager() will get called again once the UI calls | 1529 // etc. ReconfigureDatatypeManager() will get called again once the UI calls |
| 1521 // SetSetupInProgress(false). | 1530 // SetSetupInProgress(false). |
| 1522 if (setup_in_progress_) | 1531 if (setup_in_progress_) |
| 1523 return; | 1532 return; |
| 1524 | 1533 |
| 1525 bool restart = false; | 1534 bool restart = false; |
| 1526 if (!data_type_manager_.get()) { | 1535 if (!data_type_manager_.get()) { |
| 1527 restart = true; | 1536 restart = true; |
| 1528 data_type_manager_.reset( | 1537 data_type_manager_.reset( |
| 1529 factory_->CreateDataTypeManager(debug_info_listener_, | 1538 factory_->CreateDataTypeManager(debug_info_listener_, |
| 1530 backend_.get(), | 1539 backend_.get(), |
| 1531 &data_type_controllers_, | 1540 &data_type_controllers_, |
| 1532 this, | 1541 this, |
| 1533 &failed_datatypes_handler_)); | 1542 &failed_datatypes_handler_)); |
| 1534 | 1543 |
| 1535 // We create the migrator at the same time. | 1544 // We create the migrator at the same time. |
| 1536 migrator_.reset( | 1545 migrator_.reset( |
| 1537 new browser_sync::BackendMigrator( | 1546 new browser_sync::BackendMigrator( |
| 1538 profile_->GetDebugName(), GetUserShare(), | 1547 profile_->GetDebugName(), GetUserShare(), |
| 1539 this, data_type_manager_.get(), | 1548 this, data_type_manager_.get(), |
| 1540 base::Bind(&ProfileSyncService::StartSyncingWithServer, | 1549 base::Bind(&ProfileSyncService::StartSyncingWithServer, |
| 1541 base::Unretained(this)))); | 1550 base::Unretained(this)))); |
| 1542 } | 1551 } |
| 1552 ConfigurePriorityDataTypes(); |
| 1543 | 1553 |
| 1544 #if defined(OS_ANDROID) | 1554 #if defined(OS_ANDROID) |
| 1545 if (GetPreferredDataTypes().Has(syncer::PASSWORDS) && | 1555 if (GetPreferredDataTypes().Has(syncer::PASSWORDS) && |
| 1546 !ShouldEnablePasswordSyncForAndroid()) { | 1556 !ShouldEnablePasswordSyncForAndroid()) { |
| 1547 DisableBrokenDatatype(syncer::PASSWORDS, FROM_HERE, "Not supported."); | 1557 DisableBrokenDatatype(syncer::PASSWORDS, FROM_HERE, "Not supported."); |
| 1548 } | 1558 } |
| 1549 #endif | 1559 #endif |
| 1550 | 1560 |
| 1551 const syncer::ModelTypeSet types = GetPreferredDataTypes(); | 1561 const syncer::ModelTypeSet types = GetPreferredDataTypes(); |
| 1552 if (IsPassphraseRequiredForDecryption()) { | 1562 if (IsPassphraseRequiredForDecryption()) { |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2014 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 2024 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
| 2015 ProfileSyncService* old_this = this; | 2025 ProfileSyncService* old_this = this; |
| 2016 this->~ProfileSyncService(); | 2026 this->~ProfileSyncService(); |
| 2017 new(old_this) ProfileSyncService( | 2027 new(old_this) ProfileSyncService( |
| 2018 new ProfileSyncComponentsFactoryImpl(profile, | 2028 new ProfileSyncComponentsFactoryImpl(profile, |
| 2019 CommandLine::ForCurrentProcess()), | 2029 CommandLine::ForCurrentProcess()), |
| 2020 profile, | 2030 profile, |
| 2021 signin, | 2031 signin, |
| 2022 behavior); | 2032 behavior); |
| 2023 } | 2033 } |
| OLD | NEW |