1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_MESSAGE_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_MESSAGE_HANDLER_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/values.h"
12 #include "components/invalidation/invalidation_logger_observer.h"
13 #include "components/invalidation/invalidation_util.h"
14 #include "content/public/browser/web_ui_message_handler.h"
18 namespace invalidation
{
19 class InvalidationLogger
;
20 } // namespace invalidation
23 class InvalidationHandler
;
26 // The implementation for the chrome://invalidations page.
27 class InvalidationsMessageHandler
28 : public content::WebUIMessageHandler
,
29 public invalidation::InvalidationLoggerObserver
{
31 InvalidationsMessageHandler();
32 ~InvalidationsMessageHandler() override
;
34 // Implementation of InvalidationLoggerObserver.
35 void OnRegistrationChange(
36 const std::multiset
<std::string
>& registered_handlers
) override
;
37 void OnStateChange(const syncer::InvalidatorState
& new_state
,
38 const base::Time
& last_change_timestamp
) override
;
39 void OnUpdateIds(const std::string
& handler_name
,
40 const syncer::ObjectIdCountMap
& ids_set
) override
;
41 void OnDebugMessage(const base::DictionaryValue
& details
) override
;
43 const syncer::ObjectIdInvalidationMap
& new_invalidations
) override
;
44 void OnDetailedStatus(const base::DictionaryValue
& network_details
) override
;
46 // Implementation of WebUIMessageHandler.
47 void RegisterMessages() override
;
49 // Triggers the logger to send the current state and objects ids.
50 void UpdateContent(const base::ListValue
* args
);
52 // Called by the javascript whenever the page is ready to receive messages.
53 void UIReady(const base::ListValue
* args
);
55 // Calls the InvalidationService for any internal details.
56 void HandleRequestDetailedStatus(const base::ListValue
* args
);
59 // The pointer to the internal InvalidatorService InvalidationLogger.
60 // Used to get the information necessary to display to the JS and to
61 // register ourselves as Observers for any notifications.
62 invalidation::InvalidationLogger
* logger_
;
64 base::WeakPtrFactory
<InvalidationsMessageHandler
> weak_ptr_factory_
;
66 DISALLOW_COPY_AND_ASSIGN(InvalidationsMessageHandler
);
69 #endif // CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_MESSAGE_HANDLER_H_