OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 const std::string& password) { | 130 const std::string& password) { |
131 username_ = username; | 131 username_ = username; |
132 password_ = password; | 132 password_ = password; |
133 } | 133 } |
134 | 134 |
135 bool ProfileSyncServiceHarness::IsSyncAlreadySetup() { | 135 bool ProfileSyncServiceHarness::IsSyncAlreadySetup() { |
136 return profile_->HasProfileSyncService(); | 136 return profile_->HasProfileSyncService(); |
137 } | 137 } |
138 | 138 |
139 bool ProfileSyncServiceHarness::SetupSync() { | 139 bool ProfileSyncServiceHarness::SetupSync() { |
140 bool result = SetupSync(syncable::ModelEnumSet::All()); | 140 bool result = SetupSync(syncable::ModelTypeSet::All()); |
141 if (result == false) { | 141 if (result == false) { |
142 std::string status = GetServiceStatus(); | 142 std::string status = GetServiceStatus(); |
143 LOG(ERROR) << profile_debug_name_ | 143 LOG(ERROR) << profile_debug_name_ |
144 << ": SetupSync failed. Syncer status:\n" << status; | 144 << ": SetupSync failed. Syncer status:\n" << status; |
145 } else { | 145 } else { |
146 DVLOG(1) << profile_debug_name_ << ": SetupSync successful."; | 146 DVLOG(1) << profile_debug_name_ << ": SetupSync successful."; |
147 } | 147 } |
148 return result; | 148 return result; |
149 } | 149 } |
150 | 150 |
151 bool ProfileSyncServiceHarness::SetupSync( | 151 bool ProfileSyncServiceHarness::SetupSync( |
152 syncable::ModelEnumSet synced_datatypes) { | 152 syncable::ModelTypeSet synced_datatypes) { |
153 // Initialize the sync client's profile sync service object. | 153 // Initialize the sync client's profile sync service object. |
154 service_ = profile_->GetProfileSyncService(""); | 154 service_ = profile_->GetProfileSyncService(""); |
155 if (service_ == NULL) { | 155 if (service_ == NULL) { |
156 LOG(ERROR) << "SetupSync(): service_ is null."; | 156 LOG(ERROR) << "SetupSync(): service_ is null."; |
157 return false; | 157 return false; |
158 } | 158 } |
159 | 159 |
160 // Subscribe sync client to notifications from the profile sync service. | 160 // Subscribe sync client to notifications from the profile sync service. |
161 if (!service_->HasObserver(this)) | 161 if (!service_->HasObserver(this)) |
162 service_->AddObserver(this); | 162 service_->AddObserver(this); |
163 | 163 |
164 // Authenticate sync client using GAIA credentials. | 164 // Authenticate sync client using GAIA credentials. |
165 service_->signin()->StartSignIn(username_, password_, "", ""); | 165 service_->signin()->StartSignIn(username_, password_, "", ""); |
166 | 166 |
167 // Wait for the OnBackendInitialized() callback. | 167 // Wait for the OnBackendInitialized() callback. |
168 if (!AwaitBackendInitialized()) { | 168 if (!AwaitBackendInitialized()) { |
169 LOG(ERROR) << "OnBackendInitialized() not seen after " | 169 LOG(ERROR) << "OnBackendInitialized() not seen after " |
170 << kLiveSyncOperationTimeoutMs / 1000 | 170 << kLiveSyncOperationTimeoutMs / 1000 |
171 << " seconds."; | 171 << " seconds."; |
172 return false; | 172 return false; |
173 } | 173 } |
174 | 174 |
175 // Choose the datatypes to be synced. If all datatypes are to be synced, | 175 // Choose the datatypes to be synced. If all datatypes are to be synced, |
176 // set sync_everything to true; otherwise, set it to false. | 176 // set sync_everything to true; otherwise, set it to false. |
177 bool sync_everything = | 177 bool sync_everything = |
178 synced_datatypes.Equals(syncable::ModelEnumSet::All()); | 178 synced_datatypes.Equals(syncable::ModelTypeSet::All()); |
179 service()->OnUserChoseDatatypes(sync_everything, synced_datatypes); | 179 service()->OnUserChoseDatatypes(sync_everything, synced_datatypes); |
180 | 180 |
181 // Subscribe sync client to notifications from the backend migrator | 181 // Subscribe sync client to notifications from the backend migrator |
182 // (possible only after choosing data types). | 182 // (possible only after choosing data types). |
183 if (!TryListeningToMigrationEvents()) { | 183 if (!TryListeningToMigrationEvents()) { |
184 NOTREACHED(); | 184 NOTREACHED(); |
185 return false; | 185 return false; |
186 } | 186 } |
187 | 187 |
188 // Make sure that a partner client hasn't already set an explicit passphrase. | 188 // Make sure that a partner client hasn't already set an explicit passphrase. |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 445 |
446 void ProfileSyncServiceHarness::OnMigrationStateChange() { | 446 void ProfileSyncServiceHarness::OnMigrationStateChange() { |
447 // Update migration state. | 447 // Update migration state. |
448 if (HasPendingBackendMigration()) { | 448 if (HasPendingBackendMigration()) { |
449 // Merge current pending migration types into | 449 // Merge current pending migration types into |
450 // |pending_migration_types_|. | 450 // |pending_migration_types_|. |
451 pending_migration_types_.PutAll( | 451 pending_migration_types_.PutAll( |
452 service()->GetBackendMigratorForTest()-> | 452 service()->GetBackendMigratorForTest()-> |
453 GetPendingMigrationTypesForTest()); | 453 GetPendingMigrationTypesForTest()); |
454 DVLOG(1) << profile_debug_name_ << ": new pending migration types " | 454 DVLOG(1) << profile_debug_name_ << ": new pending migration types " |
455 << syncable::ModelEnumSetToString(pending_migration_types_); | 455 << syncable::ModelTypeSetToString(pending_migration_types_); |
456 } else { | 456 } else { |
457 // Merge just-finished pending migration types into | 457 // Merge just-finished pending migration types into |
458 // |migration_types_|. | 458 // |migration_types_|. |
459 migrated_types_.PutAll(pending_migration_types_); | 459 migrated_types_.PutAll(pending_migration_types_); |
460 pending_migration_types_.Clear(); | 460 pending_migration_types_.Clear(); |
461 DVLOG(1) << profile_debug_name_ << ": new migrated types " | 461 DVLOG(1) << profile_debug_name_ << ": new migrated types " |
462 << syncable::ModelEnumSetToString(migrated_types_); | 462 << syncable::ModelTypeSetToString(migrated_types_); |
463 } | 463 } |
464 RunStateChangeMachine(); | 464 RunStateChangeMachine(); |
465 } | 465 } |
466 | 466 |
467 bool ProfileSyncServiceHarness::AwaitPassphraseRequired() { | 467 bool ProfileSyncServiceHarness::AwaitPassphraseRequired() { |
468 DVLOG(1) << GetClientInfoString("AwaitPassphraseRequired"); | 468 DVLOG(1) << GetClientInfoString("AwaitPassphraseRequired"); |
469 if (wait_state_ == SYNC_DISABLED) { | 469 if (wait_state_ == SYNC_DISABLED) { |
470 LOG(ERROR) << "Sync disabled for " << profile_debug_name_ << "."; | 470 LOG(ERROR) << "Sync disabled for " << profile_debug_name_ << "."; |
471 return false; | 471 return false; |
472 } | 472 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 CHECK(status.sync_protocol_error.action == browser_sync::UNKNOWN_ACTION); | 617 CHECK(status.sync_protocol_error.action == browser_sync::UNKNOWN_ACTION); |
618 wait_state_ = WAITING_FOR_ACTIONABLE_ERROR; | 618 wait_state_ = WAITING_FOR_ACTIONABLE_ERROR; |
619 AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, | 619 AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, |
620 "Waiting for actionable error"); | 620 "Waiting for actionable error"); |
621 status = GetStatus(); | 621 status = GetStatus(); |
622 return (status.sync_protocol_error.action != browser_sync::UNKNOWN_ACTION && | 622 return (status.sync_protocol_error.action != browser_sync::UNKNOWN_ACTION && |
623 service_->unrecoverable_error_detected()); | 623 service_->unrecoverable_error_detected()); |
624 } | 624 } |
625 | 625 |
626 bool ProfileSyncServiceHarness::AwaitMigration( | 626 bool ProfileSyncServiceHarness::AwaitMigration( |
627 syncable::ModelEnumSet expected_migrated_types) { | 627 syncable::ModelTypeSet expected_migrated_types) { |
628 DVLOG(1) << GetClientInfoString("AwaitMigration"); | 628 DVLOG(1) << GetClientInfoString("AwaitMigration"); |
629 DVLOG(1) << profile_debug_name_ << ": waiting until migration is done for " | 629 DVLOG(1) << profile_debug_name_ << ": waiting until migration is done for " |
630 << syncable::ModelEnumSetToString(expected_migrated_types); | 630 << syncable::ModelTypeSetToString(expected_migrated_types); |
631 while (true) { | 631 while (true) { |
632 bool migration_finished = migrated_types_.HasAll(expected_migrated_types); | 632 bool migration_finished = migrated_types_.HasAll(expected_migrated_types); |
633 DVLOG(1) << "Migrated types " | 633 DVLOG(1) << "Migrated types " |
634 << syncable::ModelEnumSetToString(migrated_types_) | 634 << syncable::ModelTypeSetToString(migrated_types_) |
635 << (migration_finished ? " contains " : " does not contain ") | 635 << (migration_finished ? " contains " : " does not contain ") |
636 << syncable::ModelEnumSetToString(expected_migrated_types); | 636 << syncable::ModelTypeSetToString(expected_migrated_types); |
637 if (migration_finished) { | 637 if (migration_finished) { |
638 return true; | 638 return true; |
639 } | 639 } |
640 | 640 |
641 if (HasPendingBackendMigration()) { | 641 if (HasPendingBackendMigration()) { |
642 wait_state_ = WAITING_FOR_MIGRATION_TO_FINISH; | 642 wait_state_ = WAITING_FOR_MIGRATION_TO_FINISH; |
643 } else { | 643 } else { |
644 wait_state_ = WAITING_FOR_MIGRATION_TO_START; | 644 wait_state_ = WAITING_FOR_MIGRATION_TO_START; |
645 AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, | 645 AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, |
646 "Wait for migration to start"); | 646 "Wait for migration to start"); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 ProfileSyncServiceHarness* partner) { | 816 ProfileSyncServiceHarness* partner) { |
817 // TODO(akalin): Shouldn't this belong with the intersection check? | 817 // TODO(akalin): Shouldn't this belong with the intersection check? |
818 // Otherwise, this function isn't symmetric. | 818 // Otherwise, this function isn't symmetric. |
819 if (!IsFullySynced()) { | 819 if (!IsFullySynced()) { |
820 DVLOG(2) << profile_debug_name_ << ": not synced, assuming doesn't match"; | 820 DVLOG(2) << profile_debug_name_ << ": not synced, assuming doesn't match"; |
821 return false; | 821 return false; |
822 } | 822 } |
823 | 823 |
824 // Only look for a match if we have at least one enabled datatype in | 824 // Only look for a match if we have at least one enabled datatype in |
825 // common with the partner client. | 825 // common with the partner client. |
826 const syncable::ModelEnumSet common_types = | 826 const syncable::ModelTypeSet common_types = |
827 Intersection(service()->GetPreferredDataTypes(), | 827 Intersection(service()->GetPreferredDataTypes(), |
828 partner->service()->GetPreferredDataTypes()); | 828 partner->service()->GetPreferredDataTypes()); |
829 | 829 |
830 DVLOG(2) << profile_debug_name_ << ", " << partner->profile_debug_name_ | 830 DVLOG(2) << profile_debug_name_ << ", " << partner->profile_debug_name_ |
831 << ": common types are " | 831 << ": common types are " |
832 << syncable::ModelEnumSetToString(common_types); | 832 << syncable::ModelTypeSetToString(common_types); |
833 | 833 |
834 if (!common_types.Empty() && !partner->IsFullySynced()) { | 834 if (!common_types.Empty() && !partner->IsFullySynced()) { |
835 DVLOG(2) << "non-empty common types and " | 835 DVLOG(2) << "non-empty common types and " |
836 << partner->profile_debug_name_ << " isn't synced"; | 836 << partner->profile_debug_name_ << " isn't synced"; |
837 return false; | 837 return false; |
838 } | 838 } |
839 | 839 |
840 for (syncable::ModelEnumSet::Iterator i = common_types.First(); | 840 for (syncable::ModelTypeSet::Iterator i = common_types.First(); |
841 i.Good(); i.Inc()) { | 841 i.Good(); i.Inc()) { |
842 const std::string timestamp = GetUpdatedTimestamp(i.Get()); | 842 const std::string timestamp = GetUpdatedTimestamp(i.Get()); |
843 const std::string partner_timestamp = partner->GetUpdatedTimestamp(i.Get()); | 843 const std::string partner_timestamp = partner->GetUpdatedTimestamp(i.Get()); |
844 if (timestamp != partner_timestamp) { | 844 if (timestamp != partner_timestamp) { |
845 if (VLOG_IS_ON(2)) { | 845 if (VLOG_IS_ON(2)) { |
846 std::string timestamp_base64, partner_timestamp_base64; | 846 std::string timestamp_base64, partner_timestamp_base64; |
847 if (!base::Base64Encode(timestamp, ×tamp_base64)) { | 847 if (!base::Base64Encode(timestamp, ×tamp_base64)) { |
848 NOTREACHED(); | 848 NOTREACHED(); |
849 } | 849 } |
850 if (!base::Base64Encode( | 850 if (!base::Base64Encode( |
(...skipping 22 matching lines...) Expand all Loading... |
873 return NULL; | 873 return NULL; |
874 } | 874 } |
875 | 875 |
876 bool ProfileSyncServiceHarness::EnableSyncForDatatype( | 876 bool ProfileSyncServiceHarness::EnableSyncForDatatype( |
877 syncable::ModelType datatype) { | 877 syncable::ModelType datatype) { |
878 DVLOG(1) << GetClientInfoString( | 878 DVLOG(1) << GetClientInfoString( |
879 "EnableSyncForDatatype(" | 879 "EnableSyncForDatatype(" |
880 + std::string(syncable::ModelTypeToString(datatype)) + ")"); | 880 + std::string(syncable::ModelTypeToString(datatype)) + ")"); |
881 | 881 |
882 if (wait_state_ == SYNC_DISABLED) { | 882 if (wait_state_ == SYNC_DISABLED) { |
883 return SetupSync(syncable::ModelEnumSet(datatype)); | 883 return SetupSync(syncable::ModelTypeSet(datatype)); |
884 } | 884 } |
885 | 885 |
886 if (service() == NULL) { | 886 if (service() == NULL) { |
887 LOG(ERROR) << "EnableSyncForDatatype(): service() is null."; | 887 LOG(ERROR) << "EnableSyncForDatatype(): service() is null."; |
888 return false; | 888 return false; |
889 } | 889 } |
890 | 890 |
891 syncable::ModelEnumSet synced_datatypes = | 891 syncable::ModelTypeSet synced_datatypes = |
892 service()->GetPreferredDataTypes(); | 892 service()->GetPreferredDataTypes(); |
893 if (synced_datatypes.Has(datatype)) { | 893 if (synced_datatypes.Has(datatype)) { |
894 DVLOG(1) << "EnableSyncForDatatype(): Sync already enabled for datatype " | 894 DVLOG(1) << "EnableSyncForDatatype(): Sync already enabled for datatype " |
895 << syncable::ModelTypeToString(datatype) | 895 << syncable::ModelTypeToString(datatype) |
896 << " on " << profile_debug_name_ << "."; | 896 << " on " << profile_debug_name_ << "."; |
897 return true; | 897 return true; |
898 } | 898 } |
899 | 899 |
900 synced_datatypes.Put(syncable::ModelTypeFromInt(datatype)); | 900 synced_datatypes.Put(syncable::ModelTypeFromInt(datatype)); |
901 service()->OnUserChoseDatatypes(false, synced_datatypes); | 901 service()->OnUserChoseDatatypes(false, synced_datatypes); |
(...skipping 12 matching lines...) Expand all Loading... |
914 syncable::ModelType datatype) { | 914 syncable::ModelType datatype) { |
915 DVLOG(1) << GetClientInfoString( | 915 DVLOG(1) << GetClientInfoString( |
916 "DisableSyncForDatatype(" | 916 "DisableSyncForDatatype(" |
917 + std::string(syncable::ModelTypeToString(datatype)) + ")"); | 917 + std::string(syncable::ModelTypeToString(datatype)) + ")"); |
918 | 918 |
919 if (service() == NULL) { | 919 if (service() == NULL) { |
920 LOG(ERROR) << "DisableSyncForDatatype(): service() is null."; | 920 LOG(ERROR) << "DisableSyncForDatatype(): service() is null."; |
921 return false; | 921 return false; |
922 } | 922 } |
923 | 923 |
924 syncable::ModelEnumSet synced_datatypes = | 924 syncable::ModelTypeSet synced_datatypes = |
925 service()->GetPreferredDataTypes(); | 925 service()->GetPreferredDataTypes(); |
926 if (!synced_datatypes.Has(datatype)) { | 926 if (!synced_datatypes.Has(datatype)) { |
927 DVLOG(1) << "DisableSyncForDatatype(): Sync already disabled for datatype " | 927 DVLOG(1) << "DisableSyncForDatatype(): Sync already disabled for datatype " |
928 << syncable::ModelTypeToString(datatype) | 928 << syncable::ModelTypeToString(datatype) |
929 << " on " << profile_debug_name_ << "."; | 929 << " on " << profile_debug_name_ << "."; |
930 return true; | 930 return true; |
931 } | 931 } |
932 | 932 |
933 synced_datatypes.Remove(datatype); | 933 synced_datatypes.Remove(datatype); |
934 service()->OnUserChoseDatatypes(false, synced_datatypes); | 934 service()->OnUserChoseDatatypes(false, synced_datatypes); |
(...skipping 13 matching lines...) Expand all Loading... |
948 | 948 |
949 if (wait_state_ == SYNC_DISABLED) { | 949 if (wait_state_ == SYNC_DISABLED) { |
950 return SetupSync(); | 950 return SetupSync(); |
951 } | 951 } |
952 | 952 |
953 if (service() == NULL) { | 953 if (service() == NULL) { |
954 LOG(ERROR) << "EnableSyncForAllDatatypes(): service() is null."; | 954 LOG(ERROR) << "EnableSyncForAllDatatypes(): service() is null."; |
955 return false; | 955 return false; |
956 } | 956 } |
957 | 957 |
958 service()->OnUserChoseDatatypes(true, syncable::ModelEnumSet::All()); | 958 service()->OnUserChoseDatatypes(true, syncable::ModelTypeSet::All()); |
959 if (AwaitFullSyncCompletion("Datatype reconfiguration.")) { | 959 if (AwaitFullSyncCompletion("Datatype reconfiguration.")) { |
960 DVLOG(1) << "EnableSyncForAllDatatypes(): Enabled sync for all datatypes " | 960 DVLOG(1) << "EnableSyncForAllDatatypes(): Enabled sync for all datatypes " |
961 << "on " << profile_debug_name_ << "."; | 961 << "on " << profile_debug_name_ << "."; |
962 return true; | 962 return true; |
963 } | 963 } |
964 | 964 |
965 DVLOG(0) << GetClientInfoString("EnableSyncForAllDatatypes failed"); | 965 DVLOG(0) << GetClientInfoString("EnableSyncForAllDatatypes failed"); |
966 return false; | 966 return false; |
967 } | 967 } |
968 | 968 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 } else { | 1024 } else { |
1025 os << "Sync service not available"; | 1025 os << "Sync service not available"; |
1026 } | 1026 } |
1027 return os.str(); | 1027 return os.str(); |
1028 } | 1028 } |
1029 | 1029 |
1030 // TODO(zea): Rename this EnableEncryption, since we no longer turn on | 1030 // TODO(zea): Rename this EnableEncryption, since we no longer turn on |
1031 // encryption for individual types but for all. | 1031 // encryption for individual types but for all. |
1032 bool ProfileSyncServiceHarness::EnableEncryptionForType( | 1032 bool ProfileSyncServiceHarness::EnableEncryptionForType( |
1033 syncable::ModelType type) { | 1033 syncable::ModelType type) { |
1034 const syncable::ModelEnumSet encrypted_types = | 1034 const syncable::ModelTypeSet encrypted_types = |
1035 service_->GetEncryptedDataTypes(); | 1035 service_->GetEncryptedDataTypes(); |
1036 if (encrypted_types.Has(type)) | 1036 if (encrypted_types.Has(type)) |
1037 return true; | 1037 return true; |
1038 service_->EnableEncryptEverything(); | 1038 service_->EnableEncryptEverything(); |
1039 | 1039 |
1040 // In order to kick off the encryption we have to reconfigure. Just grab the | 1040 // In order to kick off the encryption we have to reconfigure. Just grab the |
1041 // currently synced types and use them. | 1041 // currently synced types and use them. |
1042 const syncable::ModelEnumSet synced_datatypes = | 1042 const syncable::ModelTypeSet synced_datatypes = |
1043 service_->GetPreferredDataTypes(); | 1043 service_->GetPreferredDataTypes(); |
1044 bool sync_everything = | 1044 bool sync_everything = |
1045 synced_datatypes.Equals(syncable::ModelEnumSet::All()); | 1045 synced_datatypes.Equals(syncable::ModelTypeSet::All()); |
1046 service_->OnUserChoseDatatypes(sync_everything, synced_datatypes); | 1046 service_->OnUserChoseDatatypes(sync_everything, synced_datatypes); |
1047 | 1047 |
1048 // Wait some time to let the enryption finish. | 1048 // Wait some time to let the enryption finish. |
1049 return WaitForTypeEncryption(type); | 1049 return WaitForTypeEncryption(type); |
1050 } | 1050 } |
1051 | 1051 |
1052 bool ProfileSyncServiceHarness::WaitForTypeEncryption( | 1052 bool ProfileSyncServiceHarness::WaitForTypeEncryption( |
1053 syncable::ModelType type) { | 1053 syncable::ModelType type) { |
1054 // The correctness of this if condition depends on the ordering of its | 1054 // The correctness of this if condition depends on the ordering of its |
1055 // sub-expressions. See crbug.com/95619. | 1055 // sub-expressions. See crbug.com/95619. |
(...skipping 11 matching lines...) Expand all Loading... |
1067 if (!AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason)) { | 1067 if (!AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason)) { |
1068 LOG(ERROR) << "Did not receive EncryptionComplete notification after" | 1068 LOG(ERROR) << "Did not receive EncryptionComplete notification after" |
1069 << kLiveSyncOperationTimeoutMs / 1000 | 1069 << kLiveSyncOperationTimeoutMs / 1000 |
1070 << " seconds."; | 1070 << " seconds."; |
1071 return false; | 1071 return false; |
1072 } | 1072 } |
1073 return IsTypeEncrypted(type); | 1073 return IsTypeEncrypted(type); |
1074 } | 1074 } |
1075 | 1075 |
1076 bool ProfileSyncServiceHarness::IsTypeEncrypted(syncable::ModelType type) { | 1076 bool ProfileSyncServiceHarness::IsTypeEncrypted(syncable::ModelType type) { |
1077 const syncable::ModelEnumSet encrypted_types = | 1077 const syncable::ModelTypeSet encrypted_types = |
1078 service_->GetEncryptedDataTypes(); | 1078 service_->GetEncryptedDataTypes(); |
1079 bool is_type_encrypted = service_->GetEncryptedDataTypes().Has(type); | 1079 bool is_type_encrypted = service_->GetEncryptedDataTypes().Has(type); |
1080 DVLOG(2) << syncable::ModelTypeToString(type) << " is " | 1080 DVLOG(2) << syncable::ModelTypeToString(type) << " is " |
1081 << (is_type_encrypted ? "" : "not ") << "encrypted; " | 1081 << (is_type_encrypted ? "" : "not ") << "encrypted; " |
1082 << "encrypted types = " | 1082 << "encrypted types = " |
1083 << syncable::ModelEnumSetToString(encrypted_types); | 1083 << syncable::ModelTypeSetToString(encrypted_types); |
1084 return is_type_encrypted; | 1084 return is_type_encrypted; |
1085 } | 1085 } |
1086 | 1086 |
1087 bool ProfileSyncServiceHarness::IsTypeRunning(syncable::ModelType type) { | 1087 bool ProfileSyncServiceHarness::IsTypeRunning(syncable::ModelType type) { |
1088 browser_sync::DataTypeController::StateMap state_map; | 1088 browser_sync::DataTypeController::StateMap state_map; |
1089 service_->GetDataTypeControllerStates(&state_map); | 1089 service_->GetDataTypeControllerStates(&state_map); |
1090 return (state_map.count(type) != 0 && | 1090 return (state_map.count(type) != 0 && |
1091 state_map[type] == browser_sync::DataTypeController::RUNNING); | 1091 state_map[type] == browser_sync::DataTypeController::RUNNING); |
1092 } | 1092 } |
1093 | 1093 |
1094 bool ProfileSyncServiceHarness::IsTypePreferred(syncable::ModelType type) { | 1094 bool ProfileSyncServiceHarness::IsTypePreferred(syncable::ModelType type) { |
1095 return service_->GetPreferredDataTypes().Has(type); | 1095 return service_->GetPreferredDataTypes().Has(type); |
1096 } | 1096 } |
1097 | 1097 |
1098 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 1098 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
1099 DictionaryValue value; | 1099 DictionaryValue value; |
1100 sync_ui_util::ConstructAboutInformation(service_, &value); | 1100 sync_ui_util::ConstructAboutInformation(service_, &value); |
1101 std::string service_status; | 1101 std::string service_status; |
1102 base::JSONWriter::Write(&value, true, &service_status); | 1102 base::JSONWriter::Write(&value, true, &service_status); |
1103 return service_status; | 1103 return service_status; |
1104 } | 1104 } |
OLD | NEW |