| 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_ANDROID_DEVICE_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ |
| 6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 DeviceInfo(); | 46 DeviceInfo(); |
| 47 ~DeviceInfo(); | 47 ~DeviceInfo(); |
| 48 | 48 |
| 49 std::string model; | 49 std::string model; |
| 50 bool connected; | 50 bool connected; |
| 51 gfx::Size screen_size; | 51 gfx::Size screen_size; |
| 52 std::vector<BrowserInfo> browser_info; | 52 std::vector<BrowserInfo> browser_info; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 typedef base::Callback<void(const DeviceInfo&)> DeviceInfoCallback; | 55 typedef base::Callback<void(const DeviceInfo&)> DeviceInfoCallback; |
| 56 class Device; |
| 56 | 57 |
| 57 class AndroidWebSocket { | 58 class AndroidWebSocket { |
| 58 public: | 59 public: |
| 59 class Delegate { | 60 class Delegate { |
| 60 public: | 61 public: |
| 61 virtual void OnSocketOpened() = 0; | 62 virtual void OnSocketOpened() = 0; |
| 62 virtual void OnFrameRead(const std::string& message) = 0; | 63 virtual void OnFrameRead(const std::string& message) = 0; |
| 63 virtual void OnSocketClosed() = 0; | 64 virtual void OnSocketClosed() = 0; |
| 64 | 65 |
| 65 protected: | 66 protected: |
| 66 virtual ~Delegate() {} | 67 virtual ~Delegate() {} |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 virtual ~AndroidWebSocket() {} | 70 ~AndroidWebSocket(); |
| 70 | 71 |
| 71 virtual void SendFrame(const std::string& message) = 0; | 72 void SendFrame(const std::string& message); |
| 73 |
| 74 private: |
| 75 friend class Device; |
| 76 class WebSocketImpl; |
| 77 |
| 78 AndroidWebSocket( |
| 79 scoped_refptr<Device> device, |
| 80 const std::string& socket_name, |
| 81 const std::string& url, |
| 82 AndroidWebSocket::Delegate* delegate); |
| 83 void Connected(int result, scoped_ptr<net::StreamSocket> socket); |
| 84 void OnFrameRead(const std::string& message); |
| 85 void OnSocketClosed(); |
| 86 |
| 87 scoped_refptr<Device> device_; |
| 88 std::string url_; |
| 89 WebSocketImpl* socket_impl_; |
| 90 Delegate* delegate_; |
| 91 base::WeakPtrFactory<AndroidWebSocket> weak_factory_; |
| 92 DISALLOW_COPY_AND_ASSIGN(AndroidWebSocket); |
| 72 }; | 93 }; |
| 73 | 94 |
| 74 class DeviceProvider; | 95 class DeviceProvider; |
| 75 | 96 |
| 76 class Device : public base::RefCountedThreadSafe<Device>, | 97 class Device : public base::RefCountedThreadSafe<Device>, |
| 77 public base::NonThreadSafe { | 98 public base::NonThreadSafe { |
| 78 public: | 99 public: |
| 79 typedef AndroidDeviceManager::DeviceInfoCallback DeviceInfoCallback; | |
| 80 typedef AndroidDeviceManager::CommandCallback CommandCallback; | |
| 81 typedef AndroidDeviceManager::SocketCallback SocketCallback; | |
| 82 | |
| 83 void QueryDeviceInfo(const DeviceInfoCallback& callback); | 100 void QueryDeviceInfo(const DeviceInfoCallback& callback); |
| 84 | 101 |
| 85 void OpenSocket(const std::string& socket_name, | 102 void OpenSocket(const std::string& socket_name, |
| 86 const SocketCallback& callback); | 103 const SocketCallback& callback); |
| 87 | 104 |
| 88 void SendJsonRequest(const std::string& socket_name, | 105 void SendJsonRequest(const std::string& socket_name, |
| 89 const std::string& request, | 106 const std::string& request, |
| 90 const CommandCallback& callback); | 107 const CommandCallback& callback); |
| 91 | 108 |
| 92 void HttpUpgrade(const std::string& socket_name, | 109 void HttpUpgrade(const std::string& socket_name, |
| 93 const std::string& url, | 110 const std::string& url, |
| 94 const SocketCallback& callback); | 111 const SocketCallback& callback); |
| 95 | |
| 96 AndroidWebSocket* CreateWebSocket( | 112 AndroidWebSocket* CreateWebSocket( |
| 97 const std::string& socket_name, | 113 const std::string& socket_name, |
| 98 const std::string& url, | 114 const std::string& url, |
| 99 AndroidWebSocket::Delegate* delegate); | 115 AndroidWebSocket::Delegate* delegate); |
| 100 | 116 |
| 101 std::string serial() { return serial_; } | 117 std::string serial() { return serial_; } |
| 102 | 118 |
| 103 private: | 119 private: |
| 120 friend class base::RefCountedThreadSafe<Device>; |
| 104 friend class AndroidDeviceManager; | 121 friend class AndroidDeviceManager; |
| 122 friend class AndroidWebSocket; |
| 123 |
| 105 Device(scoped_refptr<base::MessageLoopProxy> device_message_loop, | 124 Device(scoped_refptr<base::MessageLoopProxy> device_message_loop, |
| 106 scoped_refptr<DeviceProvider> provider, | 125 scoped_refptr<DeviceProvider> provider, |
| 107 const std::string& serial); | 126 const std::string& serial); |
| 108 | 127 |
| 109 friend class base::RefCountedThreadSafe<Device>; | |
| 110 virtual ~Device(); | 128 virtual ~Device(); |
| 111 | 129 |
| 112 scoped_refptr<base::MessageLoopProxy> device_message_loop_; | 130 scoped_refptr<base::MessageLoopProxy> device_message_loop_; |
| 113 scoped_refptr<DeviceProvider> provider_; | 131 scoped_refptr<DeviceProvider> provider_; |
| 114 std::string serial_; | 132 std::string serial_; |
| 115 base::WeakPtrFactory<Device> weak_factory_; | 133 base::WeakPtrFactory<Device> weak_factory_; |
| 116 | 134 |
| 117 DISALLOW_COPY_AND_ASSIGN(Device); | 135 DISALLOW_COPY_AND_ASSIGN(Device); |
| 118 }; | 136 }; |
| 119 | 137 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 DeviceDescriptors* descriptors); | 216 DeviceDescriptors* descriptors); |
| 199 | 217 |
| 200 typedef std::map<std::string, base::WeakPtr<Device> > DeviceWeakMap; | 218 typedef std::map<std::string, base::WeakPtr<Device> > DeviceWeakMap; |
| 201 | 219 |
| 202 scoped_refptr<HandlerThread> handler_thread_; | 220 scoped_refptr<HandlerThread> handler_thread_; |
| 203 DeviceProviders providers_; | 221 DeviceProviders providers_; |
| 204 DeviceWeakMap devices_; | 222 DeviceWeakMap devices_; |
| 205 }; | 223 }; |
| 206 | 224 |
| 207 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ | 225 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ |
| OLD | NEW |