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

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

Issue 10824140: Add InvalidationStateTracker::Forget() to erase an entry from storage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix sync_client target Created 8 years, 3 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/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/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return; 109 return;
110 } 110 }
111 max_versions[id] = max_version; 111 max_versions[id] = max_version;
112 112
113 base::ListValue max_versions_list; 113 base::ListValue max_versions_list;
114 SerializeToList(max_versions, &max_versions_list); 114 SerializeToList(max_versions, &max_versions_list);
115 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions, 115 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions,
116 max_versions_list); 116 max_versions_list);
117 } 117 }
118 118
119 void InvalidatorStorage::Forget(const syncer::ObjectIdSet& ids) {
120 DCHECK(thread_checker_.CalledOnValidThread());
121 CHECK(pref_service_);
122 InvalidationVersionMap max_versions = GetAllMaxVersions();
123 for (syncer::ObjectIdSet::const_iterator it = ids.begin(); it != ids.end();
124 ++it) {
125 max_versions.erase(*it);
126 }
127
128 base::ListValue max_versions_list;
129 SerializeToList(max_versions, &max_versions_list);
130 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions,
131 max_versions_list);
132 }
133
119 // static 134 // static
120 void InvalidatorStorage::DeserializeFromList( 135 void InvalidatorStorage::DeserializeFromList(
121 const base::ListValue& max_versions_list, 136 const base::ListValue& max_versions_list,
122 InvalidationVersionMap* max_versions_map) { 137 InvalidationVersionMap* max_versions_map) {
123 max_versions_map->clear(); 138 max_versions_map->clear();
124 for (size_t i = 0; i < max_versions_list.GetSize(); ++i) { 139 for (size_t i = 0; i < max_versions_list.GetSize(); ++i) {
125 const DictionaryValue* value = NULL; 140 const DictionaryValue* value = NULL;
126 if (!max_versions_list.GetDictionary(i, &value)) { 141 if (!max_versions_list.GetDictionary(i, &value)) {
127 DLOG(WARNING) << "Unable to deserialize entry " << i; 142 DLOG(WARNING) << "Unable to deserialize entry " << i;
128 continue; 143 continue;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 utf8_state); 242 utf8_state);
228 } 243 }
229 244
230 void InvalidatorStorage::Clear() { 245 void InvalidatorStorage::Clear() {
231 DCHECK(thread_checker_.CalledOnValidThread()); 246 DCHECK(thread_checker_.CalledOnValidThread());
232 pref_service_->ClearPref(prefs::kInvalidatorMaxInvalidationVersions); 247 pref_service_->ClearPref(prefs::kInvalidatorMaxInvalidationVersions);
233 pref_service_->ClearPref(prefs::kInvalidatorInvalidationState); 248 pref_service_->ClearPref(prefs::kInvalidatorInvalidationState);
234 } 249 }
235 250
236 } // namespace browser_sync 251 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698