Commit 9d52af90 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

InvalidatorRegistrarWithMemory: Use SequenceChecker instead of ThreadChecker

Nothing in InvalidatorRegistrarWithMemory requires thread affinity, so
no reason for using ThreadChecker instead of the preferred
SequenceChecker.

Bug: none
Change-Id: Iead32eb4176913df32c11364cf90c5263782d3d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1910087Reviewed-by: default avatarTatiana Gornak <melandory@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714888}
parent e950eded
...@@ -94,13 +94,13 @@ InvalidatorRegistrarWithMemory::InvalidatorRegistrarWithMemory( ...@@ -94,13 +94,13 @@ InvalidatorRegistrarWithMemory::InvalidatorRegistrarWithMemory(
} }
InvalidatorRegistrarWithMemory::~InvalidatorRegistrarWithMemory() { InvalidatorRegistrarWithMemory::~InvalidatorRegistrarWithMemory() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
CHECK(registered_handler_to_topics_map_.empty()); CHECK(registered_handler_to_topics_map_.empty());
} }
void InvalidatorRegistrarWithMemory::RegisterHandler( void InvalidatorRegistrarWithMemory::RegisterHandler(
InvalidationHandler* handler) { InvalidationHandler* handler) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
CHECK(handler); CHECK(handler);
CHECK(!handlers_.HasObserver(handler)); CHECK(!handlers_.HasObserver(handler));
handlers_.AddObserver(handler); handlers_.AddObserver(handler);
...@@ -108,7 +108,7 @@ void InvalidatorRegistrarWithMemory::RegisterHandler( ...@@ -108,7 +108,7 @@ void InvalidatorRegistrarWithMemory::RegisterHandler(
void InvalidatorRegistrarWithMemory::UnregisterHandler( void InvalidatorRegistrarWithMemory::UnregisterHandler(
InvalidationHandler* handler) { InvalidationHandler* handler) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
CHECK(handler); CHECK(handler);
CHECK(handlers_.HasObserver(handler)); CHECK(handlers_.HasObserver(handler));
handlers_.RemoveObserver(handler); handlers_.RemoveObserver(handler);
...@@ -122,7 +122,7 @@ void InvalidatorRegistrarWithMemory::UnregisterHandler( ...@@ -122,7 +122,7 @@ void InvalidatorRegistrarWithMemory::UnregisterHandler(
bool InvalidatorRegistrarWithMemory::UpdateRegisteredTopics( bool InvalidatorRegistrarWithMemory::UpdateRegisteredTopics(
InvalidationHandler* handler, InvalidationHandler* handler,
const Topics& topics) { const Topics& topics) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
CHECK(handler); CHECK(handler);
CHECK(handlers_.HasObserver(handler)); CHECK(handlers_.HasObserver(handler));
...@@ -166,7 +166,7 @@ bool InvalidatorRegistrarWithMemory::UpdateRegisteredTopics( ...@@ -166,7 +166,7 @@ bool InvalidatorRegistrarWithMemory::UpdateRegisteredTopics(
Topics InvalidatorRegistrarWithMemory::GetRegisteredTopics( Topics InvalidatorRegistrarWithMemory::GetRegisteredTopics(
InvalidationHandler* handler) const { InvalidationHandler* handler) const {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
auto lookup = registered_handler_to_topics_map_.find(handler); auto lookup = registered_handler_to_topics_map_.find(handler);
return lookup != registered_handler_to_topics_map_.end() ? lookup->second return lookup != registered_handler_to_topics_map_.end() ? lookup->second
: Topics(); : Topics();
...@@ -183,7 +183,7 @@ Topics InvalidatorRegistrarWithMemory::GetAllSubscribedTopics() const { ...@@ -183,7 +183,7 @@ Topics InvalidatorRegistrarWithMemory::GetAllSubscribedTopics() const {
void InvalidatorRegistrarWithMemory::DispatchInvalidationsToHandlers( void InvalidatorRegistrarWithMemory::DispatchInvalidationsToHandlers(
const TopicInvalidationMap& invalidation_map) { const TopicInvalidationMap& invalidation_map) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// If we have no handlers, there's nothing to do. // If we have no handlers, there's nothing to do.
if (!handlers_.might_have_observers()) { if (!handlers_.might_have_observers()) {
return; return;
...@@ -203,7 +203,7 @@ void InvalidatorRegistrarWithMemory::DispatchInvalidationsToHandlers( ...@@ -203,7 +203,7 @@ void InvalidatorRegistrarWithMemory::DispatchInvalidationsToHandlers(
void InvalidatorRegistrarWithMemory::UpdateInvalidatorState( void InvalidatorRegistrarWithMemory::UpdateInvalidatorState(
InvalidatorState state) { InvalidatorState state) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOG(1) << "New invalidator state: " << InvalidatorStateToString(state_) DVLOG(1) << "New invalidator state: " << InvalidatorStateToString(state_)
<< " -> " << InvalidatorStateToString(state); << " -> " << InvalidatorStateToString(state);
state_ = state; state_ = state;
...@@ -212,7 +212,7 @@ void InvalidatorRegistrarWithMemory::UpdateInvalidatorState( ...@@ -212,7 +212,7 @@ void InvalidatorRegistrarWithMemory::UpdateInvalidatorState(
} }
InvalidatorState InvalidatorRegistrarWithMemory::GetInvalidatorState() const { InvalidatorState InvalidatorRegistrarWithMemory::GetInvalidatorState() const {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return state_; return state_;
} }
...@@ -224,7 +224,7 @@ void InvalidatorRegistrarWithMemory::UpdateInvalidatorInstanceId( ...@@ -224,7 +224,7 @@ void InvalidatorRegistrarWithMemory::UpdateInvalidatorInstanceId(
std::map<std::string, Topics> std::map<std::string, Topics>
InvalidatorRegistrarWithMemory::GetHandlerNameToTopicsMap() { InvalidatorRegistrarWithMemory::GetHandlerNameToTopicsMap() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
std::map<std::string, Topics> names_to_topics; std::map<std::string, Topics> names_to_topics;
for (const auto& handler_and_topics : registered_handler_to_topics_map_) { for (const auto& handler_and_topics : registered_handler_to_topics_map_) {
names_to_topics[handler_and_topics.first->GetOwnerName()] = names_to_topics[handler_and_topics.first->GetOwnerName()] =
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/threading/thread_checker.h" #include "base/sequence_checker.h"
#include "components/invalidation/public/invalidation_export.h" #include "components/invalidation/public/invalidation_export.h"
#include "components/invalidation/public/invalidation_handler.h" #include "components/invalidation/public/invalidation_handler.h"
#include "components/invalidation/public/invalidation_util.h" #include "components/invalidation/public/invalidation_util.h"
...@@ -110,8 +110,7 @@ class INVALIDATION_EXPORT InvalidatorRegistrarWithMemory { ...@@ -110,8 +110,7 @@ class INVALIDATION_EXPORT InvalidatorRegistrarWithMemory {
// Generate a Dictionary with all the debugging information. // Generate a Dictionary with all the debugging information.
base::DictionaryValue CollectDebugData() const; base::DictionaryValue CollectDebugData() const;
// TODO(treib): Switch to SequenceChecker. SEQUENCE_CHECKER(sequence_checker_);
base::ThreadChecker thread_checker_;
base::ObserverList<InvalidationHandler, true>::Unchecked handlers_; base::ObserverList<InvalidationHandler, true>::Unchecked handlers_;
// Note: When a handler is unregistered, its entry is removed from // Note: When a handler is unregistered, its entry is removed from
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment