Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chrome/browser/sync/profile_sync_service_harness.cc

Issue 11961030: [Sync] Make SESSIONS an implicit type (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 940
925 DVLOG(0) << GetClientInfoString("EnableSyncForDatatype failed"); 941 DVLOG(0) << GetClientInfoString("EnableSyncForDatatype failed");
926 return false; 942 return false;
927 } 943 }
928 944
929 bool ProfileSyncServiceHarness::DisableSyncForDatatype( 945 bool ProfileSyncServiceHarness::DisableSyncForDatatype(
930 syncer::ModelType datatype) { 946 syncer::ModelType datatype) {
931 DVLOG(1) << GetClientInfoString( 947 DVLOG(1) << GetClientInfoString(
932 "DisableSyncForDatatype(" 948 "DisableSyncForDatatype("
933 + std::string(syncer::ModelTypeToString(datatype)) + ")"); 949 + std::string(syncer::ModelTypeToString(datatype)) + ")");
934
935 if (service() == NULL) { 950 if (service() == NULL) {
936 LOG(ERROR) << "DisableSyncForDatatype(): service() is null."; 951 LOG(ERROR) << "DisableSyncForDatatype(): service() is null.";
937 return false; 952 return false;
938 } 953 }
939 954
940 syncer::ModelTypeSet synced_datatypes = service()->GetPreferredDataTypes(); 955 syncer::ModelTypeSet synced_datatypes = service()->GetPreferredDataTypes();
941 if (!synced_datatypes.Has(datatype)) { 956 if (!synced_datatypes.Has(datatype)) {
942 DVLOG(1) << "DisableSyncForDatatype(): Sync already disabled for datatype " 957 DVLOG(1) << "DisableSyncForDatatype(): Sync already disabled for datatype "
943 << syncer::ModelTypeToString(datatype) 958 << syncer::ModelTypeToString(datatype)
944 << " on " << profile_debug_name_ << "."; 959 << " on " << profile_debug_name_ << ".";
945 return true; 960 return true;
946 } 961 }
947 962
963 synced_datatypes.RetainAll(GetUserVisibleTypes());
948 synced_datatypes.Remove(datatype); 964 synced_datatypes.Remove(datatype);
965
949 service()->OnUserChoseDatatypes(false, synced_datatypes); 966 service()->OnUserChoseDatatypes(false, synced_datatypes);
950 if (AwaitFullSyncCompletion("Datatype reconfiguration.")) { 967 if (AwaitFullSyncCompletion("Datatype reconfiguration.")) {
951 DVLOG(1) << "DisableSyncForDatatype(): Disabled sync for datatype " 968 DVLOG(1) << "DisableSyncForDatatype(): Disabled sync for datatype "
952 << syncer::ModelTypeToString(datatype) 969 << syncer::ModelTypeToString(datatype)
953 << " on " << profile_debug_name_ << "."; 970 << " on " << profile_debug_name_ << ".";
954 return true; 971 return true;
955 } 972 }
956 973
957 DVLOG(0) << GetClientInfoString("DisableSyncForDatatype failed"); 974 DVLOG(0) << GetClientInfoString("DisableSyncForDatatype failed");
958 return false; 975 return false;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 1139
1123 std::string ProfileSyncServiceHarness::GetServiceStatus() { 1140 std::string ProfileSyncServiceHarness::GetServiceStatus() {
1124 scoped_ptr<DictionaryValue> value( 1141 scoped_ptr<DictionaryValue> value(
1125 sync_ui_util::ConstructAboutInformation(service_)); 1142 sync_ui_util::ConstructAboutInformation(service_));
1126 std::string service_status; 1143 std::string service_status;
1127 base::JSONWriter::WriteWithOptions(value.get(), 1144 base::JSONWriter::WriteWithOptions(value.get(),
1128 base::JSONWriter::OPTIONS_PRETTY_PRINT, 1145 base::JSONWriter::OPTIONS_PRETTY_PRINT,
1129 &service_status); 1146 &service_status);
1130 return service_status; 1147 return service_status;
1131 } 1148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698