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

Side by Side Diff: sync/notifier/sync_invalidation_listener.cc

Issue 11415049: Implement features needed for local ack handling in InvalidationStateTracker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ...... Created 8 years 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/p2p_invalidator_unittest.cc ('k') | sync/sync.gyp » ('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/sync_invalidation_listener.h" 5 #include "sync/notifier/sync_invalidation_listener.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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // should drop invalidations for unregistered ids. We may also 141 // should drop invalidations for unregistered ids. We may also
142 // have to filter it at a higher level, as invalidations for 142 // have to filter it at a higher level, as invalidations for
143 // newly-unregistered ids may already be in flight. 143 // newly-unregistered ids may already be in flight.
144 InvalidationStateMap::const_iterator it = invalidation_state_map_.find(id); 144 InvalidationStateMap::const_iterator it = invalidation_state_map_.find(id);
145 if ((it != invalidation_state_map_.end()) && 145 if ((it != invalidation_state_map_.end()) &&
146 (invalidation.version() <= it->second.version)) { 146 (invalidation.version() <= it->second.version)) {
147 // Drop redundant invalidations. 147 // Drop redundant invalidations.
148 client->Acknowledge(ack_handle); 148 client->Acknowledge(ack_handle);
149 return; 149 return;
150 } 150 }
151 DVLOG(2) << "Setting max invalidation version for " << ObjectIdToString(id)
152 << " to " << invalidation.version();
153 invalidation_state_map_[id].version = invalidation.version();
154 invalidation_state_tracker_.Call(
155 FROM_HERE,
156 &InvalidationStateTracker::SetMaxVersion,
157 id, invalidation.version());
158 151
159 std::string payload; 152 std::string payload;
160 // payload() CHECK()'s has_payload(), so we must check it ourselves first. 153 // payload() CHECK()'s has_payload(), so we must check it ourselves first.
161 if (invalidation.has_payload()) 154 if (invalidation.has_payload())
162 payload = invalidation.payload(); 155 payload = invalidation.payload();
163 156
157 DVLOG(2) << "Setting max invalidation version for " << ObjectIdToString(id)
158 << " to " << invalidation.version();
159 invalidation_state_map_[id].version = invalidation.version();
160 invalidation_state_tracker_.Call(
161 FROM_HERE,
162 &InvalidationStateTracker::SetMaxVersionAndPayload,
163 id, invalidation.version(), payload);
164
164 ObjectIdInvalidationMap invalidation_map; 165 ObjectIdInvalidationMap invalidation_map;
165 invalidation_map[id].payload = payload; 166 invalidation_map[id].payload = payload;
166 EmitInvalidation(invalidation_map); 167 EmitInvalidation(invalidation_map);
167 // TODO(akalin): We should really acknowledge only after we get the 168 // TODO(akalin): We should really acknowledge only after we get the
168 // updates from the sync server. (see http://crbug.com/78462). 169 // updates from the sync server. (see http://crbug.com/78462).
169 client->Acknowledge(ack_handle); 170 client->Acknowledge(ack_handle);
170 } 171 }
171 172
172 void SyncInvalidationListener::InvalidateUnknownVersion( 173 void SyncInvalidationListener::InvalidateUnknownVersion(
173 invalidation::InvalidationClient* client, 174 invalidation::InvalidationClient* client,
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 EmitStateChange(); 363 EmitStateChange();
363 } 364 }
364 365
365 void SyncInvalidationListener::OnIncomingNotification( 366 void SyncInvalidationListener::OnIncomingNotification(
366 const notifier::Notification& notification) { 367 const notifier::Notification& notification) {
367 DCHECK(CalledOnValidThread()); 368 DCHECK(CalledOnValidThread());
368 // Do nothing, since this is already handled by |invalidation_client_|. 369 // Do nothing, since this is already handled by |invalidation_client_|.
369 } 370 }
370 371
371 } // namespace syncer 372 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/p2p_invalidator_unittest.cc ('k') | sync/sync.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698