#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "chrome/browser/sync/protocol_event_observer.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "sync/internal_api/public/sessions/type_debug_info_observer.h"
#include "sync/js/js_controller.h"
#include "sync/js/js_event_handler.h"
class ProfileSyncService;
// The implementation for the chrome://sync-internals page.
-class SyncInternalsMessageHandler
- : public content::WebUIMessageHandler,
- public syncer::JsEventHandler,
- public ProfileSyncServiceObserver,
- public browser_sync::ProtocolEventObserver {
+class SyncInternalsMessageHandler : public content::WebUIMessageHandler,
+ public syncer::JsEventHandler,
+ public ProfileSyncServiceObserver,
+ public browser_sync::ProtocolEventObserver,
+ public syncer::TypeDebugInfoObserver {
public:
SyncInternalsMessageHandler();
- virtual ~SyncInternalsMessageHandler();
+ ~SyncInternalsMessageHandler() override;
- virtual void RegisterMessages() OVERRIDE;
+ void RegisterMessages() override;
// Sets up observers to receive events and forward them to the UI.
void HandleRegisterForEvents(const base::ListValue* args);
+ // Sets up observers to receive per-type counters and forward them to the UI.
+ void HandleRegisterForPerTypeCounters(const base::ListValue* args);
+
// Fires an event to send updated info back to the page.
void HandleRequestUpdatedAboutInfo(const base::ListValue* args);
void HandleGetAllNodes(const base::ListValue* args);
// syncer::JsEventHandler implementation.
- virtual void HandleJsEvent(
- const std::string& name,
- const syncer::JsEventDetails& details) OVERRIDE;
+ void HandleJsEvent(const std::string& name,
+ const syncer::JsEventDetails& details) override;
// Callback used in GetAllNodes.
void OnReceivedAllNodes(int request_id, scoped_ptr<base::ListValue> nodes);
// ProfileSyncServiceObserver implementation.
- virtual void OnStateChanged() OVERRIDE;
+ void OnStateChanged() override;
// ProtocolEventObserver implementation.
- virtual void OnProtocolEvent(const syncer::ProtocolEvent& e) OVERRIDE;
+ void OnProtocolEvent(const syncer::ProtocolEvent& e) override;
+
+ // TypeDebugInfoObserver implementation.
+ void OnCommitCountersUpdated(syncer::ModelType type,
+ const syncer::CommitCounters& counters) override;
+ void OnUpdateCountersUpdated(syncer::ModelType type,
+ const syncer::UpdateCounters& counters) override;
+ void OnStatusCountersUpdated(syncer::ModelType type,
+ const syncer::StatusCounters& counters) override;
+
+ // Helper to emit counter updates.
+ //
+ // Used in implementation of On*CounterUpdated methods. Emits the given
+ // dictionary value with additional data to specify the model type and
+ // counter type.
+ void EmitCounterUpdate(syncer::ModelType type,
+ const std::string& counter_type,
+ scoped_ptr<base::DictionaryValue> value);
private:
// Fetches updated aboutInfo and sends it to the page in the form of an
// A flag used to prevent double-registration with ProfileSyncService.
bool is_registered_;
+ // A flag used to prevent double-registration as TypeDebugInfoObserver with
+ // ProfileSyncService.
+ bool is_registered_for_counters_;
+
base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler);