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

Side by Side Diff: chrome/browser/sync/notifier/chrome_invalidation_client.cc

Issue 8772074: [Sync] Convert syncable/ directory to ModelEnumSet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/sync/notifier/chrome_invalidation_client.h" 5 #include "chrome/browser/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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 invalidation_client_->Stop(); 122 invalidation_client_->Stop();
123 123
124 invalidation_client_.reset(); 124 invalidation_client_.reset();
125 state_writer_ = NULL; 125 state_writer_ = NULL;
126 listener_ = NULL; 126 listener_ = NULL;
127 127
128 invalidation_version_tracker_.Reset(); 128 invalidation_version_tracker_.Reset();
129 max_invalidation_versions_.clear(); 129 max_invalidation_versions_.clear();
130 } 130 }
131 131
132 void ChromeInvalidationClient::RegisterTypes( 132 void ChromeInvalidationClient::RegisterTypes(syncable::ModelEnumSet types) {
133 const syncable::ModelTypeSet& types) {
134 DCHECK(non_thread_safe_.CalledOnValidThread()); 133 DCHECK(non_thread_safe_.CalledOnValidThread());
135 registered_types_ = types; 134 registered_types_ = types;
136 if (ticl_ready_ && registration_manager_.get()) { 135 if (ticl_ready_ && registration_manager_.get()) {
137 registration_manager_->SetRegisteredTypes(registered_types_); 136 registration_manager_->SetRegisteredTypes(registered_types_);
138 } 137 }
139 // TODO(akalin): Clear invalidation versions for unregistered types. 138 // TODO(akalin): Clear invalidation versions for unregistered types.
140 } 139 }
141 140
142 void ChromeInvalidationClient::Ready( 141 void ChromeInvalidationClient::Ready(
143 invalidation::InvalidationClient* client) { 142 invalidation::InvalidationClient* client) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 invalidation_version_tracker_.Call( 182 invalidation_version_tracker_.Call(
184 FROM_HERE, 183 FROM_HERE,
185 &InvalidationVersionTracker::SetMaxVersion, 184 &InvalidationVersionTracker::SetMaxVersion,
186 model_type, invalidation.version()); 185 model_type, invalidation.version());
187 186
188 std::string payload; 187 std::string payload;
189 // payload() CHECK()'s has_payload(), so we must check it ourselves first. 188 // payload() CHECK()'s has_payload(), so we must check it ourselves first.
190 if (invalidation.has_payload()) 189 if (invalidation.has_payload())
191 payload = invalidation.payload(); 190 payload = invalidation.payload();
192 191
193 syncable::ModelTypeSet types; 192 EmitInvalidation(syncable::ModelEnumSet(model_type), payload);
194 types.insert(model_type);
195 EmitInvalidation(types, payload);
196 // TODO(akalin): We should really acknowledge only after we get the 193 // TODO(akalin): We should really acknowledge only after we get the
197 // updates from the sync server. (see http://crbug.com/78462). 194 // updates from the sync server. (see http://crbug.com/78462).
198 client->Acknowledge(ack_handle); 195 client->Acknowledge(ack_handle);
199 } 196 }
200 197
201 void ChromeInvalidationClient::InvalidateUnknownVersion( 198 void ChromeInvalidationClient::InvalidateUnknownVersion(
202 invalidation::InvalidationClient* client, 199 invalidation::InvalidationClient* client,
203 const invalidation::ObjectId& object_id, 200 const invalidation::ObjectId& object_id,
204 const invalidation::AckHandle& ack_handle) { 201 const invalidation::AckHandle& ack_handle) {
205 DCHECK(non_thread_safe_.CalledOnValidThread()); 202 DCHECK(non_thread_safe_.CalledOnValidThread());
206 DVLOG(1) << "InvalidateUnknownVersion"; 203 DVLOG(1) << "InvalidateUnknownVersion";
207 204
208 syncable::ModelType model_type; 205 syncable::ModelType model_type;
209 if (!ObjectIdToRealModelType(object_id, &model_type)) { 206 if (!ObjectIdToRealModelType(object_id, &model_type)) {
210 LOG(WARNING) << "Could not get invalidation model type; " 207 LOG(WARNING) << "Could not get invalidation model type; "
211 << "invalidating everything"; 208 << "invalidating everything";
212 EmitInvalidation(registered_types_, std::string()); 209 EmitInvalidation(registered_types_, std::string());
213 client->Acknowledge(ack_handle); 210 client->Acknowledge(ack_handle);
214 return; 211 return;
215 } 212 }
216 213
217 syncable::ModelTypeSet types; 214 EmitInvalidation(syncable::ModelEnumSet(model_type), "");
218 types.insert(model_type);
219 EmitInvalidation(types, "");
220 // TODO(akalin): We should really acknowledge only after we get the 215 // TODO(akalin): We should really acknowledge only after we get the
221 // updates from the sync server. (see http://crbug.com/78462). 216 // updates from the sync server. (see http://crbug.com/78462).
222 client->Acknowledge(ack_handle); 217 client->Acknowledge(ack_handle);
223 } 218 }
224 219
225 // This should behave as if we got an invalidation with version 220 // This should behave as if we got an invalidation with version
226 // UNKNOWN_OBJECT_VERSION for all known data types. 221 // UNKNOWN_OBJECT_VERSION for all known data types.
227 void ChromeInvalidationClient::InvalidateAll( 222 void ChromeInvalidationClient::InvalidateAll(
228 invalidation::InvalidationClient* client, 223 invalidation::InvalidationClient* client,
229 const invalidation::AckHandle& ack_handle) { 224 const invalidation::AckHandle& ack_handle) {
230 DCHECK(non_thread_safe_.CalledOnValidThread()); 225 DCHECK(non_thread_safe_.CalledOnValidThread());
231 DVLOG(1) << "InvalidateAll"; 226 DVLOG(1) << "InvalidateAll";
232 EmitInvalidation(registered_types_, std::string()); 227 EmitInvalidation(registered_types_, std::string());
233 // TODO(akalin): We should really acknowledge only after we get the 228 // TODO(akalin): We should really acknowledge only after we get the
234 // updates from the sync server. (see http://crbug.com/76482). 229 // updates from the sync server. (see http://crbug.com/76482).
235 client->Acknowledge(ack_handle); 230 client->Acknowledge(ack_handle);
236 } 231 }
237 232
238 void ChromeInvalidationClient::EmitInvalidation( 233 void ChromeInvalidationClient::EmitInvalidation(
239 const syncable::ModelTypeSet& types, const std::string& payload) { 234 syncable::ModelEnumSet types, const std::string& payload) {
240 DCHECK(non_thread_safe_.CalledOnValidThread()); 235 DCHECK(non_thread_safe_.CalledOnValidThread());
241 // TODO(akalin): Move all uses of ModelTypeBitSet for invalidations
242 // to ModelTypeSet.
243 syncable::ModelTypePayloadMap type_payloads = 236 syncable::ModelTypePayloadMap type_payloads =
244 syncable::ModelTypePayloadMapFromBitSet( 237 syncable::ModelTypePayloadMapFromEnumSet(types, payload);
245 syncable::ModelTypeBitSetFromSet(types), payload);
246 listener_->OnInvalidate(type_payloads); 238 listener_->OnInvalidate(type_payloads);
247 } 239 }
248 240
249 void ChromeInvalidationClient::InformRegistrationStatus( 241 void ChromeInvalidationClient::InformRegistrationStatus(
250 invalidation::InvalidationClient* client, 242 invalidation::InvalidationClient* client,
251 const invalidation::ObjectId& object_id, 243 const invalidation::ObjectId& object_id,
252 InvalidationListener::RegistrationState new_state) { 244 InvalidationListener::RegistrationState new_state) {
253 DCHECK(non_thread_safe_.CalledOnValidThread()); 245 DCHECK(non_thread_safe_.CalledOnValidThread());
254 DVLOG(1) << "InformRegistrationStatus: " 246 DVLOG(1) << "InformRegistrationStatus: "
255 << ObjectIdToString(object_id) << " " << new_state; 247 << ObjectIdToString(object_id) << " " << new_state;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // TODO(ghc): handle the error. 305 // TODO(ghc): handle the error.
314 } 306 }
315 307
316 void ChromeInvalidationClient::WriteState(const std::string& state) { 308 void ChromeInvalidationClient::WriteState(const std::string& state) {
317 DCHECK(non_thread_safe_.CalledOnValidThread()); 309 DCHECK(non_thread_safe_.CalledOnValidThread());
318 CHECK(state_writer_); 310 CHECK(state_writer_);
319 state_writer_->WriteState(state); 311 state_writer_->WriteState(state);
320 } 312 }
321 313
322 } // namespace sync_notifier 314 } // namespace sync_notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698