Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: chrome/browser/ui/webui/sync_internals_message_handler.h

Issue 2910773003: [Sync] Replace manual DI with SetTestingFactory. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/webui/sync_internals_message_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // Helper to emit counter updates. 89 // Helper to emit counter updates.
90 // 90 //
91 // Used in implementation of On*CounterUpdated methods. Emits the given 91 // Used in implementation of On*CounterUpdated methods. Emits the given
92 // dictionary value with additional data to specify the model type and 92 // dictionary value with additional data to specify the model type and
93 // counter type. 93 // counter type.
94 void EmitCounterUpdate(syncer::ModelType type, 94 void EmitCounterUpdate(syncer::ModelType type,
95 const std::string& counter_type, 95 const std::string& counter_type,
96 std::unique_ptr<base::DictionaryValue> value); 96 std::unique_ptr<base::DictionaryValue> value);
97 97
98 protected: 98 protected:
99 using SyncServiceProvider = base::RepeatingCallback<syncer::SyncService*()>;
100
101 using AboutSyncDataDelegate = 99 using AboutSyncDataDelegate =
102 base::RepeatingCallback<std::unique_ptr<base::DictionaryValue>( 100 base::RepeatingCallback<std::unique_ptr<base::DictionaryValue>(
103 syncer::SyncService* service, 101 syncer::SyncService* service,
104 version_info::Channel channel)>; 102 version_info::Channel channel)>;
105 103
106 // Constructor used for unit testing to override dependencies. 104 // Constructor used for unit testing to override dependencies.
107 SyncInternalsMessageHandler(SyncServiceProvider sync_service_provider, 105 explicit SyncInternalsMessageHandler(
108 AboutSyncDataDelegate about_sync_data_delegate); 106 AboutSyncDataDelegate about_sync_data_delegate);
109 107
110 private: 108 private:
111 // Fetches updated aboutInfo and sends it to the page in the form of an 109 // Fetches updated aboutInfo and sends it to the page in the form of an
112 // onAboutInfoUpdated event. 110 // onAboutInfoUpdated event.
113 void SendAboutInfo(); 111 void SendAboutInfo();
114 112
115 // Gets the ProfileSyncService of the underlying original profile. May return 113 // Gets the ProfileSyncService of the underlying original profile. May return
116 // nullptr (e.g., if sync is disabled on the command line). Shouldn't be 114 // nullptr (e.g., if sync is disabled on the command line).
117 // called directly, but instead through |sync_service_provider_|. 115 syncer::SyncService* GetSyncService();
118 syncer::SyncService* BindForSyncServiceProvider();
119 116
120 // Sends a dispatch event to the UI. Javascript must be enabled. 117 // Sends a dispatch event to the UI. Javascript must be enabled.
121 void DispatchEvent(const std::string& name, const base::Value& details_value); 118 void DispatchEvent(const std::string& name, const base::Value& details_value);
122 119
123 // Unregisters for notifications from all notifications coming from the sync 120 // Unregisters for notifications from all notifications coming from the sync
124 // machinery. Leaves notifications hooked into the UI alone. 121 // machinery. Leaves notifications hooked into the UI alone.
125 void UnregisterModelNotifications(); 122 void UnregisterModelNotifications();
126 123
127 base::WeakPtr<syncer::JsController> js_controller_; 124 base::WeakPtr<syncer::JsController> js_controller_;
128 125
129 // A flag used to prevent double-registration with ProfileSyncService. 126 // A flag used to prevent double-registration with ProfileSyncService.
130 bool is_registered_ = false; 127 bool is_registered_ = false;
131 128
132 // A flag used to prevent double-registration as TypeDebugInfoObserver with 129 // A flag used to prevent double-registration as TypeDebugInfoObserver with
133 // ProfileSyncService. 130 // ProfileSyncService.
134 bool is_registered_for_counters_ = false; 131 bool is_registered_for_counters_ = false;
135 132
136 // An abstraction of who provides the SyncService.
137 SyncServiceProvider sync_service_provider_;
138
139 // An abstraction of who creates the about sync info value map. 133 // An abstraction of who creates the about sync info value map.
140 AboutSyncDataDelegate about_sync_data_delegate_; 134 AboutSyncDataDelegate about_sync_data_delegate_;
141 135
142 base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_; 136 base::WeakPtrFactory<SyncInternalsMessageHandler> weak_ptr_factory_;
143 137
144 DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler); 138 DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler);
145 }; 139 };
146 140
147 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_ 141 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/sync_internals_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698