OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_MESSAGE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_MESSAGE_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_MESSAGE_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_MESSAGE_HANDLER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/invalidation/invalidation_logger_observer.h" | 11 #include "chrome/browser/invalidation/invalidation_logger_observer.h" |
12 #include "content/public/browser/web_ui_message_handler.h" | 12 #include "content/public/browser/web_ui_message_handler.h" |
| 13 #include "sync/notifier/invalidation_util.h" |
13 | 14 |
14 class Profile; | 15 class Profile; |
15 | 16 |
16 namespace invalidation { | 17 namespace invalidation { |
17 class InvalidationLogger; | 18 class InvalidationLogger; |
18 } // namespace invalidation | 19 } // namespace invalidation |
19 | 20 |
| 21 namespace syncer { |
| 22 class InvalidationHandler; |
| 23 } // namespace syncer |
| 24 |
20 // The implementation for the chrome://invalidations page. | 25 // The implementation for the chrome://invalidations page. |
21 class InvalidationsMessageHandler | 26 class InvalidationsMessageHandler |
22 : public content::WebUIMessageHandler, | 27 : public content::WebUIMessageHandler, |
23 public invalidation::InvalidationLoggerObserver { | 28 public invalidation::InvalidationLoggerObserver { |
24 public: | 29 public: |
25 InvalidationsMessageHandler(); | 30 InvalidationsMessageHandler(); |
26 virtual ~InvalidationsMessageHandler(); | 31 virtual ~InvalidationsMessageHandler(); |
27 | 32 |
28 // Implementation of InvalidationLoggerObserver | 33 // Implementation of InvalidationLoggerObserver |
29 virtual void OnRegistration(const base::DictionaryValue& details) OVERRIDE; | 34 virtual void OnRegistration(const base::DictionaryValue& details) OVERRIDE; |
30 virtual void OnUnregistration(const base::DictionaryValue& details) OVERRIDE; | 35 virtual void OnUnregistration(const base::DictionaryValue& details) OVERRIDE; |
31 virtual void OnStateChange(const syncer::InvalidatorState& newState) OVERRIDE; | 36 virtual void OnStateChange(const syncer::InvalidatorState& newState) OVERRIDE; |
32 virtual void OnUpdateIds(const base::DictionaryValue& details) OVERRIDE; | 37 virtual void OnUpdateIds(std::string handlerName, |
| 38 const syncer::ObjectIdSet& idsSet) OVERRIDE; |
33 virtual void OnDebugMessage(const base::DictionaryValue& details) OVERRIDE; | 39 virtual void OnDebugMessage(const base::DictionaryValue& details) OVERRIDE; |
34 virtual void OnInvalidation( | 40 virtual void OnInvalidation( |
35 const syncer::ObjectIdInvalidationMap& newInvalidations) OVERRIDE; | 41 const syncer::ObjectIdInvalidationMap& newInvalidations) OVERRIDE; |
36 | 42 |
37 // Implementation of WebUIMessageHandler | 43 // Implementation of WebUIMessageHandler |
38 virtual void RegisterMessages() OVERRIDE; | 44 virtual void RegisterMessages() OVERRIDE; |
39 | 45 |
40 void UpdateContent(const base::ListValue* args); | 46 void UpdateContent(const base::ListValue* args); |
41 void UIReady(const base::ListValue* args); | 47 void UIReady(const base::ListValue* args); |
42 | 48 |
43 private: | 49 private: |
| 50 scoped_ptr<base::ListValue> ObjectIdSetToList( |
| 51 const syncer::ObjectIdSet& idsSet); |
44 // The pointer to the internal InvalidatorService InvalidationLogger. | 52 // The pointer to the internal InvalidatorService InvalidationLogger. |
45 // Used to get the information necessary to display to the JS and to | 53 // Used to get the information necessary to display to the JS and to |
46 // register ourselves as Observers for any notifications. | 54 // register ourselves as Observers for any notifications. |
47 invalidation::InvalidationLogger* logger_; | 55 invalidation::InvalidationLogger* logger_; |
48 // Check to see if we are already registered as an observer | 56 // Check to see if we are already registered as an observer |
49 bool isRegistered; | 57 bool isRegistered; |
50 DISALLOW_COPY_AND_ASSIGN(InvalidationsMessageHandler); | 58 DISALLOW_COPY_AND_ASSIGN(InvalidationsMessageHandler); |
51 }; | 59 }; |
52 | 60 |
53 #endif // CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_MESSAGE_HANDLER_H_ | 61 #endif // CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_MESSAGE_HANDLER_H_ |
OLD | NEW |