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

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: . Created 8 years, 4 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 invalidation::ObjectId& id) {
120 DCHECK(thread_checker_.CalledOnValidThread());
121 CHECK(pref_service_);
122 InvalidationVersionMap max_versions = GetAllMaxVersions();
123 max_versions.erase(id);
124
125 base::ListValue max_versions_list;
126 SerializeToList(max_versions, &max_versions_list);
127 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions,
128 max_versions_list);
129 }
130
119 // static 131 // static
120 void InvalidatorStorage::DeserializeFromList( 132 void InvalidatorStorage::DeserializeFromList(
121 const base::ListValue& max_versions_list, 133 const base::ListValue& max_versions_list,
122 InvalidationVersionMap* max_versions_map) { 134 InvalidationVersionMap* max_versions_map) {
123 max_versions_map->clear(); 135 max_versions_map->clear();
124 for (size_t i = 0; i < max_versions_list.GetSize(); ++i) { 136 for (size_t i = 0; i < max_versions_list.GetSize(); ++i) {
125 const DictionaryValue* value = NULL; 137 const DictionaryValue* value = NULL;
126 if (!max_versions_list.GetDictionary(i, &value)) { 138 if (!max_versions_list.GetDictionary(i, &value)) {
127 DLOG(WARNING) << "Unable to deserialize entry " << i; 139 DLOG(WARNING) << "Unable to deserialize entry " << i;
128 continue; 140 continue;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 utf8_state); 239 utf8_state);
228 } 240 }
229 241
230 void InvalidatorStorage::Clear() { 242 void InvalidatorStorage::Clear() {
231 DCHECK(thread_checker_.CalledOnValidThread()); 243 DCHECK(thread_checker_.CalledOnValidThread());
232 pref_service_->ClearPref(prefs::kInvalidatorMaxInvalidationVersions); 244 pref_service_->ClearPref(prefs::kInvalidatorMaxInvalidationVersions);
233 pref_service_->ClearPref(prefs::kInvalidatorInvalidationState); 245 pref_service_->ClearPref(prefs::kInvalidatorInvalidationState);
234 } 246 }
235 247
236 } // namespace browser_sync 248 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698