| OLD | NEW |
| 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 Loading... |
| 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(syncable::ModelEnumSet types) { | 132 void ChromeInvalidationClient::RegisterTypes(syncable::ModelTypeSet types) { |
| 133 DCHECK(non_thread_safe_.CalledOnValidThread()); | 133 DCHECK(non_thread_safe_.CalledOnValidThread()); |
| 134 registered_types_ = types; | 134 registered_types_ = types; |
| 135 if (ticl_ready_ && registration_manager_.get()) { | 135 if (ticl_ready_ && registration_manager_.get()) { |
| 136 registration_manager_->SetRegisteredTypes(registered_types_); | 136 registration_manager_->SetRegisteredTypes(registered_types_); |
| 137 } | 137 } |
| 138 // TODO(akalin): Clear invalidation versions for unregistered types. | 138 // TODO(akalin): Clear invalidation versions for unregistered types. |
| 139 } | 139 } |
| 140 | 140 |
| 141 void ChromeInvalidationClient::Ready( | 141 void ChromeInvalidationClient::Ready( |
| 142 invalidation::InvalidationClient* client) { | 142 invalidation::InvalidationClient* client) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 invalidation_version_tracker_.Call( | 182 invalidation_version_tracker_.Call( |
| 183 FROM_HERE, | 183 FROM_HERE, |
| 184 &InvalidationVersionTracker::SetMaxVersion, | 184 &InvalidationVersionTracker::SetMaxVersion, |
| 185 model_type, invalidation.version()); | 185 model_type, invalidation.version()); |
| 186 | 186 |
| 187 std::string payload; | 187 std::string payload; |
| 188 // 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. |
| 189 if (invalidation.has_payload()) | 189 if (invalidation.has_payload()) |
| 190 payload = invalidation.payload(); | 190 payload = invalidation.payload(); |
| 191 | 191 |
| 192 EmitInvalidation(syncable::ModelEnumSet(model_type), payload); | 192 EmitInvalidation(syncable::ModelTypeSet(model_type), payload); |
| 193 // TODO(akalin): We should really acknowledge only after we get the | 193 // TODO(akalin): We should really acknowledge only after we get the |
| 194 // updates from the sync server. (see http://crbug.com/78462). | 194 // updates from the sync server. (see http://crbug.com/78462). |
| 195 client->Acknowledge(ack_handle); | 195 client->Acknowledge(ack_handle); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void ChromeInvalidationClient::InvalidateUnknownVersion( | 198 void ChromeInvalidationClient::InvalidateUnknownVersion( |
| 199 invalidation::InvalidationClient* client, | 199 invalidation::InvalidationClient* client, |
| 200 const invalidation::ObjectId& object_id, | 200 const invalidation::ObjectId& object_id, |
| 201 const invalidation::AckHandle& ack_handle) { | 201 const invalidation::AckHandle& ack_handle) { |
| 202 DCHECK(non_thread_safe_.CalledOnValidThread()); | 202 DCHECK(non_thread_safe_.CalledOnValidThread()); |
| 203 DVLOG(1) << "InvalidateUnknownVersion"; | 203 DVLOG(1) << "InvalidateUnknownVersion"; |
| 204 | 204 |
| 205 syncable::ModelType model_type; | 205 syncable::ModelType model_type; |
| 206 if (!ObjectIdToRealModelType(object_id, &model_type)) { | 206 if (!ObjectIdToRealModelType(object_id, &model_type)) { |
| 207 LOG(WARNING) << "Could not get invalidation model type; " | 207 LOG(WARNING) << "Could not get invalidation model type; " |
| 208 << "invalidating everything"; | 208 << "invalidating everything"; |
| 209 EmitInvalidation(registered_types_, std::string()); | 209 EmitInvalidation(registered_types_, std::string()); |
| 210 client->Acknowledge(ack_handle); | 210 client->Acknowledge(ack_handle); |
| 211 return; | 211 return; |
| 212 } | 212 } |
| 213 | 213 |
| 214 EmitInvalidation(syncable::ModelEnumSet(model_type), ""); | 214 EmitInvalidation(syncable::ModelTypeSet(model_type), ""); |
| 215 // TODO(akalin): We should really acknowledge only after we get the | 215 // TODO(akalin): We should really acknowledge only after we get the |
| 216 // updates from the sync server. (see http://crbug.com/78462). | 216 // updates from the sync server. (see http://crbug.com/78462). |
| 217 client->Acknowledge(ack_handle); | 217 client->Acknowledge(ack_handle); |
| 218 } | 218 } |
| 219 | 219 |
| 220 // This should behave as if we got an invalidation with version | 220 // This should behave as if we got an invalidation with version |
| 221 // UNKNOWN_OBJECT_VERSION for all known data types. | 221 // UNKNOWN_OBJECT_VERSION for all known data types. |
| 222 void ChromeInvalidationClient::InvalidateAll( | 222 void ChromeInvalidationClient::InvalidateAll( |
| 223 invalidation::InvalidationClient* client, | 223 invalidation::InvalidationClient* client, |
| 224 const invalidation::AckHandle& ack_handle) { | 224 const invalidation::AckHandle& ack_handle) { |
| 225 DCHECK(non_thread_safe_.CalledOnValidThread()); | 225 DCHECK(non_thread_safe_.CalledOnValidThread()); |
| 226 DVLOG(1) << "InvalidateAll"; | 226 DVLOG(1) << "InvalidateAll"; |
| 227 EmitInvalidation(registered_types_, std::string()); | 227 EmitInvalidation(registered_types_, std::string()); |
| 228 // TODO(akalin): We should really acknowledge only after we get the | 228 // TODO(akalin): We should really acknowledge only after we get the |
| 229 // updates from the sync server. (see http://crbug.com/76482). | 229 // updates from the sync server. (see http://crbug.com/76482). |
| 230 client->Acknowledge(ack_handle); | 230 client->Acknowledge(ack_handle); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void ChromeInvalidationClient::EmitInvalidation( | 233 void ChromeInvalidationClient::EmitInvalidation( |
| 234 syncable::ModelEnumSet types, const std::string& payload) { | 234 syncable::ModelTypeSet types, const std::string& payload) { |
| 235 DCHECK(non_thread_safe_.CalledOnValidThread()); | 235 DCHECK(non_thread_safe_.CalledOnValidThread()); |
| 236 syncable::ModelTypePayloadMap type_payloads = | 236 syncable::ModelTypePayloadMap type_payloads = |
| 237 syncable::ModelTypePayloadMapFromEnumSet(types, payload); | 237 syncable::ModelTypePayloadMapFromEnumSet(types, payload); |
| 238 listener_->OnInvalidate(type_payloads); | 238 listener_->OnInvalidate(type_payloads); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void ChromeInvalidationClient::InformRegistrationStatus( | 241 void ChromeInvalidationClient::InformRegistrationStatus( |
| 242 invalidation::InvalidationClient* client, | 242 invalidation::InvalidationClient* client, |
| 243 const invalidation::ObjectId& object_id, | 243 const invalidation::ObjectId& object_id, |
| 244 InvalidationListener::RegistrationState new_state) { | 244 InvalidationListener::RegistrationState new_state) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // TODO(ghc): handle the error. | 305 // TODO(ghc): handle the error. |
| 306 } | 306 } |
| 307 | 307 |
| 308 void ChromeInvalidationClient::WriteState(const std::string& state) { | 308 void ChromeInvalidationClient::WriteState(const std::string& state) { |
| 309 DCHECK(non_thread_safe_.CalledOnValidThread()); | 309 DCHECK(non_thread_safe_.CalledOnValidThread()); |
| 310 CHECK(state_writer_); | 310 CHECK(state_writer_); |
| 311 state_writer_->WriteState(state); | 311 state_writer_->WriteState(state); |
| 312 } | 312 } |
| 313 | 313 |
| 314 } // namespace sync_notifier | 314 } // namespace sync_notifier |
| OLD | NEW |