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_SYNC_INTERNALS_MESSAGE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 class ProfileSyncService; | 22 class ProfileSyncService; |
23 | 23 |
24 // The implementation for the chrome://sync-internals page. | 24 // The implementation for the chrome://sync-internals page. |
25 class SyncInternalsMessageHandler : public content::WebUIMessageHandler, | 25 class SyncInternalsMessageHandler : public content::WebUIMessageHandler, |
26 public syncer::JsEventHandler, | 26 public syncer::JsEventHandler, |
27 public ProfileSyncServiceObserver, | 27 public ProfileSyncServiceObserver, |
28 public browser_sync::ProtocolEventObserver, | 28 public browser_sync::ProtocolEventObserver, |
29 public syncer::TypeDebugInfoObserver { | 29 public syncer::TypeDebugInfoObserver { |
30 public: | 30 public: |
31 SyncInternalsMessageHandler(); | 31 SyncInternalsMessageHandler(); |
32 virtual ~SyncInternalsMessageHandler(); | 32 ~SyncInternalsMessageHandler() override; |
33 | 33 |
34 virtual void RegisterMessages() override; | 34 void RegisterMessages() override; |
35 | 35 |
36 // Sets up observers to receive events and forward them to the UI. | 36 // Sets up observers to receive events and forward them to the UI. |
37 void HandleRegisterForEvents(const base::ListValue* args); | 37 void HandleRegisterForEvents(const base::ListValue* args); |
38 | 38 |
39 // Sets up observers to receive per-type counters and forward them to the UI. | 39 // Sets up observers to receive per-type counters and forward them to the UI. |
40 void HandleRegisterForPerTypeCounters(const base::ListValue* args); | 40 void HandleRegisterForPerTypeCounters(const base::ListValue* args); |
41 | 41 |
42 // Fires an event to send updated info back to the page. | 42 // Fires an event to send updated info back to the page. |
43 void HandleRequestUpdatedAboutInfo(const base::ListValue* args); | 43 void HandleRequestUpdatedAboutInfo(const base::ListValue* args); |
44 | 44 |
45 // Fires and event to send the list of types back to the page. | 45 // Fires and event to send the list of types back to the page. |
46 void HandleRequestListOfTypes(const base::ListValue* args); | 46 void HandleRequestListOfTypes(const base::ListValue* args); |
47 | 47 |
48 // Handler for getAllNodes message. Needs a |request_id| argument. | 48 // Handler for getAllNodes message. Needs a |request_id| argument. |
49 void HandleGetAllNodes(const base::ListValue* args); | 49 void HandleGetAllNodes(const base::ListValue* args); |
50 | 50 |
51 // syncer::JsEventHandler implementation. | 51 // syncer::JsEventHandler implementation. |
52 virtual void HandleJsEvent( | 52 void HandleJsEvent(const std::string& name, |
53 const std::string& name, | 53 const syncer::JsEventDetails& details) override; |
54 const syncer::JsEventDetails& details) override; | |
55 | 54 |
56 // Callback used in GetAllNodes. | 55 // Callback used in GetAllNodes. |
57 void OnReceivedAllNodes(int request_id, scoped_ptr<base::ListValue> nodes); | 56 void OnReceivedAllNodes(int request_id, scoped_ptr<base::ListValue> nodes); |
58 | 57 |
59 // ProfileSyncServiceObserver implementation. | 58 // ProfileSyncServiceObserver implementation. |
60 virtual void OnStateChanged() override; | 59 void OnStateChanged() override; |
61 | 60 |
62 // ProtocolEventObserver implementation. | 61 // ProtocolEventObserver implementation. |
63 virtual void OnProtocolEvent(const syncer::ProtocolEvent& e) override; | 62 void OnProtocolEvent(const syncer::ProtocolEvent& e) override; |
64 | 63 |
65 // TypeDebugInfoObserver implementation. | 64 // TypeDebugInfoObserver implementation. |
66 virtual void OnCommitCountersUpdated( | 65 void OnCommitCountersUpdated(syncer::ModelType type, |
67 syncer::ModelType type, | 66 const syncer::CommitCounters& counters) override; |
68 const syncer::CommitCounters& counters) override; | 67 void OnUpdateCountersUpdated(syncer::ModelType type, |
69 virtual void OnUpdateCountersUpdated( | 68 const syncer::UpdateCounters& counters) override; |
70 syncer::ModelType type, | 69 void OnStatusCountersUpdated(syncer::ModelType type, |
71 const syncer::UpdateCounters& counters) override; | 70 const syncer::StatusCounters& counters) override; |
72 virtual void OnStatusCountersUpdated( | |
73 syncer::ModelType type, | |
74 const syncer::StatusCounters& counters) override; | |
75 | 71 |
76 // Helper to emit counter updates. | 72 // Helper to emit counter updates. |
77 // | 73 // |
78 // Used in implementation of On*CounterUpdated methods. Emits the given | 74 // Used in implementation of On*CounterUpdated methods. Emits the given |
79 // dictionary value with additional data to specify the model type and | 75 // dictionary value with additional data to specify the model type and |
80 // counter type. | 76 // counter type. |
81 void EmitCounterUpdate(syncer::ModelType type, | 77 void EmitCounterUpdate(syncer::ModelType type, |
82 const std::string& counter_type, | 78 const std::string& counter_type, |
83 scoped_ptr<base::DictionaryValue> value); | 79 scoped_ptr<base::DictionaryValue> value); |
84 | 80 |
(...skipping 12 matching lines...) Expand all Loading... |
97 // A flag used to prevent double-registration as TypeDebugInfoObserver with | 93 // A flag used to prevent double-registration as TypeDebugInfoObserver with |
98 // ProfileSyncService. | 94 // ProfileSyncService. |
99 bool is_registered_for_counters_; | 95 bool is_registered_for_counters_; |
100 | 96 |
101 base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_; | 97 base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_; |
102 | 98 |
103 DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler); | 99 DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler); |
104 }; | 100 }; |
105 | 101 |
106 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ | 102 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ |
OLD | NEW |