OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 IOS_CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_SYNC_INTERNALS_MESSAGE_HANDLE
R_H_ | 5 #ifndef IOS_CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_SYNC_INTERNALS_MESSAGE_HANDLE
R_H_ |
6 #define IOS_CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_SYNC_INTERNALS_MESSAGE_HANDLE
R_H_ | 6 #define IOS_CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_SYNC_INTERNALS_MESSAGE_HANDLE
R_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
12 #include "components/sync_driver/protocol_event_observer.h" | 13 #include "components/sync_driver/protocol_event_observer.h" |
13 #include "components/sync_driver/sync_service_observer.h" | 14 #include "components/sync_driver/sync_service_observer.h" |
14 #include "ios/public/provider/web/web_ui_ios_message_handler.h" | 15 #include "ios/public/provider/web/web_ui_ios_message_handler.h" |
15 #include "sync/internal_api/public/sessions/type_debug_info_observer.h" | 16 #include "sync/internal_api/public/sessions/type_debug_info_observer.h" |
16 #include "sync/js/js_controller.h" | 17 #include "sync/js/js_controller.h" |
17 #include "sync/js/js_event_handler.h" | 18 #include "sync/js/js_event_handler.h" |
(...skipping 27 matching lines...) Expand all Loading... |
45 void HandleRequestListOfTypes(const base::ListValue* args); | 46 void HandleRequestListOfTypes(const base::ListValue* args); |
46 | 47 |
47 // Handler for getAllNodes message. Needs a |request_id| argument. | 48 // Handler for getAllNodes message. Needs a |request_id| argument. |
48 void HandleGetAllNodes(const base::ListValue* args); | 49 void HandleGetAllNodes(const base::ListValue* args); |
49 | 50 |
50 // syncer::JsEventHandler implementation. | 51 // syncer::JsEventHandler implementation. |
51 void HandleJsEvent(const std::string& name, | 52 void HandleJsEvent(const std::string& name, |
52 const syncer::JsEventDetails& details) override; | 53 const syncer::JsEventDetails& details) override; |
53 | 54 |
54 // Callback used in GetAllNodes. | 55 // Callback used in GetAllNodes. |
55 void OnReceivedAllNodes(int request_id, scoped_ptr<base::ListValue> nodes); | 56 void OnReceivedAllNodes(int request_id, |
| 57 std::unique_ptr<base::ListValue> nodes); |
56 | 58 |
57 // sync_driver::SyncServiceObserver implementation. | 59 // sync_driver::SyncServiceObserver implementation. |
58 void OnStateChanged() override; | 60 void OnStateChanged() override; |
59 | 61 |
60 // ProtocolEventObserver implementation. | 62 // ProtocolEventObserver implementation. |
61 void OnProtocolEvent(const syncer::ProtocolEvent& e) override; | 63 void OnProtocolEvent(const syncer::ProtocolEvent& e) override; |
62 | 64 |
63 // TypeDebugInfoObserver implementation. | 65 // TypeDebugInfoObserver implementation. |
64 void OnCommitCountersUpdated(syncer::ModelType type, | 66 void OnCommitCountersUpdated(syncer::ModelType type, |
65 const syncer::CommitCounters& counters) override; | 67 const syncer::CommitCounters& counters) override; |
66 void OnUpdateCountersUpdated(syncer::ModelType type, | 68 void OnUpdateCountersUpdated(syncer::ModelType type, |
67 const syncer::UpdateCounters& counters) override; | 69 const syncer::UpdateCounters& counters) override; |
68 void OnStatusCountersUpdated(syncer::ModelType type, | 70 void OnStatusCountersUpdated(syncer::ModelType type, |
69 const syncer::StatusCounters& counters) override; | 71 const syncer::StatusCounters& counters) override; |
70 | 72 |
71 // Helper to emit counter updates. | 73 // Helper to emit counter updates. |
72 // | 74 // |
73 // Used in implementation of On*CounterUpdated methods. Emits the given | 75 // Used in implementation of On*CounterUpdated methods. Emits the given |
74 // dictionary value with additional data to specify the model type and | 76 // dictionary value with additional data to specify the model type and |
75 // counter type. | 77 // counter type. |
76 void EmitCounterUpdate(syncer::ModelType type, | 78 void EmitCounterUpdate(syncer::ModelType type, |
77 const std::string& counter_type, | 79 const std::string& counter_type, |
78 scoped_ptr<base::DictionaryValue> value); | 80 std::unique_ptr<base::DictionaryValue> value); |
79 | 81 |
80 private: | 82 private: |
81 // Fetches updated aboutInfo and sends it to the page in the form of an | 83 // Fetches updated aboutInfo and sends it to the page in the form of an |
82 // onAboutInfoUpdated event. | 84 // onAboutInfoUpdated event. |
83 void SendAboutInfo(); | 85 void SendAboutInfo(); |
84 | 86 |
85 sync_driver::SyncService* GetSyncService(); | 87 sync_driver::SyncService* GetSyncService(); |
86 | 88 |
87 base::WeakPtr<syncer::JsController> js_controller_; | 89 base::WeakPtr<syncer::JsController> js_controller_; |
88 | 90 |
89 // A flag used to prevent double-registration with ProfileSyncService. | 91 // A flag used to prevent double-registration with ProfileSyncService. |
90 bool is_registered_; | 92 bool is_registered_; |
91 | 93 |
92 // A flag used to prevent double-registration as TypeDebugInfoObserver with | 94 // A flag used to prevent double-registration as TypeDebugInfoObserver with |
93 // ProfileSyncService. | 95 // ProfileSyncService. |
94 bool is_registered_for_counters_; | 96 bool is_registered_for_counters_; |
95 | 97 |
96 base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_; | 98 base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_; |
97 | 99 |
98 DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler); | 100 DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler); |
99 }; | 101 }; |
100 | 102 |
101 #endif // IOS_CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_SYNC_INTERNALS_MESSAGE_HAN
DLER_H_ | 103 #endif // IOS_CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_SYNC_INTERNALS_MESSAGE_HAN
DLER_H_ |
OLD | NEW |