| 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_task_scheduler_for_test( |
| 217 base::Callback<void(const base::Closure&)> scheduler) { |
| 218 task_scheduler_ = 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 StartDeviceCountPolling(); |
| 236 void StopDeviceCountPolling(); |
| 237 void RequestDeviceCount(const base::Callback<void(int)>& callback); |
| 227 void ReceivedDeviceCount(int count); | 238 void ReceivedDeviceCount(int count); |
| 228 | 239 |
| 240 static void ScheduleTaskDefault(const base::Closure& task); |
| 241 |
| 229 void CreateDeviceProviders(); | 242 void CreateDeviceProviders(); |
| 230 | 243 |
| 231 Profile* profile_; | 244 Profile* profile_; |
| 232 scoped_refptr<AndroidDeviceManager> device_manager_; | 245 scoped_refptr<AndroidDeviceManager> device_manager_; |
| 233 RemoteDevices devices_; | 246 RemoteDevices devices_; |
| 234 | 247 |
| 235 typedef std::vector<DeviceListListener*> DeviceListListeners; | 248 typedef std::vector<DeviceListListener*> DeviceListListeners; |
| 236 DeviceListListeners device_list_listeners_; | 249 DeviceListListeners device_list_listeners_; |
| 250 base::CancelableCallback<void(const RemoteDevices&)> device_list_callback_; |
| 237 | 251 |
| 238 typedef std::vector<DeviceCountListener*> DeviceCountListeners; | 252 typedef std::vector<DeviceCountListener*> DeviceCountListeners; |
| 239 DeviceCountListeners device_count_listeners_; | 253 DeviceCountListeners device_count_listeners_; |
| 254 base::CancelableCallback<void(int)> device_count_callback_; |
| 255 base::Callback<void(const base::Closure&)> task_scheduler_; |
| 240 | 256 |
| 241 PrefChangeRegistrar pref_change_registrar_; | 257 PrefChangeRegistrar pref_change_registrar_; |
| 242 DISALLOW_COPY_AND_ASSIGN(DevToolsAndroidBridge); | 258 DISALLOW_COPY_AND_ASSIGN(DevToolsAndroidBridge); |
| 243 }; | 259 }; |
| 244 | 260 |
| 245 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ | 261 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ |
| OLD | NEW |