| 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 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/sync/about_sync_util.h" | 25 #include "chrome/browser/sync/about_sync_util.h" |
| 26 #include "chrome/browser/sync/glue/data_type_controller.h" | 26 #include "chrome/browser/sync/glue/data_type_controller.h" |
| 27 #include "chrome/browser/sync/profile_sync_service_factory.h" | 27 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "sync/internal_api/public/base/progress_marker_map.h" | 29 #include "sync/internal_api/public/base/progress_marker_map.h" |
| 30 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 30 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
| 31 #include "sync/internal_api/public/util/sync_string_conversions.h" | 31 #include "sync/internal_api/public/util/sync_string_conversions.h" |
| 32 | 32 |
| 33 using syncer::sessions::SyncSessionSnapshot; | 33 using syncer::sessions::SyncSessionSnapshot; |
| 34 | 34 |
| 35 namespace { |
| 36 |
| 35 // TODO(rsimha): Remove the following lines once crbug.com/91863 is fixed. | 37 // TODO(rsimha): Remove the following lines once crbug.com/91863 is fixed. |
| 36 // The amount of time for which we wait for a live sync operation to complete. | 38 // The amount of time for which we wait for a live sync operation to complete. |
| 37 static const int kLiveSyncOperationTimeoutMs = 45000; | 39 static const int kLiveSyncOperationTimeoutMs = 45000; |
| 38 | 40 |
| 39 // The amount of time we wait for test cases that verify exponential backoff. | 41 // The amount of time we wait for test cases that verify exponential backoff. |
| 40 static const int kExponentialBackoffVerificationTimeoutMs = 60000; | 42 static const int kExponentialBackoffVerificationTimeoutMs = 60000; |
| 41 | 43 |
| 44 syncer::ModelTypeSet GetUserVisibleTypes() { |
| 45 syncer::ModelTypeSet user_visible_types(syncer::UserTypes()); |
| 46 user_visible_types.Remove(syncer::APP_NOTIFICATIONS); |
| 47 user_visible_types.Remove(syncer::APP_SETTINGS); |
| 48 user_visible_types.Remove(syncer::AUTOFILL_PROFILE); |
| 49 user_visible_types.Remove(syncer::EXTENSION_SETTINGS); |
| 50 user_visible_types.Remove(syncer::SEARCH_ENGINES); |
| 51 user_visible_types.Remove(syncer::SESSIONS); |
| 52 user_visible_types.Remove(syncer::HISTORY_DELETE_DIRECTIVES); |
| 53 return user_visible_types; |
| 54 } |
| 55 |
| 56 } |
| 57 |
| 42 // Simple class to implement a timeout using PostDelayedTask. If it is not | 58 // Simple class to implement a timeout using PostDelayedTask. If it is not |
| 43 // aborted before picked up by a message queue, then it asserts with the message | 59 // aborted before picked up by a message queue, then it asserts with the message |
| 44 // provided. This class is not thread safe. | 60 // provided. This class is not thread safe. |
| 45 class StateChangeTimeoutEvent | 61 class StateChangeTimeoutEvent |
| 46 : public base::RefCountedThreadSafe<StateChangeTimeoutEvent> { | 62 : public base::RefCountedThreadSafe<StateChangeTimeoutEvent> { |
| 47 public: | 63 public: |
| 48 StateChangeTimeoutEvent(ProfileSyncServiceHarness* caller, | 64 StateChangeTimeoutEvent(ProfileSyncServiceHarness* caller, |
| 49 const std::string& message); | 65 const std::string& message); |
| 50 | 66 |
| 51 // The entry point to the class from PostDelayedTask. | 67 // The entry point to the class from PostDelayedTask. |
| (...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 } | 971 } |
| 956 | 972 |
| 957 syncer::ModelTypeSet synced_datatypes = service()->GetPreferredDataTypes(); | 973 syncer::ModelTypeSet synced_datatypes = service()->GetPreferredDataTypes(); |
| 958 if (!synced_datatypes.Has(datatype)) { | 974 if (!synced_datatypes.Has(datatype)) { |
| 959 DVLOG(1) << "DisableSyncForDatatype(): Sync already disabled for datatype " | 975 DVLOG(1) << "DisableSyncForDatatype(): Sync already disabled for datatype " |
| 960 << syncer::ModelTypeToString(datatype) | 976 << syncer::ModelTypeToString(datatype) |
| 961 << " on " << profile_debug_name_ << "."; | 977 << " on " << profile_debug_name_ << "."; |
| 962 return true; | 978 return true; |
| 963 } | 979 } |
| 964 | 980 |
| 981 synced_datatypes.RetainAll(GetUserVisibleTypes()); |
| 965 synced_datatypes.Remove(datatype); | 982 synced_datatypes.Remove(datatype); |
| 966 service()->OnUserChoseDatatypes(false, synced_datatypes); | 983 service()->OnUserChoseDatatypes(false, synced_datatypes); |
| 967 if (AwaitFullSyncCompletion("Datatype reconfiguration.")) { | 984 if (AwaitFullSyncCompletion("Datatype reconfiguration.")) { |
| 968 DVLOG(1) << "DisableSyncForDatatype(): Disabled sync for datatype " | 985 DVLOG(1) << "DisableSyncForDatatype(): Disabled sync for datatype " |
| 969 << syncer::ModelTypeToString(datatype) | 986 << syncer::ModelTypeToString(datatype) |
| 970 << " on " << profile_debug_name_ << "."; | 987 << " on " << profile_debug_name_ << "."; |
| 971 return true; | 988 return true; |
| 972 } | 989 } |
| 973 | 990 |
| 974 DVLOG(0) << GetClientInfoString("DisableSyncForDatatype failed"); | 991 DVLOG(0) << GetClientInfoString("DisableSyncForDatatype failed"); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 | 1156 |
| 1140 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 1157 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
| 1141 scoped_ptr<DictionaryValue> value( | 1158 scoped_ptr<DictionaryValue> value( |
| 1142 sync_ui_util::ConstructAboutInformation(service_)); | 1159 sync_ui_util::ConstructAboutInformation(service_)); |
| 1143 std::string service_status; | 1160 std::string service_status; |
| 1144 base::JSONWriter::WriteWithOptions(value.get(), | 1161 base::JSONWriter::WriteWithOptions(value.get(), |
| 1145 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 1162 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 1146 &service_status); | 1163 &service_status); |
| 1147 return service_status; | 1164 return service_status; |
| 1148 } | 1165 } |
| OLD | NEW |