Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / webui / invalidations_message_handler.h
blob2320ba45e9cd6310e2ebcce6d0e02fea1316b064
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"
16 class Profile;
18 namespace invalidation {
19 class InvalidationLogger;
20 } // namespace invalidation
22 namespace syncer {
23 class InvalidationHandler;
24 } // namespace syncer
26 // The implementation for the chrome://invalidations page.
27 class InvalidationsMessageHandler
28 : public content::WebUIMessageHandler,
29 public invalidation::InvalidationLoggerObserver {
30 public:
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;
42 void OnInvalidation(
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);
58 private:
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_