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/chrome_invalidation_client.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 "sync/notifier/chrome_invalidation_client.h" 5 #include "sync/notifier/chrome_invalidation_client.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 chrome_system_resources_.network()->UpdateCredentials(email, token); 102 chrome_system_resources_.network()->UpdateCredentials(email, token);
103 } 103 }
104 104
105 void ChromeInvalidationClient::UpdateRegisteredIds(const ObjectIdSet& ids) { 105 void ChromeInvalidationClient::UpdateRegisteredIds(const ObjectIdSet& ids) {
106 DCHECK(CalledOnValidThread()); 106 DCHECK(CalledOnValidThread());
107 registered_ids_ = ids; 107 registered_ids_ = ids;
108 // |ticl_state_| can go to NO_NOTIFICATION_ERROR even without a 108 // |ticl_state_| can go to NO_NOTIFICATION_ERROR even without a
109 // working XMPP connection (as observed by us), so check it instead 109 // working XMPP connection (as observed by us), so check it instead
110 // of GetState() (see http://crbug.com/139424). 110 // of GetState() (see http://crbug.com/139424).
111 if (ticl_state_ == NO_NOTIFICATION_ERROR && registration_manager_.get()) { 111 if (ticl_state_ == NO_NOTIFICATION_ERROR && registration_manager_.get()) {
112 registration_manager_->UpdateRegisteredIds(registered_ids_); 112 DoRegistrationUpdate();
113 } 113 }
114 // TODO(akalin): Clear invalidation versions for unregistered types.
115 } 114 }
116 115
117 void ChromeInvalidationClient::Ready( 116 void ChromeInvalidationClient::Ready(
118 invalidation::InvalidationClient* client) { 117 invalidation::InvalidationClient* client) {
119 DCHECK(CalledOnValidThread()); 118 DCHECK(CalledOnValidThread());
120 DCHECK_EQ(client, invalidation_client_.get()); 119 DCHECK_EQ(client, invalidation_client_.get());
121 ticl_state_ = NO_NOTIFICATION_ERROR; 120 ticl_state_ = NO_NOTIFICATION_ERROR;
122 EmitStateChange(); 121 EmitStateChange();
123 registration_manager_->UpdateRegisteredIds(registered_ids_); 122 DoRegistrationUpdate();
124 } 123 }
125 124
126 void ChromeInvalidationClient::Invalidate( 125 void ChromeInvalidationClient::Invalidate(
127 invalidation::InvalidationClient* client, 126 invalidation::InvalidationClient* client,
128 const invalidation::Invalidation& invalidation, 127 const invalidation::Invalidation& invalidation,
129 const invalidation::AckHandle& ack_handle) { 128 const invalidation::AckHandle& ack_handle) {
130 DCHECK(CalledOnValidThread()); 129 DCHECK(CalledOnValidThread());
131 DCHECK_EQ(client, invalidation_client_.get()); 130 DCHECK_EQ(client, invalidation_client_.get());
132 DVLOG(1) << "Invalidate: " << InvalidationToString(invalidation); 131 DVLOG(1) << "Invalidate: " << InvalidationToString(invalidation);
133 132
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 EmitStateChange(); 277 EmitStateChange();
279 } 278 }
280 279
281 void ChromeInvalidationClient::WriteState(const std::string& state) { 280 void ChromeInvalidationClient::WriteState(const std::string& state) {
282 DCHECK(CalledOnValidThread()); 281 DCHECK(CalledOnValidThread());
283 DVLOG(1) << "WriteState"; 282 DVLOG(1) << "WriteState";
284 invalidation_state_tracker_.Call( 283 invalidation_state_tracker_.Call(
285 FROM_HERE, &InvalidationStateTracker::SetInvalidationState, state); 284 FROM_HERE, &InvalidationStateTracker::SetInvalidationState, state);
286 } 285 }
287 286
287 void ChromeInvalidationClient::DoRegistrationUpdate() {
288 DCHECK(CalledOnValidThread());
289 const ObjectIdSet& unregistered_ids =
290 registration_manager_->UpdateRegisteredIds(registered_ids_);
291 for (ObjectIdSet::const_iterator it = unregistered_ids.begin();
292 it != unregistered_ids.end();
293 ++it) {
294 invalidation_state_tracker_.Call(
akalin 2012/08/22 19:57:30 resurrecting my old comment, make Forget take a se
dcheng 2012/08/24 01:35:25 Done.
295 FROM_HERE, &InvalidationStateTracker::Forget, *it);
296 }
297 }
298
288 void ChromeInvalidationClient::StopForTest() { 299 void ChromeInvalidationClient::StopForTest() {
289 DCHECK(CalledOnValidThread()); 300 DCHECK(CalledOnValidThread());
290 Stop(); 301 Stop();
291 } 302 }
292 303
293 void ChromeInvalidationClient::Stop() { 304 void ChromeInvalidationClient::Stop() {
294 DCHECK(CalledOnValidThread()); 305 DCHECK(CalledOnValidThread());
295 if (!invalidation_client_.get()) { 306 if (!invalidation_client_.get()) {
296 return; 307 return;
297 } 308 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 EmitStateChange(); 360 EmitStateChange();
350 } 361 }
351 362
352 void ChromeInvalidationClient::OnIncomingNotification( 363 void ChromeInvalidationClient::OnIncomingNotification(
353 const notifier::Notification& notification) { 364 const notifier::Notification& notification) {
354 DCHECK(CalledOnValidThread()); 365 DCHECK(CalledOnValidThread());
355 // Do nothing, since this is already handled by |invalidation_client_|. 366 // Do nothing, since this is already handled by |invalidation_client_|.
356 } 367 }
357 368
358 } // namespace syncer 369 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698