summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormferreria@chromium.org <mferreria@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-20 13:16:01 +0000
committermferreria@chromium.org <mferreria@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-20 13:16:01 +0000
commit9b0d66b6fcb4c34964a678c9068c4635b3b040e8 (patch)
tree6dae63bc3e7a16bb97aca193d3d00ba800b56538
parent92da2ed4160503a947cc5d8b71f8f1f1ba8c1973 (diff)
downloadchromium_src-9b0d66b6fcb4c34964a678c9068c4635b3b040e8.zip
chromium_src-9b0d66b6fcb4c34964a678c9068c4635b3b040e8.tar.gz
chromium_src-9b0d66b6fcb4c34964a678c9068c4635b3b040e8.tar.bz2
[invalidations] Added table with registered objectsIds
This patch is a follow-up to issue 147353011. The patch adds a display mechanism for the about:invalidations page that shows a table with every implementer of InvalidationHandler that has registered for at least one ObjectId for invalidations. The table also registers for every ObjectId how many invalidations were received of that kind, the last time one of those arrived and what was the payload it contained, in case there were any. There are minimal modifications to every file that implemented InvalidationHandler because there was a small change in the interface, in order to be able to return a string stating who is the owner of the InvalidationHandler without passing raw pointers around. BUG=263863 Review URL: https://codereview.chromium.org/159773006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252210 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/drive/drive_notification_manager.cc2
-rw-r--r--chrome/browser/drive/drive_notification_manager.h1
-rw-r--r--chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.cc4
-rw-r--r--chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h1
-rw-r--r--chrome/browser/invalidation/invalidation_logger.cc41
-rw-r--r--chrome/browser/invalidation/invalidation_logger.h51
-rw-r--r--chrome/browser/invalidation/invalidation_logger_observer.h8
-rw-r--r--chrome/browser/invalidation/invalidation_logger_unittest.cc177
-rw-r--r--chrome/browser/invalidation/p2p_invalidation_service.h3
-rw-r--r--chrome/browser/invalidation/ticl_invalidation_service.cc5
-rw-r--r--chrome/browser/invalidation/ticl_invalidation_service.h1
-rw-r--r--chrome/browser/policy/cloud/cloud_policy_invalidator.cc2
-rw-r--r--chrome/browser/policy/cloud/cloud_policy_invalidator.h1
-rw-r--r--chrome/browser/resources/about_invalidations.css26
-rw-r--r--chrome/browser/resources/about_invalidations.html43
-rw-r--r--chrome/browser/resources/about_invalidations.js97
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_impl.cc4
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_impl.h1
-rw-r--r--chrome/browser/ui/webui/invalidations_message_handler.cc48
-rw-r--r--chrome/browser/ui/webui/invalidations_message_handler.h28
-rw-r--r--chrome/test/data/webui/about_invalidations_browsertest.js44
-rw-r--r--sync/internal_api/public/test/fake_sync_manager.h3
-rw-r--r--sync/internal_api/sync_manager_impl.cc2
-rw-r--r--sync/internal_api/sync_manager_impl.h1
-rw-r--r--sync/internal_api/test/fake_sync_manager.cc2
-rw-r--r--sync/notifier/fake_invalidation_handler.cc2
-rw-r--r--sync/notifier/fake_invalidation_handler.h1
-rw-r--r--sync/notifier/invalidation_handler.h2
-rw-r--r--sync/notifier/invalidator_registrar.cc12
-rw-r--r--sync/notifier/invalidator_registrar.h5
-rw-r--r--sync/notifier/non_blocking_invalidator.cc7
-rw-r--r--sync/notifier/non_blocking_invalidator.h1
-rw-r--r--sync/tools/sync_listen_notifications.cc4
33 files changed, 508 insertions, 122 deletions
diff --git a/chrome/browser/drive/drive_notification_manager.cc b/chrome/browser/drive/drive_notification_manager.cc
index a3dcf34..7c34700 100644
--- a/chrome/browser/drive/drive_notification_manager.cc
+++ b/chrome/browser/drive/drive_notification_manager.cc
@@ -83,6 +83,8 @@ void DriveNotificationManager::OnIncomingInvalidation(
NotifyObserversToUpdate(NOTIFICATION_XMPP);
}
+std::string DriveNotificationManager::GetOwnerName() const { return "Drive"; }
+
void DriveNotificationManager::AddObserver(
DriveNotificationObserver* observer) {
observers_.AddObserver(observer);
diff --git a/chrome/browser/drive/drive_notification_manager.h b/chrome/browser/drive/drive_notification_manager.h
index e9016698b..a9fb2ed 100644
--- a/chrome/browser/drive/drive_notification_manager.h
+++ b/chrome/browser/drive/drive_notification_manager.h
@@ -40,6 +40,7 @@ class DriveNotificationManager
syncer::InvalidatorState state) OVERRIDE;
virtual void OnIncomingInvalidation(
const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
+ virtual std::string GetOwnerName() const OVERRIDE;
void AddObserver(DriveNotificationObserver* observer);
void RemoveObserver(DriveNotificationObserver* observer);
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.cc
index 1e52211..a060864 100644
--- a/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.cc
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.cc
@@ -180,6 +180,10 @@ void PushMessagingInvalidationHandler::OnIncomingInvalidation(
}
}
+std::string PushMessagingInvalidationHandler::GetOwnerName() const {
+ return "PushMessagingApi";
+}
+
void PushMessagingInvalidationHandler::UpdateRegistrations() {
syncer::ObjectIdSet ids;
for (std::set<std::string>::const_iterator it =
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h b/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h
index dfb89e6..cf580d6 100644
--- a/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h
@@ -49,6 +49,7 @@ class PushMessagingInvalidationHandler : public PushMessagingInvalidationMapper,
syncer::InvalidatorState state) OVERRIDE;
virtual void OnIncomingInvalidation(
const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
+ virtual std::string GetOwnerName() const OVERRIDE;
const std::set<std::string>& GetRegisteredExtensionsForTest() const {
return registered_extensions_;
diff --git a/chrome/browser/invalidation/invalidation_logger.cc b/chrome/browser/invalidation/invalidation_logger.cc
index 19bdf9d..6910810 100644
--- a/chrome/browser/invalidation/invalidation_logger.cc
+++ b/chrome/browser/invalidation/invalidation_logger.cc
@@ -7,10 +7,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "chrome/browser/invalidation/invalidation_logger_observer.h"
-
-namespace syncer {
-class ObjectIdInvalidationMap;
-}
+#include "sync/notifier/invalidation_handler.h"
namespace invalidation {
class InvalidationLoggerObserver;
@@ -43,9 +40,22 @@ void InvalidationLogger::EmitState() {
OnStateChange(last_invalidator_state_));
}
-void InvalidationLogger::OnUpdateIds(const base::DictionaryValue& details) {
- FOR_EACH_OBSERVER(
- InvalidationLoggerObserver, observer_list_, OnUpdateIds(details));
+void InvalidationLogger::OnUpdateIds(
+ std::map<std::string, syncer::ObjectIdSet> updated_ids) {
+ for (std::map<std::string, syncer::ObjectIdSet>::const_iterator it =
+ updated_ids.begin(); it != updated_ids.end(); ++it) {
+ latest_ids_[it->first] = syncer::ObjectIdSet(it->second);
+ }
+ EmitUpdatedIds();
+}
+
+void InvalidationLogger::EmitUpdatedIds() {
+ for (std::map<std::string, syncer::ObjectIdSet>::const_iterator it =
+ latest_ids_.begin(); it != latest_ids_.end(); ++it) {
+ FOR_EACH_OBSERVER(InvalidationLoggerObserver,
+ observer_list_,
+ OnUpdateIds(it->first, it->second));
+ }
}
void InvalidationLogger::OnDebugMessage(const base::DictionaryValue& details) {
@@ -60,22 +70,23 @@ void InvalidationLogger::OnInvalidation(
}
void InvalidationLogger::EmitContent() {
- // Here we add content to send to the observers not via real time push
- // but on explicit request.
EmitState();
+ EmitUpdatedIds();
}
-// Obtain a target object to call whenever we have
-// debug messages to display
-void InvalidationLogger::RegisterForDebug(
+void InvalidationLogger::RegisterObserver(
InvalidationLoggerObserver* debug_observer) {
observer_list_.AddObserver(debug_observer);
}
-// Removes the target object to call whenever we have
-// debug messages to display
-void InvalidationLogger::UnregisterForDebug(
+void InvalidationLogger::UnregisterObserver(
InvalidationLoggerObserver* debug_observer) {
observer_list_.RemoveObserver(debug_observer);
}
+
+bool InvalidationLogger::IsObserverRegistered(
+ InvalidationLoggerObserver* debug_observer) {
+ return observer_list_.HasObserver(debug_observer);
+}
+
} // namespace invalidation
diff --git a/chrome/browser/invalidation/invalidation_logger.h b/chrome/browser/invalidation/invalidation_logger.h
index 0d80b9a..7a4d67c 100644
--- a/chrome/browser/invalidation/invalidation_logger.h
+++ b/chrome/browser/invalidation/invalidation_logger.h
@@ -5,8 +5,10 @@
#ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_H_
#define CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_H_
+#include <map>
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
+#include "sync/notifier/invalidation_util.h"
#include "sync/notifier/invalidator_state.h"
namespace base {
@@ -14,38 +16,71 @@ class DictionaryValue;
} // namespace base
namespace syncer {
+class InvalidationHandler;
class ObjectIdInvalidationMap;
-}
+} // namespace syncer
namespace invalidation {
+
class InvalidationLoggerObserver;
+// This class is in charge of logging invalidation-related information.
+// It is used store the state of the InvalidatorService that owns this object
+// and then rebroadcast it to observers than can display it accordingly
+// (like a debugging page). This class only stores lightweight state, as in
+// which services are registered and listening for certain objects, and the
+// status of the InvalidatorService (in order not to increase unnecesary
+// memory usage).
+//
+// Observers can be registered and will be called to be notified of any
+// status change immediatly. They can log there the history of what messages
+// they recieve.
+
class InvalidationLogger {
+
public:
+ InvalidationLogger();
+ ~InvalidationLogger();
+
// Pass through to any registered InvalidationLoggerObservers.
// We will do local logging here too.
void OnRegistration(const base::DictionaryValue& details);
void OnUnregistration(const base::DictionaryValue& details);
- void OnStateChange(const syncer::InvalidatorState& newState);
- void OnUpdateIds(const base::DictionaryValue& details);
+ void OnStateChange(const syncer::InvalidatorState& new_state);
+ void OnUpdateIds(std::map<std::string, syncer::ObjectIdSet> updated_ids);
void OnDebugMessage(const base::DictionaryValue& details);
void OnInvalidation(const syncer::ObjectIdInvalidationMap& details);
+ // Triggers messages to be sent to the Observers to provide them with
+ // the current state of the logging.
void EmitContent();
- InvalidationLogger();
- ~InvalidationLogger();
-
- void RegisterForDebug(InvalidationLoggerObserver* debug_observer);
- void UnregisterForDebug(InvalidationLoggerObserver* debug_observer);
+ // Add and remove observers listening for messages.
+ void RegisterObserver(InvalidationLoggerObserver* debug_observer);
+ void UnregisterObserver(InvalidationLoggerObserver* debug_observer);
+ bool IsObserverRegistered(InvalidationLoggerObserver* debug_observer);
private:
+ // Send to every Observer a OnStateChange event with the latest state.
void EmitState();
+
+ // Send to every Observer many OnUpdateIds events, each with one registrar
+ // and every objectId it currently has registered.
+ void EmitUpdatedIds();
+
// The list of every observer currently listening for notifications.
ObserverList<InvalidationLoggerObserver> observer_list_;
+
// The last InvalidatorState updated by the InvalidatorService.
syncer::InvalidatorState last_invalidator_state_;
+
+ // The map that contains every object id that is currently registered
+ // and its owner.
+ std::map<std::string, syncer::ObjectIdSet> latest_ids_;
+
+ DISALLOW_COPY_AND_ASSIGN(InvalidationLogger);
};
} // namespace invalidation
+
#endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_H_
diff --git a/chrome/browser/invalidation/invalidation_logger_observer.h b/chrome/browser/invalidation/invalidation_logger_observer.h
index 6bd102e..7ee3652 100644
--- a/chrome/browser/invalidation/invalidation_logger_observer.h
+++ b/chrome/browser/invalidation/invalidation_logger_observer.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_INVALIDATION_INVALIDATION_LOGGER_OBSERVER_H_
#include "base/memory/scoped_ptr.h"
+#include "sync/notifier/invalidation_util.h"
#include "sync/notifier/invalidator_state.h"
#include "sync/notifier/object_id_invalidation_map.h"
@@ -14,6 +15,7 @@ class DictionaryValue;
} // namespace base
namespace syncer {
+class InvalidationHandler;
class ObjectIdInvalidationMap;
} // namespace syncer
@@ -22,13 +24,13 @@ namespace invalidation {
// InvalidationLogger notifications whenever an InvalidatorService changes
// its internal state.
// (i.e. A new registration, a new invalidation, a TICL/GCM state change)
-
class InvalidationLoggerObserver {
public:
virtual void OnRegistration(const base::DictionaryValue& details) = 0;
virtual void OnUnregistration(const base::DictionaryValue& details) = 0;
- virtual void OnStateChange(const syncer::InvalidatorState& newState) = 0;
- virtual void OnUpdateIds(const base::DictionaryValue& details) = 0;
+ virtual void OnStateChange(const syncer::InvalidatorState& new_state) = 0;
+ virtual void OnUpdateIds(const std::string& handler_name,
+ const syncer::ObjectIdSet& details) = 0;
virtual void OnDebugMessage(const base::DictionaryValue& details) = 0;
virtual void OnInvalidation(
const syncer::ObjectIdInvalidationMap& details) = 0;
diff --git a/chrome/browser/invalidation/invalidation_logger_unittest.cc b/chrome/browser/invalidation/invalidation_logger_unittest.cc
index 30a3c4d..86e3f9d 100644
--- a/chrome/browser/invalidation/invalidation_logger_unittest.cc
+++ b/chrome/browser/invalidation/invalidation_logger_unittest.cc
@@ -16,77 +16,81 @@ class InvalidationLoggerTest : public testing::Test {
class InvalidationLoggerObserverTest : public InvalidationLoggerObserver {
public:
- InvalidationLoggerObserverTest() { resetStates(); }
-
- void resetStates() {
- registrationReceived = false;
- unregistrationReceived = false;
- stateReceived = false;
- updateIdReceived = false;
- debugMessageReceived = false;
- invalidationReceived = false;
+ InvalidationLoggerObserverTest() { ResetStates(); }
+
+ void ResetStates() {
+ registration_received = false;
+ unregistration_received = false;
+ state_received = false;
+ update_id_received = false;
+ debug_message_received = false;
+ invalidation_received = false;
+ update_id_replicated = std::map<std::string, syncer::ObjectIdSet>();
}
virtual void OnRegistration(const base::DictionaryValue& details) OVERRIDE {
- registrationReceived = true;
+ registration_received = true;
}
virtual void OnUnregistration(const base::DictionaryValue& details) OVERRIDE {
- unregistrationReceived = true;
+ unregistration_received = true;
}
virtual void OnStateChange(const syncer::InvalidatorState& newState)
OVERRIDE {
- stateReceived = true;
+ state_received = true;
}
- virtual void OnUpdateIds(const base::DictionaryValue& details) OVERRIDE {
- updateIdReceived = true;
+ virtual void OnUpdateIds(const std::string& handler,
+ const syncer::ObjectIdSet& details) OVERRIDE {
+ update_id_received = true;
+ update_id_replicated[handler] = details;
}
virtual void OnDebugMessage(const base::DictionaryValue& details) OVERRIDE {
- debugMessageReceived = true;
+ debug_message_received = true;
}
virtual void OnInvalidation(
const syncer::ObjectIdInvalidationMap& newInvalidations) OVERRIDE {
- invalidationReceived = true;
+ invalidation_received = true;
}
- bool registrationReceived;
- bool unregistrationReceived;
- bool stateReceived;
- bool updateIdReceived;
- bool debugMessageReceived;
- bool invalidationReceived;
+ bool registration_received;
+ bool unregistration_received;
+ bool state_received;
+ bool update_id_received;
+ bool debug_message_received;
+ bool invalidation_received;
+ std::map<std::string, syncer::ObjectIdSet> update_id_replicated;
};
// Test that the callbacks are actually being called when observers are
// registered and don't produce any other callback in the meantime.
TEST_F(InvalidationLoggerTest, TestCallbacks) {
InvalidationLogger log;
- InvalidationLoggerObserverTest observerTest;
+ InvalidationLoggerObserverTest observer_test;
- log.RegisterForDebug(&observerTest);
+ log.RegisterObserver(&observer_test);
log.OnStateChange(syncer::INVALIDATIONS_ENABLED);
- EXPECT_TRUE(observerTest.stateReceived);
- EXPECT_FALSE(observerTest.updateIdReceived);
- EXPECT_FALSE(observerTest.registrationReceived);
- EXPECT_FALSE(observerTest.invalidationReceived);
- EXPECT_FALSE(observerTest.unregistrationReceived);
- EXPECT_FALSE(observerTest.debugMessageReceived);
+ EXPECT_TRUE(observer_test.state_received);
+ EXPECT_FALSE(observer_test.update_id_received);
+ EXPECT_FALSE(observer_test.registration_received);
+ EXPECT_FALSE(observer_test.invalidation_received);
+ EXPECT_FALSE(observer_test.unregistration_received);
+ EXPECT_FALSE(observer_test.debug_message_received);
- observerTest.resetStates();
+ observer_test.ResetStates();
log.OnInvalidation(syncer::ObjectIdInvalidationMap());
- EXPECT_TRUE(observerTest.invalidationReceived);
- EXPECT_FALSE(observerTest.stateReceived);
- EXPECT_FALSE(observerTest.updateIdReceived);
- EXPECT_FALSE(observerTest.registrationReceived);
- EXPECT_FALSE(observerTest.unregistrationReceived);
- EXPECT_FALSE(observerTest.debugMessageReceived);
-
- log.UnregisterForDebug(&observerTest);
+ EXPECT_TRUE(observer_test.invalidation_received);
+ EXPECT_FALSE(observer_test.state_received);
+ EXPECT_FALSE(observer_test.update_id_received);
+ EXPECT_FALSE(observer_test.registration_received);
+ EXPECT_FALSE(observer_test.unregistration_received);
+ EXPECT_FALSE(observer_test.debug_message_received);
+
+ log.UnregisterObserver(&observer_test);
}
// Test that after registering an observer and then unregistering it
@@ -94,41 +98,94 @@ TEST_F(InvalidationLoggerTest, TestCallbacks) {
// (i.e. the observer is cleanly removed)
TEST_F(InvalidationLoggerTest, TestReleaseOfObserver) {
InvalidationLogger log;
- InvalidationLoggerObserverTest observerTest;
+ InvalidationLoggerObserverTest observer_test;
- log.RegisterForDebug(&observerTest);
- log.UnregisterForDebug(&observerTest);
+ log.RegisterObserver(&observer_test);
+ log.UnregisterObserver(&observer_test);
log.OnInvalidation(syncer::ObjectIdInvalidationMap());
log.OnStateChange(syncer::INVALIDATIONS_ENABLED);
log.OnRegistration(base::DictionaryValue());
log.OnUnregistration(base::DictionaryValue());
log.OnDebugMessage(base::DictionaryValue());
- log.OnUpdateIds(base::DictionaryValue());
- EXPECT_FALSE(observerTest.registrationReceived);
- EXPECT_FALSE(observerTest.unregistrationReceived);
- EXPECT_FALSE(observerTest.updateIdReceived);
- EXPECT_FALSE(observerTest.invalidationReceived);
- EXPECT_FALSE(observerTest.stateReceived);
- EXPECT_FALSE(observerTest.debugMessageReceived);
+ log.OnUpdateIds(std::map<std::string, syncer::ObjectIdSet>());
+ EXPECT_FALSE(observer_test.registration_received);
+ EXPECT_FALSE(observer_test.unregistration_received);
+ EXPECT_FALSE(observer_test.update_id_received);
+ EXPECT_FALSE(observer_test.invalidation_received);
+ EXPECT_FALSE(observer_test.state_received);
+ EXPECT_FALSE(observer_test.debug_message_received);
}
// Test the EmitContet in InvalidationLogger is actually
-// sending (only) state notifications.
+// sending state and updateIds notifications.
TEST_F(InvalidationLoggerTest, TestEmitContent) {
InvalidationLogger log;
- InvalidationLoggerObserverTest observerTest;
+ InvalidationLoggerObserverTest observer_test;
- log.RegisterForDebug(&observerTest);
- EXPECT_FALSE(observerTest.stateReceived);
+ log.RegisterObserver(&observer_test);
+ EXPECT_FALSE(observer_test.state_received);
+ EXPECT_FALSE(observer_test.update_id_received);
log.EmitContent();
+ // Only expect state because no Ids were registered.
+ EXPECT_TRUE(observer_test.state_received);
+ EXPECT_FALSE(observer_test.registration_received);
+ EXPECT_FALSE(observer_test.unregistration_received);
+ EXPECT_FALSE(observer_test.update_id_received);
+ EXPECT_FALSE(observer_test.invalidation_received);
+ EXPECT_FALSE(observer_test.debug_message_received);
+
+ observer_test.ResetStates();
+ std::map<std::string, syncer::ObjectIdSet> test_map;
+ test_map["Test"] = syncer::ObjectIdSet();
+ log.OnUpdateIds(test_map);
+ EXPECT_TRUE(observer_test.update_id_received);
+ observer_test.ResetStates();
- EXPECT_TRUE(observerTest.stateReceived);
- EXPECT_FALSE(observerTest.registrationReceived);
- EXPECT_FALSE(observerTest.unregistrationReceived);
- EXPECT_FALSE(observerTest.updateIdReceived);
- EXPECT_FALSE(observerTest.invalidationReceived);
- EXPECT_FALSE(observerTest.debugMessageReceived);
- log.UnregisterForDebug(&observerTest);
+ log.EmitContent();
+ // Expect now state and ids change.
+ EXPECT_TRUE(observer_test.state_received);
+ EXPECT_TRUE(observer_test.update_id_received);
+ EXPECT_FALSE(observer_test.registration_received);
+ EXPECT_FALSE(observer_test.unregistration_received);
+ EXPECT_FALSE(observer_test.invalidation_received);
+ EXPECT_FALSE(observer_test.debug_message_received);
+ log.UnregisterObserver(&observer_test);
+}
+
+// Test that the updateId notification actually sends
+// what was sent to the Observer.
+// The ObserverTest rebuilds the map that was sent in pieces by the logger.
+TEST_F(InvalidationLoggerTest, TestUpdateIdsMap) {
+ InvalidationLogger log;
+ InvalidationLoggerObserverTest observer_test;
+ std::map<std::string, syncer::ObjectIdSet> test_map;
+ log.RegisterObserver(&observer_test);
+
+ syncer::ObjectIdSet sync_set_A;
+ sync_set_A.insert(ObjectId(1000, "DataType1"));
+ sync_set_A.insert(ObjectId(1000, "DataType2"));
+ syncer::ObjectIdSet sync_set_B;
+ sync_set_B.insert(ObjectId(1020, "DataTypeA"));
+ test_map["TestA"] = sync_set_A;
+ test_map["TestB"] = sync_set_B;
+
+ log.OnUpdateIds(test_map);
+ EXPECT_EQ(test_map, observer_test.update_id_replicated);
+
+ syncer::ObjectIdSet sync_set_B2;
+ sync_set_B2.insert(ObjectId(1020, "DataTypeF"));
+ sync_set_B2.insert(ObjectId(1020, "DataTypeG"));
+ test_map["TestB"] = sync_set_B2;
+
+ log.OnUpdateIds(test_map);
+ EXPECT_EQ(test_map, observer_test.update_id_replicated);
+
+ // The emit content should return the same map too.
+ observer_test.ResetStates();
+ log.EmitContent();
+ EXPECT_EQ(test_map, observer_test.update_id_replicated);
+
+ log.UnregisterObserver(&observer_test);
}
} // namespace invalidation
diff --git a/chrome/browser/invalidation/p2p_invalidation_service.h b/chrome/browser/invalidation/p2p_invalidation_service.h
index d4dfdbf..d1407eb 100644
--- a/chrome/browser/invalidation/p2p_invalidation_service.h
+++ b/chrome/browser/invalidation/p2p_invalidation_service.h
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/threading/non_thread_safe.h"
-#include "chrome/browser/invalidation/invalidation_logger.h"
#include "chrome/browser/invalidation/invalidation_service.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
@@ -18,6 +17,8 @@ class Profile;
namespace invalidation {
+class InvalidationLogger;
+
// This service is a wrapper around P2PInvalidator. Unlike other
// InvalidationServices, it can both send and receive invalidations. It is used
// only in tests, where we're unable to connect to a real invalidations server.
diff --git a/chrome/browser/invalidation/ticl_invalidation_service.cc b/chrome/browser/invalidation/ticl_invalidation_service.cc
index e83c843..616bdc1 100644
--- a/chrome/browser/invalidation/ticl_invalidation_service.cc
+++ b/chrome/browser/invalidation/ticl_invalidation_service.cc
@@ -125,6 +125,9 @@ void TiclInvalidationService::UpdateRegisteredInvalidationIds(
this,
invalidator_registrar_->GetAllRegisteredIds());
}
+
+ // Log this update ids call
+ logger_.OnUpdateIds(invalidator_registrar_->GetSanitizedHandlersIdsMap());
}
void TiclInvalidationService::UnregisterInvalidationHandler(
@@ -283,6 +286,8 @@ void TiclInvalidationService::OnIncomingInvalidation(
logger_.OnInvalidation(invalidation_map);
}
+std::string TiclInvalidationService::GetOwnerName() const { return "TICL"; }
+
void TiclInvalidationService::Shutdown() {
DCHECK(CalledOnValidThread());
oauth2_token_service_->RemoveObserver(this);
diff --git a/chrome/browser/invalidation/ticl_invalidation_service.h b/chrome/browser/invalidation/ticl_invalidation_service.h
index cdbd0a6..043b796 100644
--- a/chrome/browser/invalidation/ticl_invalidation_service.h
+++ b/chrome/browser/invalidation/ticl_invalidation_service.h
@@ -84,6 +84,7 @@ class TiclInvalidationService
syncer::InvalidatorState state) OVERRIDE;
virtual void OnIncomingInvalidation(
const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
+ virtual std::string GetOwnerName() const OVERRIDE;
// Overrides BrowserContextKeyedService method.
virtual void Shutdown() OVERRIDE;
diff --git a/chrome/browser/policy/cloud/cloud_policy_invalidator.cc b/chrome/browser/policy/cloud/cloud_policy_invalidator.cc
index 57fdc4c..2ed223f 100644
--- a/chrome/browser/policy/cloud/cloud_policy_invalidator.cc
+++ b/chrome/browser/policy/cloud/cloud_policy_invalidator.cc
@@ -110,6 +110,8 @@ void CloudPolicyInvalidator::OnIncomingInvalidation(
HandleInvalidation(list.back());
}
+std::string CloudPolicyInvalidator::GetOwnerName() const { return "Cloud"; }
+
void CloudPolicyInvalidator::OnCoreConnected(CloudPolicyCore* core) {}
void CloudPolicyInvalidator::OnRefreshSchedulerStarted(CloudPolicyCore* core) {
diff --git a/chrome/browser/policy/cloud/cloud_policy_invalidator.h b/chrome/browser/policy/cloud/cloud_policy_invalidator.h
index f86016a..5192277 100644
--- a/chrome/browser/policy/cloud/cloud_policy_invalidator.h
+++ b/chrome/browser/policy/cloud/cloud_policy_invalidator.h
@@ -72,6 +72,7 @@ class CloudPolicyInvalidator : public syncer::InvalidationHandler,
syncer::InvalidatorState state) OVERRIDE;
virtual void OnIncomingInvalidation(
const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
+ virtual std::string GetOwnerName() const OVERRIDE;
// CloudPolicyCore::Observer:
virtual void OnCoreConnected(CloudPolicyCore* core) OVERRIDE;
diff --git a/chrome/browser/resources/about_invalidations.css b/chrome/browser/resources/about_invalidations.css
index e71c941..2747f69 100644
--- a/chrome/browser/resources/about_invalidations.css
+++ b/chrome/browser/resources/about_invalidations.css
@@ -8,11 +8,13 @@ body {
font-size: 80%;
}
-#invalidations-info p {
+#invalidations-info .lead {
color: rgb(74, 142, 230);
+ display: block;
font-size: 100%;
font-weight: bold;
- margin-bottom: 0;
+ margin-top: 10px;
+ word-wrap: normal;
}
#invalidations-info .section {
@@ -22,3 +24,23 @@ body {
width: 100%;
}
+#objectsid-table-container .td {
+ font-size: 50%;
+}
+
+#objectsid-table-container .error {
+ background: rgb(255, 204, 204);
+}
+
+#objectsid-table-container .header {
+ background: rgb(255, 255, 204);
+}
+
+#objectsid-table-container .content {
+ background: rgb(204, 255, 204);
+}
+
+#objectsid-table-container .greyed {
+ background: rgb(204, 204, 204);
+}
+
diff --git a/chrome/browser/resources/about_invalidations.html b/chrome/browser/resources/about_invalidations.html
index d7dd623..2b1a0e1 100644
--- a/chrome/browser/resources/about_invalidations.html
+++ b/chrome/browser/resources/about_invalidations.html
@@ -13,17 +13,44 @@
<h1>Invalidations Debug Information</h1>
<div id="invalidations-info">
<div id="states" class="section">
- <label>
- <p>Invalidation service state:</p><span id="invalidations-state"></span>
- </label>
+ <span class='lead'>Invalidation service state:</span>
+ <span id="invalidations-state"></span>
+ </div>
+ <div id="objectsid-table-div" class="section">
+ <span class='lead'>Registered objectsIds for invalidations:</span>
+ <table id="objectsid-table-container">
+ <!-- 'objectsidtable' can't have dashes in the name
+ as jstemplate can't deal with them-->
+ <thead>
+ <tr class="header">
+ <th>Registrar</th>
+ <th>Source</th>
+ <th>Name</th>
+ <th>Count</th>
+ <th>Version</th>
+ <th>Time</th>
+ <th>Last Payload</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr jsselect="objectsidtable" jsvalues="class:$this.type">
+ <td jscontent="registrar" width=5%></td>
+ <td jscontent="source" width=5%></td>
+ <td jscontent="name" width=20%></td>
+ <td jscontent="count" width=5%></td>
+ <td jscontent="version" width=10%></td>
+ <td jscontent="time" width=20%></td>
+ <td jscontent="payload" width=35%></td>
+ </tr>
+ </tbody>
+ </table>
</div>
<div class="section">
- <label>
- <p>Invalidations Log:</p>
- <textarea
- id="invalidations-log" rows="10" cols="120" readonly></textarea>
- </label>
+ <span class='lead'>Invalidations Log:</span>
+ <textarea
+ id="invalidations-log" rows="10" cols="120"readonly></textarea>
</div>
</div>
+ <script src="chrome://resources/js/jstemplate_compiled.js"></script>
</body>
</html>
diff --git a/chrome/browser/resources/about_invalidations.js b/chrome/browser/resources/about_invalidations.js
index db58dc9..f6982ca 100644
--- a/chrome/browser/resources/about_invalidations.js
+++ b/chrome/browser/resources/about_invalidations.js
@@ -1,8 +1,14 @@
-// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('chrome.invalidations', function() {
+ /**
+ * Local variable where we maintain a count of the invalidations received
+ * and of every ObjectId that has ever been updated (note that this doesn't
+ * log any invalidations ocurred prior to opening the about:invalidation page)
+ */
+ var tableObjects = {};
function quote(str) {
return '\"' + str + '\"';
@@ -21,6 +27,20 @@ cr.define('chrome.invalidations', function() {
var invalidationsLog = $('invalidations-log');
invalidationsLog.value += logMessage + '\n';
}
+ /**
+ * Updates the jstemplate with the latest ObjectIds, ordered by registrar.
+ */
+ function repaintTable() {
+ var keys = [];
+ for (var key in tableObjects)
+ keys.push(key);
+ keys.sort();
+ var sortedInvalidations = [];
+ for (var i = 0; i < keys.length; i++)
+ sortedInvalidations.push(tableObjects[keys[i]]);
+ var wrapped = { objectsidtable: sortedInvalidations };
+ jstProcess(new JsEvalContext(wrapped), $('objectsid-table-div'));
+ }
/**
* Shows the current state of the InvalidatorService
@@ -40,7 +60,7 @@ cr.define('chrome.invalidations', function() {
* Adds to the log the latest invalidations received
*
* @param {Array of Object} allInvalidations The array of ObjectId
- * that contains the invalidations received by the InvalidatorService
+ * that contains the invalidations received by the InvalidatorService.
*/
function logInvalidations(allInvalidations) {
for (var i = 0; i < allInvalidations.length; i++) {
@@ -55,8 +75,80 @@ cr.define('chrome.invalidations', function() {
quote(inv.payload);
appendToLog(logMessage);
+ var isInvalidation = true;
+ logToTable(inv, isInvalidation);
}
}
+ repaintTable();
+ }
+
+ /**
+ * Marks a change in the table whether a new invalidation has arrived
+ * or a new ObjectId is currently being added or updated.
+ *
+ * @param {object} oId The ObjectId being added or updated.
+ * @param {bool} isInvaldation A flag that says that an invalidation
+ * for this ObjectId has arrived or we just need to add it to the table
+ * as it was just updated its state.
+ */
+ function logToTable(oId, isInvalidation) {
+ var registrar = oId.registrar;
+ var name = oId.objectId.name;
+ var source = oId.objectId.source;
+ var key = source + '-' + name;
+ var time = new Date();
+ var version = oId.isUnknownVersion ? '?' :
+ oId.version;
+ var payload = '';
+ if (oId.hasOwnProperty('payload'))
+ payload = oId.payload;
+ if (!(key in tableObjects)) {
+ tableObjects[key] = {
+ name: name,
+ source: source,
+ count: 0,
+ registrar: registrar,
+ time: '',
+ version: '',
+ payload: '',
+ type: 'content'
+ };
+ }
+ // Refresh the type to be a content because it might have been
+ // greyed out.
+ tableObjects[key].type = 'content';
+ if (isInvalidation) {
+ tableObjects[key].count = tableObjects[key].count + 1;
+ tableObjects[key].time = time.toTimeString();
+ tableObjects[key].version = version;
+ tableObjects[key].payload = payload;
+ }
+ }
+
+ /**
+ * Updates the table with the objects ids registered for invalidations
+ *
+ * @param {string} registrar The name of the owner of the InvalidationHandler
+ * that is registered for invalidations
+ * @param {Array of Object} allIds An array of ObjectsIds that are currently
+ * registered for invalidations. It is not differential (as in, whatever
+ * is not registered now but was before, it mean it was taken out the
+ * registered objects)
+ */
+ function updateIds(registrar, allIds) {
+ // Grey out every datatype assigned to this registrar
+ // (and reenable them later in case they are still registered).
+ for (var key in tableObjects) {
+ if (tableObjects[key]['registrar'] === registrar)
+ tableObjects[key].type = 'greyed';
+ }
+ // Reenable those ObjectsIds still registered with this registrar.
+ for (var i = 0; i < allIds.length; i++) {
+ var oId = { objectId: allIds[i], registrar: registrar };
+ var isInvalidation = false;
+ logToTable(oId, isInvalidation);
+ }
+ repaintTable();
}
/**
@@ -69,6 +161,7 @@ cr.define('chrome.invalidations', function() {
return {
updateState: updateState,
+ updateIds: updateIds,
logInvalidations: logInvalidations,
onLoadWork: onLoadWork
};
diff --git a/chrome/browser/sync/glue/sync_backend_host_impl.cc b/chrome/browser/sync/glue/sync_backend_host_impl.cc
index 70a34cc..8a9a3bf 100644
--- a/chrome/browser/sync/glue/sync_backend_host_impl.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_impl.cc
@@ -662,6 +662,10 @@ void SyncBackendHostImpl::OnIncomingInvalidation(
invalidation_map));
}
+std::string SyncBackendHostImpl::GetOwnerName() const {
+ return "SyncBackendHostImpl";
+}
+
bool SyncBackendHostImpl::CheckPassphraseAgainstCachedPendingKeys(
const std::string& passphrase) const {
DCHECK(cached_pending_keys_.has_blob());
diff --git a/chrome/browser/sync/glue/sync_backend_host_impl.h b/chrome/browser/sync/glue/sync_backend_host_impl.h
index c41a1ea..4a65f46 100644
--- a/chrome/browser/sync/glue/sync_backend_host_impl.h
+++ b/chrome/browser/sync/glue/sync_backend_host_impl.h
@@ -260,6 +260,7 @@ class SyncBackendHostImpl
syncer::InvalidatorState state) OVERRIDE;
virtual void OnIncomingInvalidation(
const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
+ virtual std::string GetOwnerName() const OVERRIDE;
content::NotificationRegistrar notification_registrar_;
diff --git a/chrome/browser/ui/webui/invalidations_message_handler.cc b/chrome/browser/ui/webui/invalidations_message_handler.cc
index 6a55ec5..3ddde3c 100644
--- a/chrome/browser/ui/webui/invalidations_message_handler.cc
+++ b/chrome/browser/ui/webui/invalidations_message_handler.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/invalidation/invalidation_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/web_ui.h"
+#include "sync/notifier/invalidation_handler.h"
namespace invalidation {
class InvalidationLogger;
@@ -20,11 +21,11 @@ class ObjectIdInvalidationMap;
} // namespace syncer
InvalidationsMessageHandler::InvalidationsMessageHandler()
- : logger_(NULL), isRegistered(false) {}
+ : logger_(NULL) {}
InvalidationsMessageHandler::~InvalidationsMessageHandler() {
if (logger_)
- logger_->UnregisterForDebug(this);
+ logger_->UnregisterObserver(this);
}
void InvalidationsMessageHandler::RegisterMessages() {
@@ -36,14 +37,14 @@ void InvalidationsMessageHandler::RegisterMessages() {
void InvalidationsMessageHandler::UIReady(const base::ListValue* args) {
Profile* profile = Profile::FromWebUI(web_ui());
- if (!isRegistered && profile) {
+ if (profile) {
invalidation::InvalidationService* invalidation_service =
invalidation::InvalidationServiceFactory::GetForProfile(profile);
if (invalidation_service)
logger_ = invalidation_service->GetInvalidationLogger();
if (logger_) {
- logger_->RegisterForDebug(this);
- isRegistered = true;
+ if (!logger_->IsObserverRegistered(this))
+ logger_->RegisterObserver(this);
}
}
UpdateContent(args);
@@ -55,27 +56,46 @@ void InvalidationsMessageHandler::UpdateContent(const base::ListValue* args) {
}
void InvalidationsMessageHandler::OnUnregistration(
- const base::DictionaryValue& newRegistrationState) {}
+ const base::DictionaryValue& details) {}
void InvalidationsMessageHandler::OnRegistration(
- const base::DictionaryValue& newRegistrationState) {}
+ const base::DictionaryValue& details) {}
void InvalidationsMessageHandler::OnStateChange(
- const syncer::InvalidatorState& newState) {
- std::string state(syncer::InvalidatorStateToString(newState));
+ const syncer::InvalidatorState& new_state) {
+ std::string state(syncer::InvalidatorStateToString(new_state));
web_ui()->CallJavascriptFunction("chrome.invalidations.updateState",
base::StringValue(state));
}
void InvalidationsMessageHandler::OnUpdateIds(
- const base::DictionaryValue& newIds) {}
-
+ const std::string& handler_name,
+ const syncer::ObjectIdSet& ids_set) {
+ scoped_ptr<base::ListValue> list_of_objects = ObjectIdSetToList(ids_set);
+ web_ui()->CallJavascriptFunction("chrome.invalidations.updateIds",
+ base::StringValue(handler_name),
+ *list_of_objects);
+}
void InvalidationsMessageHandler::OnDebugMessage(
const base::DictionaryValue& details) {}
void InvalidationsMessageHandler::OnInvalidation(
- const syncer::ObjectIdInvalidationMap& newInvalidations) {
- scoped_ptr<base::ListValue> invalidationsList = newInvalidations.ToValue();
+ const syncer::ObjectIdInvalidationMap& new_invalidations) {
+ scoped_ptr<base::ListValue> invalidations_list = new_invalidations.ToValue();
web_ui()->CallJavascriptFunction("chrome.invalidations.logInvalidations",
- *invalidationsList);
+ *invalidations_list);
+}
+
+scoped_ptr<base::ListValue> InvalidationsMessageHandler::ObjectIdSetToList(
+ const syncer::ObjectIdSet& ids_set) {
+ scoped_ptr<base::ListValue> list(new base::ListValue());
+
+ for (syncer::ObjectIdSet::const_iterator it = ids_set.begin();
+ it != ids_set.end(); ++it) {
+ scoped_ptr<base::DictionaryValue> dic(new base::DictionaryValue);
+ dic->SetString("name", it->name());
+ dic->SetInteger("source", it->source());
+ list->Append(dic.release());
+ }
+ return list.Pass();
}
diff --git a/chrome/browser/ui/webui/invalidations_message_handler.h b/chrome/browser/ui/webui/invalidations_message_handler.h
index 41d6073..f8f2e1e 100644
--- a/chrome/browser/ui/webui/invalidations_message_handler.h
+++ b/chrome/browser/ui/webui/invalidations_message_handler.h
@@ -10,6 +10,7 @@
#include "base/values.h"
#include "chrome/browser/invalidation/invalidation_logger_observer.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "sync/notifier/invalidation_util.h"
class Profile;
@@ -17,6 +18,10 @@ namespace invalidation {
class InvalidationLogger;
} // namespace invalidation
+namespace syncer {
+class InvalidationHandler;
+} // namespace syncer
+
// The implementation for the chrome://invalidations page.
class InvalidationsMessageHandler
: public content::WebUIMessageHandler,
@@ -25,28 +30,37 @@ class InvalidationsMessageHandler
InvalidationsMessageHandler();
virtual ~InvalidationsMessageHandler();
- // Implementation of InvalidationLoggerObserver
+ // Implementation of InvalidationLoggerObserver.
virtual void OnRegistration(const base::DictionaryValue& details) OVERRIDE;
virtual void OnUnregistration(const base::DictionaryValue& details) OVERRIDE;
- virtual void OnStateChange(const syncer::InvalidatorState& newState) OVERRIDE;
- virtual void OnUpdateIds(const base::DictionaryValue& details) OVERRIDE;
+ virtual void OnStateChange(const syncer::InvalidatorState& new_state)
+ OVERRIDE;
+ virtual void OnUpdateIds(const std::string& handler_name,
+ const syncer::ObjectIdSet& ids_set) OVERRIDE;
virtual void OnDebugMessage(const base::DictionaryValue& details) OVERRIDE;
virtual void OnInvalidation(
- const syncer::ObjectIdInvalidationMap& newInvalidations) OVERRIDE;
+ const syncer::ObjectIdInvalidationMap& new_invalidations) OVERRIDE;
- // Implementation of WebUIMessageHandler
+ // Implementation of WebUIMessageHandler.
virtual void RegisterMessages() OVERRIDE;
+ // Triggers the logger to send the current state and objects ids.
void UpdateContent(const base::ListValue* args);
+
+ // Called by the javascript whenever the page is ready to receive messages.
void UIReady(const base::ListValue* args);
private:
+ // Transforms a set to a ListValue in order to be automatically
+ // transformed to a JavaScript array of objects.
+ scoped_ptr<base::ListValue> ObjectIdSetToList(
+ const syncer::ObjectIdSet& ids_set);
+
// The pointer to the internal InvalidatorService InvalidationLogger.
// Used to get the information necessary to display to the JS and to
// register ourselves as Observers for any notifications.
invalidation::InvalidationLogger* logger_;
- // Check to see if we are already registered as an observer
- bool isRegistered;
+
DISALLOW_COPY_AND_ASSIGN(InvalidationsMessageHandler);
};
diff --git a/chrome/test/data/webui/about_invalidations_browsertest.js b/chrome/test/data/webui/about_invalidations_browsertest.js
index 694e488..4b9da27 100644
--- a/chrome/test/data/webui/about_invalidations_browsertest.js
+++ b/chrome/test/data/webui/about_invalidations_browsertest.js
@@ -17,7 +17,7 @@ InvalidationsWebUITest.prototype = {
**/
browsePreload: 'chrome://invalidations',
runAccessibilityChecks: false,
- accessibilityIssuesAreErrors: false,
+ accessibilityIssuesAreErrors: false
};
// Test that registering an invalidations appears properly on the textarea.
@@ -55,8 +55,48 @@ TEST_F('InvalidationsWebUITest', 'testChangingInvalidationsState', function() {
'TRANSIENT_INVALIDATION_ERROR');
var isContained =
invalidationsLog.value.indexOf(
- 'Invalidations service state changed to '+
+ 'Invalidations service state changed to ' +
'"TRANSIENT_INVALIDATION_ERROR"') != -1;
expectTrue(isContained, 'Actual log is:' + invalidationsLog.value);
});
+// Test that objects ids appear on the table.
+TEST_F('InvalidationsWebUITest', 'testRegisteringNewIds', function() {
+ var newDataType = [
+ { name: 'EXTENSIONS', source: 1004},
+ { name: 'FAVICON_IMAGE', source: 1004}
+ ];
+ var pattern1 = ['Fake', '1004', 'EXTENSIONS', '0', '', '', ''];
+ var pattern2 = ['Fake', '1004', 'FAVICON_IMAGE', '0', '', '', ''];
+ // Register two objects ID with 'Fake' registrar
+ chrome.invalidations.updateIds('Fake', newDataType);
+ // Disable the Extensions ObjectId by only sending FAVICON_IMAGE
+ newDataType = [{ name: 'FAVICON_IMAGE', source: 1004}];
+ chrome.invalidations.updateIds('Fake', newDataType);
+
+ // Test that the two patterns are contained in the table.
+ var oidTable = $('objectsid-table-container');
+ var foundPattern1 = false;
+ var foundPattern2 = false;
+ for (var row = 0; row < oidTable.rows.length; row++) {
+ var pattern1Test = true;
+ var pattern2Test = true;
+ for (var cell = 0; cell < oidTable.rows[row].cells.length; cell++) {
+ pattern1Test = pattern1Test
+ && (pattern1[cell] == oidTable.rows[row].cells[cell].textContent);
+ pattern2Test = pattern2Test
+ && (pattern2[cell] == oidTable.rows[row].cells[cell].textContent);
+ }
+ if (pattern1Test)
+ expectEquals('greyed', oidTable.rows[row].className);
+ if (pattern2Test)
+ expectEquals('content', oidTable.rows[row].className);
+
+ foundPattern1 = foundPattern1 || pattern1Test;
+ foundPattern2 = foundPattern2 || pattern2Test;
+ if (foundPattern2)
+ expectTrue(foundPattern1, 'The entries were not ordererd');
+ }
+ expectTrue(foundPattern1 && foundPattern2, "couldn't find both objects ids");
+
+});
diff --git a/sync/internal_api/public/test/fake_sync_manager.h b/sync/internal_api/public/test/fake_sync_manager.h
index 41dee19..1194399 100644
--- a/sync/internal_api/public/test/fake_sync_manager.h
+++ b/sync/internal_api/public/test/fake_sync_manager.h
@@ -68,6 +68,9 @@ class FakeSyncManager : public SyncManager {
// Posts a method to update the invalidator state on the sync thread.
virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE;
+ // Returns this class name for logging purposes.
+ virtual std::string GetOwnerName() const OVERRIDE;
+
// Block until the sync thread has finished processing any pending messages.
void WaitForSyncThread();
diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc
index 59c0f3a..edd79a9 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/sync/internal_api/sync_manager_impl.cc
@@ -1140,6 +1140,8 @@ void SyncManagerImpl::OnIncomingInvalidation(
}
}
+std::string SyncManagerImpl::GetOwnerName() const { return "SyncManagerImpl"; }
+
void SyncManagerImpl::RefreshTypes(ModelTypeSet types) {
DCHECK(thread_checker_.CalledOnValidThread());
if (types.Empty()) {
diff --git a/sync/internal_api/sync_manager_impl.h b/sync/internal_api/sync_manager_impl.h
index fa1662e..75593fc 100644
--- a/sync/internal_api/sync_manager_impl.h
+++ b/sync/internal_api/sync_manager_impl.h
@@ -103,6 +103,7 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE;
virtual void OnIncomingInvalidation(
const ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
+ virtual std::string GetOwnerName() const OVERRIDE;
virtual void AddObserver(SyncManager::Observer* observer) OVERRIDE;
virtual void RemoveObserver(SyncManager::Observer* observer) OVERRIDE;
virtual SyncStatus GetDetailedStatus() const OVERRIDE;
diff --git a/sync/internal_api/test/fake_sync_manager.cc b/sync/internal_api/test/fake_sync_manager.cc
index dd83f38..d6b538f 100644
--- a/sync/internal_api/test/fake_sync_manager.cc
+++ b/sync/internal_api/test/fake_sync_manager.cc
@@ -252,4 +252,6 @@ void FakeSyncManager::OnInvalidatorStateChange(InvalidatorState state) {
// Do nothing.
}
+std::string FakeSyncManager::GetOwnerName() const { return "FakeSyncManager"; }
+
} // namespace syncer
diff --git a/sync/notifier/fake_invalidation_handler.cc b/sync/notifier/fake_invalidation_handler.cc
index 30cb2fd..6c18066 100644
--- a/sync/notifier/fake_invalidation_handler.cc
+++ b/sync/notifier/fake_invalidation_handler.cc
@@ -35,4 +35,6 @@ void FakeInvalidationHandler::OnIncomingInvalidation(
++invalidation_count_;
}
+std::string FakeInvalidationHandler::GetOwnerName() const { return "Fake"; }
+
} // namespace syncer
diff --git a/sync/notifier/fake_invalidation_handler.h b/sync/notifier/fake_invalidation_handler.h
index 81b877a..4203e62 100644
--- a/sync/notifier/fake_invalidation_handler.h
+++ b/sync/notifier/fake_invalidation_handler.h
@@ -27,6 +27,7 @@ class FakeInvalidationHandler : public InvalidationHandler {
virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE;
virtual void OnIncomingInvalidation(
const ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
+ virtual std::string GetOwnerName() const OVERRIDE;
private:
InvalidatorState state_;
diff --git a/sync/notifier/invalidation_handler.h b/sync/notifier/invalidation_handler.h
index 2f5149f..29843904 100644
--- a/sync/notifier/invalidation_handler.h
+++ b/sync/notifier/invalidation_handler.h
@@ -23,6 +23,8 @@ class SYNC_EXPORT InvalidationHandler {
virtual void OnIncomingInvalidation(
const ObjectIdInvalidationMap& invalidation_map) = 0;
+ virtual std::string GetOwnerName() const = 0;
+
protected:
virtual ~InvalidationHandler() {}
};
diff --git a/sync/notifier/invalidator_registrar.cc b/sync/notifier/invalidator_registrar.cc
index 1c9c50c..3345052 100644
--- a/sync/notifier/invalidator_registrar.cc
+++ b/sync/notifier/invalidator_registrar.cc
@@ -123,6 +123,18 @@ InvalidatorState InvalidatorRegistrar::GetInvalidatorState() const {
return state_;
}
+std::map<std::string, ObjectIdSet>
+InvalidatorRegistrar::GetSanitizedHandlersIdsMap() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ std::map<std::string, ObjectIdSet> clean_handlers_to_ids;
+ for (HandlerIdsMap::const_iterator it = handler_to_ids_map_.begin();
+ it != handler_to_ids_map_.end();
+ ++it) {
+ clean_handlers_to_ids[it->first->GetOwnerName()] = ObjectIdSet(it->second);
+ }
+ return clean_handlers_to_ids;
+}
+
bool InvalidatorRegistrar::IsHandlerRegisteredForTest(
InvalidationHandler* handler) const {
DCHECK(thread_checker_.CalledOnValidThread());
diff --git a/sync/notifier/invalidator_registrar.h b/sync/notifier/invalidator_registrar.h
index fb6b388..145b7c3 100644
--- a/sync/notifier/invalidator_registrar.h
+++ b/sync/notifier/invalidator_registrar.h
@@ -71,6 +71,11 @@ class SYNC_EXPORT InvalidatorRegistrar {
// updated state.
InvalidatorState GetInvalidatorState() const;
+ // 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.
+ std::map<std::string, ObjectIdSet> GetSanitizedHandlersIdsMap();
+
bool IsHandlerRegisteredForTest(InvalidationHandler* handler) const;
// Needed for death tests.
diff --git a/sync/notifier/non_blocking_invalidator.cc b/sync/notifier/non_blocking_invalidator.cc
index 1b90a97..ffb9361 100644
--- a/sync/notifier/non_blocking_invalidator.cc
+++ b/sync/notifier/non_blocking_invalidator.cc
@@ -71,6 +71,7 @@ class NonBlockingInvalidator::Core
virtual void OnInvalidatorStateChange(InvalidatorState reason) OVERRIDE;
virtual void OnIncomingInvalidation(
const ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
+ virtual std::string GetOwnerName() const OVERRIDE;
private:
friend class
@@ -147,6 +148,10 @@ void NonBlockingInvalidator::Core::OnIncomingInvalidation(
invalidation_map);
}
+std::string NonBlockingInvalidator::Core::GetOwnerName() const {
+ return "Sync";
+}
+
NonBlockingInvalidator::NonBlockingInvalidator(
NetworkChannelCreator network_channel_creator,
const std::string& invalidator_client_id,
@@ -241,6 +246,8 @@ void NonBlockingInvalidator::OnIncomingInvalidation(
registrar_.DispatchInvalidationsToHandlers(invalidation_map);
}
+std::string NonBlockingInvalidator::GetOwnerName() const { return "Sync"; }
+
NetworkChannelCreator
NonBlockingInvalidator::MakePushClientChannelCreator(
const notifier::NotifierOptions& notifier_options) {
diff --git a/sync/notifier/non_blocking_invalidator.h b/sync/notifier/non_blocking_invalidator.h
index 1b2e072..c0b832a 100644
--- a/sync/notifier/non_blocking_invalidator.h
+++ b/sync/notifier/non_blocking_invalidator.h
@@ -68,6 +68,7 @@ class SYNC_EXPORT_PRIVATE NonBlockingInvalidator
virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE;
virtual void OnIncomingInvalidation(
const ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
+ virtual std::string GetOwnerName() const OVERRIDE;
// Static functions to construct callback that creates network channel for
// SyncSystemResources. The goal is to pass network channel to invalidator at
diff --git a/sync/tools/sync_listen_notifications.cc b/sync/tools/sync_listen_notifications.cc
index 12d089b..b4e45e6 100644
--- a/sync/tools/sync_listen_notifications.cc
+++ b/sync/tools/sync_listen_notifications.cc
@@ -67,6 +67,10 @@ class NotificationPrinter : public InvalidationHandler {
}
}
+ virtual std::string GetOwnerName() const OVERRIDE {
+ return "NotificationPrinter";
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(NotificationPrinter);
};