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

Side by Side Diff: sync/notifier/registration_manager.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
« no previous file with comments | « sync/notifier/registration_manager.h ('k') | sync/notifier/registration_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "sync/notifier/registration_manager.h" 5 #include "sync/notifier/registration_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstddef> 8 #include <cstddef>
9 #include <iterator> 9 #include <iterator>
10 #include <string> 10 #include <string>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 invalidation::InvalidationClient* invalidation_client) 59 invalidation::InvalidationClient* invalidation_client)
60 : invalidation_client_(invalidation_client) { 60 : invalidation_client_(invalidation_client) {
61 DCHECK(invalidation_client_); 61 DCHECK(invalidation_client_);
62 } 62 }
63 63
64 RegistrationManager::~RegistrationManager() { 64 RegistrationManager::~RegistrationManager() {
65 DCHECK(CalledOnValidThread()); 65 DCHECK(CalledOnValidThread());
66 STLDeleteValues(&registration_statuses_); 66 STLDeleteValues(&registration_statuses_);
67 } 67 }
68 68
69 void RegistrationManager::UpdateRegisteredIds(const ObjectIdSet& ids) { 69 ObjectIdSet RegistrationManager::UpdateRegisteredIds(const ObjectIdSet& ids) {
70 DCHECK(CalledOnValidThread()); 70 DCHECK(CalledOnValidThread());
71 71
72 const ObjectIdSet& old_ids = GetRegisteredIds(); 72 const ObjectIdSet& old_ids = GetRegisteredIds();
73 const ObjectIdSet& to_register = ids; 73 const ObjectIdSet& to_register = ids;
74 ObjectIdSet to_unregister; 74 ObjectIdSet to_unregister;
75 std::set_difference(old_ids.begin(), old_ids.end(), 75 std::set_difference(old_ids.begin(), old_ids.end(),
76 ids.begin(), ids.end(), 76 ids.begin(), ids.end(),
77 std::inserter(to_unregister, to_unregister.begin()), 77 std::inserter(to_unregister, to_unregister.begin()),
78 ObjectIdLessThan()); 78 ObjectIdLessThan());
79 79
80 for (ObjectIdSet::const_iterator it = to_unregister.begin(); 80 for (ObjectIdSet::const_iterator it = to_unregister.begin();
81 it != to_unregister.end(); ++it) { 81 it != to_unregister.end(); ++it) {
82 UnregisterId(*it); 82 UnregisterId(*it);
83 } 83 }
84 84
85 for (ObjectIdSet::const_iterator it = to_register.begin(); 85 for (ObjectIdSet::const_iterator it = to_register.begin();
86 it != to_register.end(); ++it) { 86 it != to_register.end(); ++it) {
87 if (!ContainsKey(registration_statuses_, *it)) { 87 if (!ContainsKey(registration_statuses_, *it)) {
88 registration_statuses_.insert( 88 registration_statuses_.insert(
89 std::make_pair(*it, new RegistrationStatus(*it, this))); 89 std::make_pair(*it, new RegistrationStatus(*it, this)));
90 } 90 }
91 if (!IsIdRegistered(*it)) { 91 if (!IsIdRegistered(*it)) {
92 TryRegisterId(*it, false /* is-retry */); 92 TryRegisterId(*it, false /* is-retry */);
93 } 93 }
94 } 94 }
95
96 return to_unregister;
95 } 97 }
96 98
97 void RegistrationManager::MarkRegistrationLost( 99 void RegistrationManager::MarkRegistrationLost(
98 const invalidation::ObjectId& id) { 100 const invalidation::ObjectId& id) {
99 DCHECK(CalledOnValidThread()); 101 DCHECK(CalledOnValidThread());
100 RegistrationStatusMap::const_iterator it = registration_statuses_.find(id); 102 RegistrationStatusMap::const_iterator it = registration_statuses_.find(id);
101 if (it == registration_statuses_.end()) { 103 if (it == registration_statuses_.end()) {
102 DLOG(WARNING) << "Attempt to mark non-existent registration for " 104 DLOG(WARNING) << "Attempt to mark non-existent registration for "
103 << ObjectIdToString(id) << " as lost"; 105 << ObjectIdToString(id) << " as lost";
104 return; 106 return;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 bool RegistrationManager::IsIdRegistered( 296 bool RegistrationManager::IsIdRegistered(
295 const invalidation::ObjectId& id) const { 297 const invalidation::ObjectId& id) const {
296 DCHECK(CalledOnValidThread()); 298 DCHECK(CalledOnValidThread());
297 RegistrationStatusMap::const_iterator it = 299 RegistrationStatusMap::const_iterator it =
298 registration_statuses_.find(id); 300 registration_statuses_.find(id);
299 return it != registration_statuses_.end() && 301 return it != registration_statuses_.end() &&
300 it->second->state == invalidation::InvalidationListener::REGISTERED; 302 it->second->state == invalidation::InvalidationListener::REGISTERED;
301 } 303 }
302 304
303 } // namespace syncer 305 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/registration_manager.h ('k') | sync/notifier/registration_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698