| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/invalidation/non_blocking_invalidator.h" | 5 #include "components/invalidation/non_blocking_invalidator.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 core_.get()))) { | 267 core_.get()))) { |
| 268 DVLOG(1) << "Network thread stopped before invalidator is destroyed."; | 268 DVLOG(1) << "Network thread stopped before invalidator is destroyed."; |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 | 271 |
| 272 void NonBlockingInvalidator::RegisterHandler(InvalidationHandler* handler) { | 272 void NonBlockingInvalidator::RegisterHandler(InvalidationHandler* handler) { |
| 273 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 273 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
| 274 registrar_.RegisterHandler(handler); | 274 registrar_.RegisterHandler(handler); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void NonBlockingInvalidator::UpdateRegisteredIds(InvalidationHandler* handler, | 277 bool NonBlockingInvalidator::UpdateRegisteredIds(InvalidationHandler* handler, |
| 278 const ObjectIdSet& ids) { | 278 const ObjectIdSet& ids) { |
| 279 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 279 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
| 280 registrar_.UpdateRegisteredIds(handler, ids); | 280 if (!registrar_.UpdateRegisteredIds(handler, ids)) |
| 281 return false; |
| 281 if (!network_task_runner_->PostTask( | 282 if (!network_task_runner_->PostTask( |
| 282 FROM_HERE, | 283 FROM_HERE, |
| 283 base::Bind( | 284 base::Bind( |
| 284 &NonBlockingInvalidator::Core::UpdateRegisteredIds, | 285 &NonBlockingInvalidator::Core::UpdateRegisteredIds, |
| 285 core_.get(), | 286 core_.get(), |
| 286 registrar_.GetAllRegisteredIds()))) { | 287 registrar_.GetAllRegisteredIds()))) { |
| 287 NOTREACHED(); | 288 NOTREACHED(); |
| 288 } | 289 } |
| 290 return true; |
| 289 } | 291 } |
| 290 | 292 |
| 291 void NonBlockingInvalidator::UnregisterHandler(InvalidationHandler* handler) { | 293 void NonBlockingInvalidator::UnregisterHandler(InvalidationHandler* handler) { |
| 292 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 294 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
| 293 registrar_.UnregisterHandler(handler); | 295 registrar_.UnregisterHandler(handler); |
| 294 } | 296 } |
| 295 | 297 |
| 296 InvalidatorState NonBlockingInvalidator::GetInvalidatorState() const { | 298 InvalidatorState NonBlockingInvalidator::GetInvalidatorState() const { |
| 297 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 299 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
| 298 return registrar_.GetInvalidatorState(); | 300 return registrar_.GetInvalidatorState(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 383 |
| 382 void NonBlockingInvalidator::OnIncomingInvalidation( | 384 void NonBlockingInvalidator::OnIncomingInvalidation( |
| 383 const ObjectIdInvalidationMap& invalidation_map) { | 385 const ObjectIdInvalidationMap& invalidation_map) { |
| 384 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 386 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
| 385 registrar_.DispatchInvalidationsToHandlers(invalidation_map); | 387 registrar_.DispatchInvalidationsToHandlers(invalidation_map); |
| 386 } | 388 } |
| 387 | 389 |
| 388 std::string NonBlockingInvalidator::GetOwnerName() const { return "Sync"; } | 390 std::string NonBlockingInvalidator::GetOwnerName() const { return "Sync"; } |
| 389 | 391 |
| 390 } // namespace syncer | 392 } // namespace syncer |
| OLD | NEW |