| 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_harness.h" | 5 #include "chrome/browser/sync/profile_sync_service_harness.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 DCHECK(service() != NULL) << "GetStatus(): service() is NULL."; | 756 DCHECK(service() != NULL) << "GetStatus(): service() is NULL."; |
| 757 ProfileSyncService::Status result; | 757 ProfileSyncService::Status result; |
| 758 service()->QueryDetailedSyncStatus(&result); | 758 service()->QueryDetailedSyncStatus(&result); |
| 759 return result; | 759 return result; |
| 760 } | 760 } |
| 761 | 761 |
| 762 // We use this function to share code between IsFullySynced and IsDataSynced | 762 // We use this function to share code between IsFullySynced and IsDataSynced |
| 763 // while ensuring that all conditions are evaluated using on the same snapshot. | 763 // while ensuring that all conditions are evaluated using on the same snapshot. |
| 764 bool ProfileSyncServiceHarness::IsDataSyncedImpl( | 764 bool ProfileSyncServiceHarness::IsDataSyncedImpl( |
| 765 const SyncSessionSnapshot& snap) { | 765 const SyncSessionSnapshot& snap) { |
| 766 return snap.num_simple_conflicts() == 0 && | 766 return ServiceIsPushingChanges() && |
| 767 ServiceIsPushingChanges() && | |
| 768 GetStatus().notifications_enabled && | 767 GetStatus().notifications_enabled && |
| 769 !service()->HasUnsyncedItems() && | 768 !service()->HasUnsyncedItems() && |
| 770 !snap.has_more_to_sync() && | |
| 771 !HasPendingBackendMigration(); | 769 !HasPendingBackendMigration(); |
| 772 } | 770 } |
| 773 | 771 |
| 774 bool ProfileSyncServiceHarness::IsDataSynced() { | 772 bool ProfileSyncServiceHarness::IsDataSynced() { |
| 775 if (service() == NULL) { | 773 if (service() == NULL) { |
| 776 DVLOG(1) << GetClientInfoString("IsDataSynced(): false"); | 774 DVLOG(1) << GetClientInfoString("IsDataSynced(): false"); |
| 777 return false; | 775 return false; |
| 778 } | 776 } |
| 779 | 777 |
| 780 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); | 778 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 } | 990 } |
| 993 | 991 |
| 994 std::string ProfileSyncServiceHarness::GetClientInfoString( | 992 std::string ProfileSyncServiceHarness::GetClientInfoString( |
| 995 const std::string& message) { | 993 const std::string& message) { |
| 996 std::stringstream os; | 994 std::stringstream os; |
| 997 os << profile_debug_name_ << ": " << message << ": "; | 995 os << profile_debug_name_ << ": " << message << ": "; |
| 998 if (service()) { | 996 if (service()) { |
| 999 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); | 997 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); |
| 1000 const ProfileSyncService::Status& status = GetStatus(); | 998 const ProfileSyncService::Status& status = GetStatus(); |
| 1001 // Capture select info from the sync session snapshot and syncer status. | 999 // Capture select info from the sync session snapshot and syncer status. |
| 1002 os << "has_more_to_sync: " | 1000 os << ", has_unsynced_items: " |
| 1003 << snap.has_more_to_sync() | |
| 1004 << ", has_unsynced_items: " | |
| 1005 << (service()->sync_initialized() ? service()->HasUnsyncedItems() : 0) | 1001 << (service()->sync_initialized() ? service()->HasUnsyncedItems() : 0) |
| 1006 << ", did_commit: " | 1002 << ", did_commit: " |
| 1007 << (snap.model_neutral_state().num_successful_commits == 0 && | 1003 << (snap.model_neutral_state().num_successful_commits == 0 && |
| 1008 snap.model_neutral_state().commit_result == syncer::SYNCER_OK) | 1004 snap.model_neutral_state().commit_result == syncer::SYNCER_OK) |
| 1009 << ", encryption conflicts: " | 1005 << ", encryption conflicts: " |
| 1010 << snap.num_encryption_conflicts() | 1006 << snap.num_encryption_conflicts() |
| 1011 << ", hierarchy conflicts: " | 1007 << ", hierarchy conflicts: " |
| 1012 << snap.num_hierarchy_conflicts() | 1008 << snap.num_hierarchy_conflicts() |
| 1013 << ", simple conflicts: " | |
| 1014 << snap.num_simple_conflicts() | |
| 1015 << ", server conflicts: " | 1009 << ", server conflicts: " |
| 1016 << snap.num_server_conflicts() | 1010 << snap.num_server_conflicts() |
| 1017 << ", num_updates_downloaded : " | 1011 << ", num_updates_downloaded : " |
| 1018 << snap.model_neutral_state().num_updates_downloaded_total | 1012 << snap.model_neutral_state().num_updates_downloaded_total |
| 1019 << ", passphrase_required_reason: " | 1013 << ", passphrase_required_reason: " |
| 1020 << syncer::PassphraseRequiredReasonToString( | 1014 << syncer::PassphraseRequiredReasonToString( |
| 1021 service()->passphrase_required_reason()) | 1015 service()->passphrase_required_reason()) |
| 1022 << ", notifications_enabled: " | 1016 << ", notifications_enabled: " |
| 1023 << status.notifications_enabled | 1017 << status.notifications_enabled |
| 1024 << ", service_is_pushing_changes: " | 1018 << ", service_is_pushing_changes: " |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 | 1104 |
| 1111 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 1105 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
| 1112 scoped_ptr<DictionaryValue> value( | 1106 scoped_ptr<DictionaryValue> value( |
| 1113 sync_ui_util::ConstructAboutInformation(service_)); | 1107 sync_ui_util::ConstructAboutInformation(service_)); |
| 1114 std::string service_status; | 1108 std::string service_status; |
| 1115 base::JSONWriter::WriteWithOptions(value.get(), | 1109 base::JSONWriter::WriteWithOptions(value.get(), |
| 1116 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 1110 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 1117 &service_status); | 1111 &service_status); |
| 1118 return service_status; | 1112 return service_status; |
| 1119 } | 1113 } |
| OLD | NEW |