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

Side by Side Diff: chrome/browser/sync/invalidations/invalidator_storage.cc

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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/invalidations/invalidator_storage.h" 5 #include "chrome/browser/sync/invalidations/invalidator_storage.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 value->SetString(kPayloadKey, state.payload); 86 value->SetString(kPayloadKey, state.payload);
87 if (state.current.IsValid()) 87 if (state.current.IsValid())
88 value->Set(kCurrentAckHandleKey, state.current.ToValue().release()); 88 value->Set(kCurrentAckHandleKey, state.current.ToValue().release());
89 if (state.expected.IsValid()) 89 if (state.expected.IsValid())
90 value->Set(kExpectedAckHandleKey, state.expected.ToValue().release()); 90 value->Set(kExpectedAckHandleKey, state.expected.ToValue().release());
91 return value; 91 return value;
92 } 92 }
93 93
94 } // namespace 94 } // namespace
95 95
96 InvalidatorStorage::InvalidatorStorage(PrefService* pref_service) 96 InvalidatorStorage::InvalidatorStorage(PrefServiceSyncable* pref_service)
97 : pref_service_(pref_service) { 97 : pref_service_(pref_service) {
98 // TODO(tim): Create a Mock instead of maintaining the if(!pref_service_) case 98 // TODO(tim): Create a Mock instead of maintaining the if(!pref_service_) case
99 // throughout this file. This is a problem now due to lack of injection at 99 // throughout this file. This is a problem now due to lack of injection at
100 // ProfileSyncService. Bug 130176. 100 // ProfileSyncService. Bug 130176.
101 if (pref_service_) { 101 if (pref_service_) {
102 pref_service_->RegisterListPref(prefs::kInvalidatorMaxInvalidationVersions, 102 pref_service_->RegisterListPref(prefs::kInvalidatorMaxInvalidationVersions,
103 PrefService::UNSYNCABLE_PREF); 103 PrefServiceSyncable::UNSYNCABLE_PREF);
104 pref_service_->RegisterStringPref(prefs::kInvalidatorInvalidationState, 104 pref_service_->RegisterStringPref(prefs::kInvalidatorInvalidationState,
105 std::string(), 105 std::string(),
106 PrefService::UNSYNCABLE_PREF); 106 PrefServiceSyncable::UNSYNCABLE_PREF);
107 107
108 MigrateMaxInvalidationVersionsPref(); 108 MigrateMaxInvalidationVersionsPref();
109 } 109 }
110 } 110 }
111 111
112 InvalidatorStorage::~InvalidatorStorage() { 112 InvalidatorStorage::~InvalidatorStorage() {
113 } 113 }
114 114
115 InvalidationStateMap InvalidatorStorage::GetAllInvalidationStates() const { 115 InvalidationStateMap InvalidatorStorage::GetAllInvalidationStates() const {
116 DCHECK(thread_checker_.CalledOnValidThread()); 116 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 base::ListValue* state_map_list) { 188 base::ListValue* state_map_list) {
189 for (InvalidationStateMap::const_iterator it = state_map.begin(); 189 for (InvalidationStateMap::const_iterator it = state_map.begin();
190 it != state_map.end(); ++it) { 190 it != state_map.end(); ++it) {
191 state_map_list->Append(ObjectIdAndStateToValue(it->first, it->second)); 191 state_map_list->Append(ObjectIdAndStateToValue(it->first, it->second));
192 } 192 }
193 } 193 }
194 194
195 // Legacy migration code. 195 // Legacy migration code.
196 void InvalidatorStorage::MigrateMaxInvalidationVersionsPref() { 196 void InvalidatorStorage::MigrateMaxInvalidationVersionsPref() {
197 pref_service_->RegisterDictionaryPref(prefs::kSyncMaxInvalidationVersions, 197 pref_service_->RegisterDictionaryPref(prefs::kSyncMaxInvalidationVersions,
198 PrefService::UNSYNCABLE_PREF); 198 PrefServiceSyncable::UNSYNCABLE_PREF);
199 const base::DictionaryValue* max_versions_dict = 199 const base::DictionaryValue* max_versions_dict =
200 pref_service_->GetDictionary(prefs::kSyncMaxInvalidationVersions); 200 pref_service_->GetDictionary(prefs::kSyncMaxInvalidationVersions);
201 CHECK(max_versions_dict); 201 CHECK(max_versions_dict);
202 if (!max_versions_dict->empty()) { 202 if (!max_versions_dict->empty()) {
203 InvalidationStateMap state_map; 203 InvalidationStateMap state_map;
204 DeserializeMap(max_versions_dict, &state_map); 204 DeserializeMap(max_versions_dict, &state_map);
205 base::ListValue state_map_list; 205 base::ListValue state_map_list;
206 SerializeToList(state_map, &state_map_list); 206 SerializeToList(state_map, &state_map_list);
207 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions, 207 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions,
208 state_map_list); 208 state_map_list);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 return; 315 return;
316 it->second.current = ack_handle; 316 it->second.current = ack_handle;
317 317
318 base::ListValue state_map_list; 318 base::ListValue state_map_list;
319 SerializeToList(state_map, &state_map_list); 319 SerializeToList(state_map, &state_map_list);
320 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions, 320 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions,
321 state_map_list); 321 state_map_list);
322 } 322 }
323 323
324 } // namespace browser_sync 324 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698