| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 return BACKUP_USER_DATA; | 1542 return BACKUP_USER_DATA; |
| 1543 } else if (backend_mode_ == ROLLBACK) { | 1543 } else if (backend_mode_ == ROLLBACK) { |
| 1544 return ROLLBACK_USER_DATA; | 1544 return ROLLBACK_USER_DATA; |
| 1545 } else if (backend_.get() && !HasSyncSetupCompleted()) { | 1545 } else if (backend_.get() && !HasSyncSetupCompleted()) { |
| 1546 return SETUP_INCOMPLETE; | 1546 return SETUP_INCOMPLETE; |
| 1547 } else if ( | 1547 } else if ( |
| 1548 backend_.get() && HasSyncSetupCompleted() && | 1548 backend_.get() && HasSyncSetupCompleted() && |
| 1549 directory_data_type_manager_.get() && | 1549 directory_data_type_manager_.get() && |
| 1550 directory_data_type_manager_->state() == DataTypeManager::STOPPED) { | 1550 directory_data_type_manager_->state() == DataTypeManager::STOPPED) { |
| 1551 return DATATYPES_NOT_INITIALIZED; | 1551 return DATATYPES_NOT_INITIALIZED; |
| 1552 } else if (SyncActive()) { | 1552 } else if (IsSyncActive()) { |
| 1553 return INITIALIZED; | 1553 return INITIALIZED; |
| 1554 } | 1554 } |
| 1555 return UNKNOWN_ERROR; | 1555 return UNKNOWN_ERROR; |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 std::string ProfileSyncService::QuerySyncStatusSummaryString() { | 1558 std::string ProfileSyncService::QuerySyncStatusSummaryString() { |
| 1559 SyncStatusSummary status = QuerySyncStatusSummary(); | 1559 SyncStatusSummary status = QuerySyncStatusSummary(); |
| 1560 | 1560 |
| 1561 std::string config_status_str = | 1561 std::string config_status_str = |
| 1562 configure_status_ != DataTypeManager::UNKNOWN ? | 1562 configure_status_ != DataTypeManager::UNKNOWN ? |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1619 // This method is a no-op if |setup_in_progress_| remains unchanged. | 1619 // This method is a no-op if |setup_in_progress_| remains unchanged. |
| 1620 if (startup_controller_->setup_in_progress() == setup_in_progress) | 1620 if (startup_controller_->setup_in_progress() == setup_in_progress) |
| 1621 return; | 1621 return; |
| 1622 | 1622 |
| 1623 startup_controller_->set_setup_in_progress(setup_in_progress); | 1623 startup_controller_->set_setup_in_progress(setup_in_progress); |
| 1624 if (!setup_in_progress && backend_initialized()) | 1624 if (!setup_in_progress && backend_initialized()) |
| 1625 ReconfigureDatatypeManager(); | 1625 ReconfigureDatatypeManager(); |
| 1626 NotifyObservers(); | 1626 NotifyObservers(); |
| 1627 } | 1627 } |
| 1628 | 1628 |
| 1629 bool ProfileSyncService::SyncActive() const { | 1629 bool ProfileSyncService::IsSyncActive() const { |
| 1630 return backend_initialized_ && backend_mode_ == SYNC && | 1630 return backend_initialized_ && backend_mode_ == SYNC && |
| 1631 directory_data_type_manager_ && | 1631 directory_data_type_manager_ && |
| 1632 directory_data_type_manager_->state() != DataTypeManager::STOPPED; | 1632 directory_data_type_manager_->state() != DataTypeManager::STOPPED; |
| 1633 } | 1633 } |
| 1634 | 1634 |
| 1635 bool ProfileSyncService::backend_initialized() const { | 1635 bool ProfileSyncService::backend_initialized() const { |
| 1636 return backend_initialized_; | 1636 return backend_initialized_; |
| 1637 } | 1637 } |
| 1638 | 1638 |
| 1639 ProfileSyncService::BackendMode ProfileSyncService::backend_mode() const { | 1639 ProfileSyncService::BackendMode ProfileSyncService::backend_mode() const { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 | 1779 |
| 1780 // Now reconfigure the DTM. | 1780 // Now reconfigure the DTM. |
| 1781 ReconfigureDatatypeManager(); | 1781 ReconfigureDatatypeManager(); |
| 1782 | 1782 |
| 1783 // TODO(rlarocque): Reconfigure the NonBlockingDataTypeManager, too. Blocked | 1783 // TODO(rlarocque): Reconfigure the NonBlockingDataTypeManager, too. Blocked |
| 1784 // on crbug.com/368834. Until that bug is fixed, it's difficult to tell | 1784 // on crbug.com/368834. Until that bug is fixed, it's difficult to tell |
| 1785 // which types should be enabled and when. | 1785 // which types should be enabled and when. |
| 1786 } | 1786 } |
| 1787 | 1787 |
| 1788 syncer::ModelTypeSet ProfileSyncService::GetActiveDataTypes() const { | 1788 syncer::ModelTypeSet ProfileSyncService::GetActiveDataTypes() const { |
| 1789 if (!SyncActive() || !ConfigurationDone()) | 1789 if (!IsSyncActive() || !ConfigurationDone()) |
| 1790 return syncer::ModelTypeSet(); | 1790 return syncer::ModelTypeSet(); |
| 1791 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); | 1791 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); |
| 1792 const syncer::ModelTypeSet failed_types = | 1792 const syncer::ModelTypeSet failed_types = |
| 1793 data_type_status_table_.GetFailedTypes(); | 1793 data_type_status_table_.GetFailedTypes(); |
| 1794 return Difference(preferred_types, failed_types); | 1794 return Difference(preferred_types, failed_types); |
| 1795 } | 1795 } |
| 1796 | 1796 |
| 1797 syncer::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const { | 1797 syncer::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const { |
| 1798 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); | 1798 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); |
| 1799 const syncer::ModelTypeSet preferred_types = | 1799 const syncer::ModelTypeSet preferred_types = |
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2748 } else { | 2748 } else { |
| 2749 UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningBeforeCleanShutdown", | 2749 UMA_HISTOGRAM_COUNTS("Sync.MemoryPressureWarningBeforeCleanShutdown", |
| 2750 warning_received); | 2750 warning_received); |
| 2751 } | 2751 } |
| 2752 } | 2752 } |
| 2753 sync_prefs_.SetMemoryPressureWarningCount(0); | 2753 sync_prefs_.SetMemoryPressureWarningCount(0); |
| 2754 // Will set to true during a clean shutdown, so crash or something else will | 2754 // Will set to true during a clean shutdown, so crash or something else will |
| 2755 // remain this as false. | 2755 // remain this as false. |
| 2756 sync_prefs_.SetCleanShutdown(false); | 2756 sync_prefs_.SetCleanShutdown(false); |
| 2757 } | 2757 } |
| OLD | NEW |