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_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ |
6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... | |
26 class DictionaryValue; | 26 class DictionaryValue; |
27 class ListValue; | 27 class ListValue; |
28 class Thread; | 28 class Thread; |
29 } | 29 } |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 class BrowserContext; | 32 class BrowserContext; |
33 } | 33 } |
34 | 34 |
35 class DevToolsTargetImpl; | 35 class DevToolsTargetImpl; |
36 class PortForwardingController; | |
36 class Profile; | 37 class Profile; |
37 | 38 |
38 class DevToolsAndroidBridge | 39 class DevToolsAndroidBridge |
39 : public base::RefCountedThreadSafe< | 40 : public base::RefCountedThreadSafe< |
40 DevToolsAndroidBridge, | 41 DevToolsAndroidBridge, |
41 content::BrowserThread::DeleteOnUIThread> { | 42 content::BrowserThread::DeleteOnUIThread> { |
42 public: | 43 public: |
43 typedef base::Callback<void(int result, | 44 typedef base::Callback<void(int result, |
44 const std::string& response)> Callback; | 45 const std::string& response)> Callback; |
45 | 46 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 class DeviceCountListener { | 202 class DeviceCountListener { |
202 public: | 203 public: |
203 virtual void DeviceCountChanged(int count) = 0; | 204 virtual void DeviceCountChanged(int count) = 0; |
204 protected: | 205 protected: |
205 virtual ~DeviceCountListener() {} | 206 virtual ~DeviceCountListener() {} |
206 }; | 207 }; |
207 | 208 |
208 void AddDeviceCountListener(DeviceCountListener* listener); | 209 void AddDeviceCountListener(DeviceCountListener* listener); |
209 void RemoveDeviceCountListener(DeviceCountListener* listener); | 210 void RemoveDeviceCountListener(DeviceCountListener* listener); |
210 | 211 |
212 typedef int PortStatus; | |
dgozman
2014/08/27 08:08:34
Why this class doesn't expose status constants? Wh
vkuzkokov
2014/09/01 16:13:41
Status is compared only in JS.
| |
213 typedef std::map<int, PortStatus> PortStatusMap; | |
214 typedef std::map<std::string, PortStatusMap> DevicesStatus; | |
215 | |
216 class PortForwardingListener { | |
217 public: | |
218 typedef DevToolsAndroidBridge::PortStatusMap PortStatusMap; | |
219 typedef DevToolsAndroidBridge::DevicesStatus DevicesStatus; | |
220 | |
221 virtual void PortStatusChanged(const DevicesStatus&) = 0; | |
222 protected: | |
223 virtual ~PortForwardingListener() {} | |
224 }; | |
225 | |
226 void AddPortForwardingListener(PortForwardingListener* listener); | |
227 void RemovePortForwardingListener(PortForwardingListener* listener); | |
228 | |
211 void set_device_providers_for_test( | 229 void set_device_providers_for_test( |
212 const AndroidDeviceManager::DeviceProviders& device_providers) { | 230 const AndroidDeviceManager::DeviceProviders& device_providers) { |
213 device_manager_->SetDeviceProviders(device_providers); | 231 device_manager_->SetDeviceProviders(device_providers); |
214 } | 232 } |
215 | 233 |
216 void set_task_scheduler_for_test( | 234 void set_task_scheduler_for_test( |
217 base::Callback<void(const base::Closure&)> scheduler) { | 235 base::Callback<void(const base::Closure&)> scheduler) { |
218 task_scheduler_ = scheduler; | 236 task_scheduler_ = scheduler; |
219 } | 237 } |
220 | 238 |
221 static bool HasDevToolsWindow(const std::string& agent_id); | 239 static bool HasDevToolsWindow(const std::string& agent_id); |
222 | 240 |
223 private: | 241 private: |
224 friend struct content::BrowserThread::DeleteOnThread< | 242 friend struct content::BrowserThread::DeleteOnThread< |
225 content::BrowserThread::UI>; | 243 content::BrowserThread::UI>; |
226 friend class base::DeleteHelper<DevToolsAndroidBridge>; | 244 friend class base::DeleteHelper<DevToolsAndroidBridge>; |
227 | 245 |
228 virtual ~DevToolsAndroidBridge(); | 246 virtual ~DevToolsAndroidBridge(); |
229 | 247 |
230 void StartDeviceListPolling(); | 248 void StartDeviceListPolling(); |
231 void StopDeviceListPolling(); | 249 void StopDeviceListPolling(); |
250 bool NeedsDeviceListPolling(); | |
232 void RequestDeviceList( | 251 void RequestDeviceList( |
233 const base::Callback<void(const RemoteDevices&)>& callback); | 252 const base::Callback<void(const RemoteDevices&)>& callback); |
234 void ReceivedDeviceList(const RemoteDevices& devices); | 253 void ReceivedDeviceList(const RemoteDevices& devices); |
235 void StartDeviceCountPolling(); | 254 void StartDeviceCountPolling(); |
236 void StopDeviceCountPolling(); | 255 void StopDeviceCountPolling(); |
237 void RequestDeviceCount(const base::Callback<void(int)>& callback); | 256 void RequestDeviceCount(const base::Callback<void(int)>& callback); |
238 void ReceivedDeviceCount(int count); | 257 void ReceivedDeviceCount(int count); |
239 | 258 |
240 static void ScheduleTaskDefault(const base::Closure& task); | 259 static void ScheduleTaskDefault(const base::Closure& task); |
241 | 260 |
242 void CreateDeviceProviders(); | 261 void CreateDeviceProviders(); |
243 | 262 |
244 Profile* profile_; | 263 Profile* profile_; |
245 scoped_refptr<AndroidDeviceManager> device_manager_; | 264 scoped_refptr<AndroidDeviceManager> device_manager_; |
246 RemoteDevices devices_; | 265 RemoteDevices devices_; |
247 | 266 |
248 typedef std::vector<DeviceListListener*> DeviceListListeners; | 267 typedef std::vector<DeviceListListener*> DeviceListListeners; |
249 DeviceListListeners device_list_listeners_; | 268 DeviceListListeners device_list_listeners_; |
250 base::CancelableCallback<void(const RemoteDevices&)> device_list_callback_; | 269 base::CancelableCallback<void(const RemoteDevices&)> device_list_callback_; |
251 | 270 |
252 typedef std::vector<DeviceCountListener*> DeviceCountListeners; | 271 typedef std::vector<DeviceCountListener*> DeviceCountListeners; |
253 DeviceCountListeners device_count_listeners_; | 272 DeviceCountListeners device_count_listeners_; |
254 base::CancelableCallback<void(int)> device_count_callback_; | 273 base::CancelableCallback<void(int)> device_count_callback_; |
255 base::Callback<void(const base::Closure&)> task_scheduler_; | 274 base::Callback<void(const base::Closure&)> task_scheduler_; |
256 | 275 |
276 typedef std::vector<PortForwardingListener*> PortForwardingListeners; | |
277 PortForwardingListeners port_forwarding_listeners_; | |
278 scoped_ptr<PortForwardingController> port_forwarding_controller_; | |
279 | |
257 PrefChangeRegistrar pref_change_registrar_; | 280 PrefChangeRegistrar pref_change_registrar_; |
258 DISALLOW_COPY_AND_ASSIGN(DevToolsAndroidBridge); | 281 DISALLOW_COPY_AND_ASSIGN(DevToolsAndroidBridge); |
259 }; | 282 }; |
260 | 283 |
261 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ | 284 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ |
OLD | NEW |