Commit 52fed16a authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Small cleanups in InvalidatorRegistrar

Updating comments, removing some unused members and some typedefs that
are only used a single time.

Bug: none
Change-Id: Icc7f37f9f0d8d9d7f707a5db6955726d0668b41e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1889653Reviewed-by: default avatarTatiana Gornak <melandory@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710733}
parent 64c2324e
......@@ -75,9 +75,9 @@ Topics InvalidatorRegistrar::GetRegisteredTopics(
Topics InvalidatorRegistrar::GetAllRegisteredIds() const {
DCHECK(thread_checker_.CalledOnValidThread());
Topics registered_ids;
for (auto it = handler_to_topics_map_.begin();
it != handler_to_topics_map_.end(); ++it) {
registered_ids.insert(it->second.begin(), it->second.end());
for (const auto& handler_and_topics : handler_to_topics_map_) {
const Topics& topics = handler_and_topics.second;
registered_ids.insert(topics.begin(), topics.end());
}
return registered_ids;
}
......
......@@ -30,30 +30,29 @@ class INVALIDATION_EXPORT InvalidatorRegistrar {
~InvalidatorRegistrar();
// Starts sending notifications to |handler|. |handler| must not be NULL,
// and it must already be registered.
// and it must not already be registered.
void RegisterHandler(InvalidationHandler* handler);
// Stops sending notifications to |handler|. |handler| must not be NULL, and
// it must already be registered. Note that this doesn't unregister the IDs
// associated with |handler|.
// it must already be registered. Note that this doesn't unregister the
// topics associated with |handler| from the server.
void UnregisterHandler(InvalidationHandler* handler);
// Updates the set of topics associated with |handler|. |handler| must
// not be NULL, and must already be registered. A topic must be registered
// for at most one handler. If topic is already registered function returns
// false.
// for at most one handler. If any of the |topics| is already registered
// to a different handler, returns false.
virtual bool UpdateRegisteredTopics(InvalidationHandler* handler,
const Topics& topics) WARN_UNUSED_RESULT;
virtual Topics GetRegisteredTopics(InvalidationHandler* handler) const;
// Returns the set of all IDs that are registered to some handler (even
// handlers that have been unregistered).
// Returns the set of all topics that are registered to some handler.
virtual Topics GetAllRegisteredIds() const;
// Sorts incoming invalidations into a bucket for each handler and then
// dispatches the batched invalidations to the corresponding handler.
// Invalidations for IDs with no corresponding handler are dropped, as are
// Invalidations for topics with no corresponding handler are dropped, as are
// invalidations for handlers that are not added.
void DispatchInvalidationsToHandlers(
const TopicInvalidationMap& invalidation_map);
......@@ -74,21 +73,18 @@ class INVALIDATION_EXPORT InvalidatorRegistrar {
// Gets a new map for the name of invalidator handlers and their
// objects id. This is used by the InvalidatorLogger to be able
// to display every registered handlers and its objectsIds.
// to display every registered handler and its topics.
std::map<std::string, Topics> GetSanitizedHandlersIdsMap();
bool IsHandlerRegistered(const InvalidationHandler* handler) const;
bool HasRegisteredHandlers() const;
// Needed for death tests.
void DetachFromThreadForTest();
private:
typedef std::map<InvalidationHandler*, Topics> HandlerTopicsMap;
base::ThreadChecker thread_checker_;
base::ObserverList<InvalidationHandler, true>::Unchecked handlers_;
HandlerTopicsMap handler_to_topics_map_;
std::map<InvalidationHandler*, Topics> handler_to_topics_map_;
InvalidatorState state_;
DISALLOW_COPY_AND_ASSIGN(InvalidatorRegistrar);
......
......@@ -53,9 +53,6 @@ class INVALIDATION_EXPORT InvalidatorRegistrarWithMemory
bool UpdateRegisteredTopics(InvalidationHandler* handler,
const Topics& topics) override WARN_UNUSED_RESULT;
// void UnregisterHandler(InvalidationHandler* handler) override;
// void RegisterHandler(InvalidationHandler* handler) override;
// Returns the set of all IDs that are registered to some handler (even
// handlers that have been unregistered).
Topics GetAllRegisteredIds() const override;
......@@ -65,14 +62,10 @@ class INVALIDATION_EXPORT InvalidatorRegistrarWithMemory
const;
private:
using HandlerNameTopicsMap = std::map<std::string, Topics>;
// Generate a Dictionary with all the debugging information.
base::DictionaryValue CollectDebugData() const;
std::unordered_map<std::string, InvalidationHandler*>
handler_name_to_handler_;
HandlerNameTopicsMap handler_name_to_topics_map_;
std::map<std::string, Topics> handler_name_to_topics_map_;
PrefService* local_state_;
const std::string sender_id_;
......
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