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

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/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 chrome_system_resources_.network()->UpdateCredentials(email, token); 100 chrome_system_resources_.network()->UpdateCredentials(email, token);
101 } 101 }
102 102
103 void ChromeInvalidationClient::RegisterIds(const ObjectIdSet& ids) { 103 void ChromeInvalidationClient::RegisterIds(const ObjectIdSet& ids) {
104 DCHECK(CalledOnValidThread()); 104 DCHECK(CalledOnValidThread());
105 registered_ids_ = ids; 105 registered_ids_ = ids;
106 // |ticl_state_| can go to NO_NOTIFICATION_ERROR even without a 106 // |ticl_state_| can go to NO_NOTIFICATION_ERROR even without a
107 // working XMPP connection (as observed by us), so check it instead 107 // working XMPP connection (as observed by us), so check it instead
108 // of GetState() (see http://crbug.com/139424). 108 // of GetState() (see http://crbug.com/139424).
109 if (ticl_state_ == NO_NOTIFICATION_ERROR && registration_manager_.get()) { 109 if (ticl_state_ == NO_NOTIFICATION_ERROR && registration_manager_.get()) {
110 registration_manager_->SetRegisteredIds(registered_ids_); 110 DoRegistrationUpdate();
111 } 111 }
112 // TODO(akalin): Clear invalidation versions for unregistered types.
113 } 112 }
114 113
115 void ChromeInvalidationClient::Ready( 114 void ChromeInvalidationClient::Ready(
116 invalidation::InvalidationClient* client) { 115 invalidation::InvalidationClient* client) {
117 ticl_state_ = NO_NOTIFICATION_ERROR; 116 ticl_state_ = NO_NOTIFICATION_ERROR;
118 EmitStateChange(); 117 EmitStateChange();
119 registration_manager_->SetRegisteredIds(registered_ids_); 118 DoRegistrationUpdate();
120 } 119 }
121 120
122 void ChromeInvalidationClient::Invalidate( 121 void ChromeInvalidationClient::Invalidate(
123 invalidation::InvalidationClient* client, 122 invalidation::InvalidationClient* client,
124 const invalidation::Invalidation& invalidation, 123 const invalidation::Invalidation& invalidation,
125 const invalidation::AckHandle& ack_handle) { 124 const invalidation::AckHandle& ack_handle) {
126 DCHECK(CalledOnValidThread()); 125 DCHECK(CalledOnValidThread());
127 DVLOG(1) << "Invalidate: " << InvalidationToString(invalidation); 126 DVLOG(1) << "Invalidate: " << InvalidationToString(invalidation);
128 127
129 const invalidation::ObjectId& id = invalidation.object_id(); 128 const invalidation::ObjectId& id = invalidation.object_id();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 EmitStateChange(); 265 EmitStateChange();
267 } 266 }
268 267
269 void ChromeInvalidationClient::WriteState(const std::string& state) { 268 void ChromeInvalidationClient::WriteState(const std::string& state) {
270 DCHECK(CalledOnValidThread()); 269 DCHECK(CalledOnValidThread());
271 DVLOG(1) << "WriteState"; 270 DVLOG(1) << "WriteState";
272 invalidation_state_tracker_.Call( 271 invalidation_state_tracker_.Call(
273 FROM_HERE, &InvalidationStateTracker::SetInvalidationState, state); 272 FROM_HERE, &InvalidationStateTracker::SetInvalidationState, state);
274 } 273 }
275 274
275 void ChromeInvalidationClient::DoRegistrationUpdate() {
276 DCHECK(CalledOnValidThread());
277 const ObjectIdSet& unregistered_ids =
278 registration_manager_->SetRegisteredIds(registered_ids_);
279 for (ObjectIdSet::const_iterator it = unregistered_ids.begin();
280 it != unregistered_ids.end();
281 ++it) {
282 invalidation_state_tracker_.Call(
akalin 2012/08/02 07:04:30 you trigger a post on another thread for each ID,
283 FROM_HERE, &InvalidationStateTracker::Forget, *it);
284 }
285 }
286
276 void ChromeInvalidationClient::Stop() { 287 void ChromeInvalidationClient::Stop() {
277 DCHECK(CalledOnValidThread()); 288 DCHECK(CalledOnValidThread());
278 if (!invalidation_client_.get()) { 289 if (!invalidation_client_.get()) {
279 return; 290 return;
280 } 291 }
281 292
282 registration_manager_.reset(); 293 registration_manager_.reset();
283 chrome_system_resources_.Stop(); 294 chrome_system_resources_.Stop();
284 invalidation_client_->Stop(); 295 invalidation_client_->Stop();
285 296
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 EmitStateChange(); 343 EmitStateChange();
333 } 344 }
334 345
335 void ChromeInvalidationClient::OnIncomingNotification( 346 void ChromeInvalidationClient::OnIncomingNotification(
336 const notifier::Notification& notification) { 347 const notifier::Notification& notification) {
337 DCHECK(CalledOnValidThread()); 348 DCHECK(CalledOnValidThread());
338 // Do nothing, since this is already handled by |invalidation_client_|. 349 // Do nothing, since this is already handled by |invalidation_client_|.
339 } 350 }
340 351
341 } // namespace syncer 352 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/chrome_invalidation_client.h ('k') | sync/notifier/chrome_invalidation_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698