Index: chrome/browser/devtools/device/devtools_android_bridge.h |
diff --git a/chrome/browser/devtools/device/devtools_android_bridge.h b/chrome/browser/devtools/device/devtools_android_bridge.h |
index 6a0f781e8138db2e0c4df7204a4de1a33537ee0f..29e7a07102125b92d0487d3c93bd86aaf6b21932 100644 |
--- a/chrome/browser/devtools/device/devtools_android_bridge.h |
+++ b/chrome/browser/devtools/device/devtools_android_bridge.h |
@@ -107,15 +107,44 @@ class DevToolsAndroidBridge |
}; |
typedef base::Callback<void(RemotePage*)> RemotePageCallback; |
+ typedef base::Callback<void(int, const std::string&)> JsonRequestCallback; |
+ |
+ class DeviceHandle : public base::RefCounted<DeviceHandle> { |
pfeldman
2014/05/21 11:33:41
This does not need to be public.
|
+ public: |
+ DeviceHandle(scoped_refptr<DevToolsAndroidBridge> android_bridge, |
+ const std::string& serial); |
+ |
+ std::string serial() const { return serial_; } |
+ |
+ void SendJsonRequest(const std::string& socket, |
+ const std::string& request, |
+ const JsonRequestCallback& callback); |
+ |
+ void OpenSocket(const std::string& socket_name, |
+ const AndroidDeviceManager::SocketCallback& callback); |
+ |
+ scoped_refptr<AndroidWebSocket> CreateWebSocket( |
+ const std::string& socket, |
+ const std::string& url, |
+ DevToolsAndroidBridge::AndroidWebSocket::Delegate* delegate); |
+ |
+ private: |
+ friend class base::RefCounted<DeviceHandle>; |
+ virtual ~DeviceHandle(); |
+ |
+ scoped_refptr<DevToolsAndroidBridge> android_bridge_; |
pfeldman
2014/05/21 11:33:41
Introducing devtools_manager field along this one
|
+ const std::string serial_; |
+ }; |
+ |
+ typedef std::map<std::string, scoped_refptr<DeviceHandle> > DeviceHandleMap; |
class RemoteBrowser : public base::RefCounted<RemoteBrowser> { |
public: |
RemoteBrowser( |
- scoped_refptr<DevToolsAndroidBridge> android_bridge, |
- const std::string& serial, |
+ scoped_refptr<DeviceHandle> device_handle, |
const AndroidDeviceManager::BrowserInfo& browser_info); |
- std::string serial() { return serial_; } |
+ std::string serial() { return device_handle_->serial(); } |
std::string socket() { return socket_; } |
std::string display_name() { return display_name_; } |
@@ -133,7 +162,6 @@ class DevToolsAndroidBridge |
std::vector<RemotePage*> CreatePages(); |
void SetPageDescriptors(const base::ListValue&); |
- typedef base::Callback<void(int, const std::string&)> JsonRequestCallback; |
void SendJsonRequest(const std::string& request, |
const JsonRequestCallback& callback); |
void SendProtocolCommand(const std::string& debug_url, |
@@ -171,8 +199,7 @@ class DevToolsAndroidBridge |
int result, |
const std::string& response); |
- scoped_refptr<DevToolsAndroidBridge> android_bridge_; |
- const std::string serial_; |
+ scoped_refptr<DeviceHandle> device_handle_; |
const std::string socket_; |
std::string display_name_; |
const AndroidDeviceManager::BrowserInfo::Type type_; |
@@ -186,12 +213,11 @@ class DevToolsAndroidBridge |
class RemoteDevice : public base::RefCounted<RemoteDevice> { |
public: |
- RemoteDevice(scoped_refptr<DevToolsAndroidBridge> android_bridge, |
- const std::string& serial, |
+ RemoteDevice(scoped_refptr<DeviceHandle> device_handle, |
const AndroidDeviceManager::DeviceInfo& device_info, |
bool connected); |
- std::string serial() { return serial_; } |
+ std::string serial() { return device_handle_->serial(); } |
std::string model() { return model_; } |
bool is_connected() { return connected_; } |
RemoteBrowsers& browsers() { return browsers_; } |
@@ -204,8 +230,7 @@ class DevToolsAndroidBridge |
friend class base::RefCounted<RemoteDevice>; |
virtual ~RemoteDevice(); |
- scoped_refptr<DevToolsAndroidBridge> android_bridge_; |
- std::string serial_; |
+ scoped_refptr<DeviceHandle> device_handle_; |
std::string model_; |
bool connected_; |
RemoteBrowsers browsers_; |
@@ -244,6 +269,9 @@ class DevToolsAndroidBridge |
static bool HasDevToolsWindow(const std::string& agent_id); |
+ void IsConnectedForTest(const std::string& serial, |
+ const base::Callback<void(bool)>& callback); |
+ |
private: |
friend struct content::BrowserThread::DeleteOnThread< |
content::BrowserThread::UI>; |
@@ -276,7 +304,9 @@ class DevToolsAndroidBridge |
void CreatedDeviceManager(scoped_refptr<AndroidDeviceManager> device_manager); |
void RequestDeviceList(); |
- void ReceivedDeviceList(RemoteDevices* devices); |
+ void ReceivedDeviceList(scoped_ptr<RemoteDevices> devices, |
+ scoped_ptr<DeviceHandleMap> used_device_handles, |
+ scoped_ptr<DeviceHandleMap> all_device_handles); |
void RequestDeviceCount(); |
void ReceivedDeviceCount(int count); |
@@ -289,6 +319,7 @@ class DevToolsAndroidBridge |
typedef std::vector<DeviceListListener*> DeviceListListeners; |
DeviceListListeners device_list_listeners_; |
+ DeviceHandleMap device_handles_; |
typedef std::vector<DeviceCountListener*> DeviceCountListeners; |
DeviceCountListeners device_count_listeners_; |