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

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

Issue 11052007: Rename ModelType/ObjectIdStateMap to InvalidationMap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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/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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 invalidation_state_tracker_.Call( 155 invalidation_state_tracker_.Call(
156 FROM_HERE, 156 FROM_HERE,
157 &InvalidationStateTracker::SetMaxVersion, 157 &InvalidationStateTracker::SetMaxVersion,
158 id, invalidation.version()); 158 id, invalidation.version());
159 159
160 std::string payload; 160 std::string payload;
161 // payload() CHECK()'s has_payload(), so we must check it ourselves first. 161 // payload() CHECK()'s has_payload(), so we must check it ourselves first.
162 if (invalidation.has_payload()) 162 if (invalidation.has_payload())
163 payload = invalidation.payload(); 163 payload = invalidation.payload();
164 164
165 ObjectIdStateMap id_state_map; 165 ObjectIdInvalidationMap invalidation_map;
166 id_state_map[id].payload = payload; 166 invalidation_map[id].payload = payload;
167 EmitInvalidation(id_state_map); 167 EmitInvalidation(invalidation_map);
168 // TODO(akalin): We should really acknowledge only after we get the 168 // TODO(akalin): We should really acknowledge only after we get the
169 // updates from the sync server. (see http://crbug.com/78462). 169 // updates from the sync server. (see http://crbug.com/78462).
170 client->Acknowledge(ack_handle); 170 client->Acknowledge(ack_handle);
171 } 171 }
172 172
173 void SyncInvalidationListener::InvalidateUnknownVersion( 173 void SyncInvalidationListener::InvalidateUnknownVersion(
174 invalidation::InvalidationClient* client, 174 invalidation::InvalidationClient* client,
175 const invalidation::ObjectId& object_id, 175 const invalidation::ObjectId& object_id,
176 const invalidation::AckHandle& ack_handle) { 176 const invalidation::AckHandle& ack_handle) {
177 DCHECK(CalledOnValidThread()); 177 DCHECK(CalledOnValidThread());
178 DCHECK_EQ(client, invalidation_client_.get()); 178 DCHECK_EQ(client, invalidation_client_.get());
179 DVLOG(1) << "InvalidateUnknownVersion"; 179 DVLOG(1) << "InvalidateUnknownVersion";
180 180
181 ObjectIdStateMap id_state_map; 181 ObjectIdInvalidationMap invalidation_map;
182 id_state_map[object_id].payload = std::string(); 182 invalidation_map[object_id].payload = std::string();
183 EmitInvalidation(id_state_map); 183 EmitInvalidation(invalidation_map);
184 // TODO(akalin): We should really acknowledge only after we get the 184 // TODO(akalin): We should really acknowledge only after we get the
185 // updates from the sync server. (see http://crbug.com/78462). 185 // updates from the sync server. (see http://crbug.com/78462).
186 client->Acknowledge(ack_handle); 186 client->Acknowledge(ack_handle);
187 } 187 }
188 188
189 // This should behave as if we got an invalidation with version 189 // This should behave as if we got an invalidation with version
190 // UNKNOWN_OBJECT_VERSION for all known data types. 190 // UNKNOWN_OBJECT_VERSION for all known data types.
191 void SyncInvalidationListener::InvalidateAll( 191 void SyncInvalidationListener::InvalidateAll(
192 invalidation::InvalidationClient* client, 192 invalidation::InvalidationClient* client,
193 const invalidation::AckHandle& ack_handle) { 193 const invalidation::AckHandle& ack_handle) {
194 DCHECK(CalledOnValidThread()); 194 DCHECK(CalledOnValidThread());
195 DCHECK_EQ(client, invalidation_client_.get()); 195 DCHECK_EQ(client, invalidation_client_.get());
196 DVLOG(1) << "InvalidateAll"; 196 DVLOG(1) << "InvalidateAll";
197 197
198 ObjectIdStateMap id_state_map; 198 const ObjectIdInvalidationMap& invalidation_map =
199 for (ObjectIdSet::const_iterator it = registered_ids_.begin(); 199 ObjectIdSetToInvalidationMap(registered_ids_, std::string());
200 it != registered_ids_.end(); ++it) { 200 EmitInvalidation(invalidation_map);
201 id_state_map[*it].payload = std::string();
202 }
203 EmitInvalidation(id_state_map);
204 // TODO(akalin): We should really acknowledge only after we get the 201 // TODO(akalin): We should really acknowledge only after we get the
205 // updates from the sync server. (see http://crbug.com/76482). 202 // updates from the sync server. (see http://crbug.com/76482).
206 client->Acknowledge(ack_handle); 203 client->Acknowledge(ack_handle);
207 } 204 }
208 205
209 void SyncInvalidationListener::EmitInvalidation( 206 void SyncInvalidationListener::EmitInvalidation(
210 const ObjectIdStateMap& id_state_map) { 207 const ObjectIdInvalidationMap& invalidation_map) {
211 DCHECK(CalledOnValidThread()); 208 DCHECK(CalledOnValidThread());
212 delegate_->OnInvalidate(id_state_map); 209 delegate_->OnInvalidate(invalidation_map);
213 } 210 }
214 211
215 void SyncInvalidationListener::InformRegistrationStatus( 212 void SyncInvalidationListener::InformRegistrationStatus(
216 invalidation::InvalidationClient* client, 213 invalidation::InvalidationClient* client,
217 const invalidation::ObjectId& object_id, 214 const invalidation::ObjectId& object_id,
218 InvalidationListener::RegistrationState new_state) { 215 InvalidationListener::RegistrationState new_state) {
219 DCHECK(CalledOnValidThread()); 216 DCHECK(CalledOnValidThread());
220 DCHECK_EQ(client, invalidation_client_.get()); 217 DCHECK_EQ(client, invalidation_client_.get());
221 DVLOG(1) << "InformRegistrationStatus: " 218 DVLOG(1) << "InformRegistrationStatus: "
222 << ObjectIdToString(object_id) << " " << new_state; 219 << ObjectIdToString(object_id) << " " << new_state;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 EmitStateChange(); 354 EmitStateChange();
358 } 355 }
359 356
360 void SyncInvalidationListener::OnIncomingNotification( 357 void SyncInvalidationListener::OnIncomingNotification(
361 const notifier::Notification& notification) { 358 const notifier::Notification& notification) {
362 DCHECK(CalledOnValidThread()); 359 DCHECK(CalledOnValidThread());
363 // Do nothing, since this is already handled by |invalidation_client_|. 360 // Do nothing, since this is already handled by |invalidation_client_|.
364 } 361 }
365 362
366 } // namespace syncer 363 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/sync_invalidation_listener.h ('k') | sync/notifier/sync_invalidation_listener_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698