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 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/cancelable_callback.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/prefs/pref_change_registrar.h" | 15 #include "base/prefs/pref_change_registrar.h" |
15 #include "chrome/browser/devtools/device/android_device_manager.h" | 16 #include "chrome/browser/devtools/device/android_device_manager.h" |
16 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 17 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
17 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
18 #include "content/public/browser/devtools_agent_host.h" | 19 #include "content/public/browser/devtools_agent_host.h" |
19 #include "ui/gfx/size.h" | 20 #include "ui/gfx/size.h" |
20 | 21 |
21 template<typename T> struct DefaultSingletonTraits; | 22 template<typename T> struct DefaultSingletonTraits; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 }; | 206 }; |
206 | 207 |
207 void AddDeviceCountListener(DeviceCountListener* listener); | 208 void AddDeviceCountListener(DeviceCountListener* listener); |
208 void RemoveDeviceCountListener(DeviceCountListener* listener); | 209 void RemoveDeviceCountListener(DeviceCountListener* listener); |
209 | 210 |
210 void set_device_providers_for_test( | 211 void set_device_providers_for_test( |
211 const AndroidDeviceManager::DeviceProviders& device_providers) { | 212 const AndroidDeviceManager::DeviceProviders& device_providers) { |
212 device_manager_->SetDeviceProviders(device_providers); | 213 device_manager_->SetDeviceProviders(device_providers); |
213 } | 214 } |
214 | 215 |
| 216 void set_device_count_scheduler_for_test( |
| 217 base::Callback<void(base::Closure)> scheduler) { |
| 218 device_count_scheduler_for_test_ = scheduler; |
| 219 } |
| 220 |
215 static bool HasDevToolsWindow(const std::string& agent_id); | 221 static bool HasDevToolsWindow(const std::string& agent_id); |
216 | 222 |
217 private: | 223 private: |
218 friend struct content::BrowserThread::DeleteOnThread< | 224 friend struct content::BrowserThread::DeleteOnThread< |
219 content::BrowserThread::UI>; | 225 content::BrowserThread::UI>; |
220 friend class base::DeleteHelper<DevToolsAndroidBridge>; | 226 friend class base::DeleteHelper<DevToolsAndroidBridge>; |
221 | 227 |
222 virtual ~DevToolsAndroidBridge(); | 228 virtual ~DevToolsAndroidBridge(); |
223 | 229 |
224 void RequestDeviceList(); | 230 void StartDeviceListPolling(); |
225 void ReceivedDeviceList(scoped_ptr<RemoteDevices> devices); | 231 void StopDeviceListPolling(); |
226 void RequestDeviceCount(); | 232 void RequestDeviceList( |
| 233 const base::Callback<void(const RemoteDevices&)>& callback); |
| 234 void ReceivedDeviceList(const RemoteDevices& devices); |
| 235 void RequestDeviceCount(const base::Callback<void(int)>& callback); |
227 void ReceivedDeviceCount(int count); | 236 void ReceivedDeviceCount(int count); |
| 237 void ScheduleDeviceCountRequest(const base::Closure& callback); |
228 | 238 |
229 void CreateDeviceProviders(); | 239 void CreateDeviceProviders(); |
230 | 240 |
231 Profile* profile_; | 241 Profile* profile_; |
232 scoped_refptr<AndroidDeviceManager> device_manager_; | 242 scoped_refptr<AndroidDeviceManager> device_manager_; |
233 RemoteDevices devices_; | 243 RemoteDevices devices_; |
234 | 244 |
235 typedef std::vector<DeviceListListener*> DeviceListListeners; | 245 typedef std::vector<DeviceListListener*> DeviceListListeners; |
236 DeviceListListeners device_list_listeners_; | 246 DeviceListListeners device_list_listeners_; |
| 247 base::CancelableCallback<void(const RemoteDevices&)> device_list_callback_; |
237 | 248 |
238 typedef std::vector<DeviceCountListener*> DeviceCountListeners; | 249 typedef std::vector<DeviceCountListener*> DeviceCountListeners; |
239 DeviceCountListeners device_count_listeners_; | 250 DeviceCountListeners device_count_listeners_; |
| 251 base::CancelableCallback<void(int)> device_count_callback_; |
| 252 base::Callback<void(base::Closure)> device_count_scheduler_for_test_; |
240 | 253 |
241 PrefChangeRegistrar pref_change_registrar_; | 254 PrefChangeRegistrar pref_change_registrar_; |
242 DISALLOW_COPY_AND_ASSIGN(DevToolsAndroidBridge); | 255 DISALLOW_COPY_AND_ASSIGN(DevToolsAndroidBridge); |
243 }; | 256 }; |
244 | 257 |
245 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ | 258 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ |
OLD | NEW |