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(
}
InvalidatorRegistrarWithMemory::~InvalidatorRegistrarWithMemory() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
CHECK(registered_handler_to_topics_map_.empty());
}
void InvalidatorRegistrarWithMemory::RegisterHandler(
InvalidationHandler* handler) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
CHECK(handler);
CHECK(!handlers_.HasObserver(handler));
handlers_.AddObserver(handler);
......@@ -108,7 +108,7 @@ void InvalidatorRegistrarWithMemory::RegisterHandler(
void InvalidatorRegistrarWithMemory::UnregisterHandler(
InvalidationHandler* handler) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
CHECK(handler);
CHECK(handlers_.HasObserver(handler));
handlers_.RemoveObserver(handler);
......@@ -122,7 +122,7 @@ void InvalidatorRegistrarWithMemory::UnregisterHandler(
bool InvalidatorRegistrarWithMemory::UpdateRegisteredTopics(
InvalidationHandler* handler,
const Topics& topics) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
CHECK(handler);
CHECK(handlers_.HasObserver(handler));
......@@ -166,7 +166,7 @@ bool InvalidatorRegistrarWithMemory::UpdateRegisteredTopics(
Topics InvalidatorRegistrarWithMemory::GetRegisteredTopics(
InvalidationHandler* handler) const {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
auto lookup = registered_handler_to_topics_map_.find(handler);
return lookup != registered_handler_to_topics_map_.end() ? lookup->second
: Topics();
......@@ -183,7 +183,7 @@ Topics InvalidatorRegistrarWithMemory::GetAllSubscribedTopics() const {
void InvalidatorRegistrarWithMemory::DispatchInvalidationsToHandlers(
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 (!handlers_.might_have_observers()) {
return;
......@@ -203,7 +203,7 @@ void InvalidatorRegistrarWithMemory::DispatchInvalidationsToHandlers(
void InvalidatorRegistrarWithMemory::UpdateInvalidatorState(
InvalidatorState state) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOG(1) << "New invalidator state: " << InvalidatorStateToString(state_)
<< " -> " << InvalidatorStateToString(state);
state_ = state;
......@@ -212,7 +212,7 @@ void InvalidatorRegistrarWithMemory::UpdateInvalidatorState(
}
InvalidatorState InvalidatorRegistrarWithMemory::GetInvalidatorState() const {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return state_;
}
......@@ -224,7 +224,7 @@ void InvalidatorRegistrarWithMemory::UpdateInvalidatorInstanceId(
std::map<std::string, Topics>
InvalidatorRegistrarWithMemory::GetHandlerNameToTopicsMap() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
std::map<std::string, Topics> names_to_topics;
for (const auto& handler_and_topics : registered_handler_to_topics_map_) {
names_to_topics[handler_and_topics.first->GetOwnerName()] =
......
......@@ -10,7 +10,7 @@
#include "base/macros.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_handler.h"
#include "components/invalidation/public/invalidation_util.h"
......@@ -110,8 +110,7 @@ class INVALIDATION_EXPORT InvalidatorRegistrarWithMemory {
// Generate a Dictionary with all the debugging information.
base::DictionaryValue CollectDebugData() const;
// TODO(treib): Switch to SequenceChecker.
base::ThreadChecker thread_checker_;
SEQUENCE_CHECKER(sequence_checker_);
base::ObserverList<InvalidationHandler, true>::Unchecked handlers_;
// 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