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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 class WebSocketImpl; | 76 class WebSocketImpl; |
77 | 77 |
78 AndroidWebSocket( | 78 AndroidWebSocket( |
79 scoped_refptr<Device> device, | 79 scoped_refptr<Device> device, |
80 const std::string& socket_name, | 80 const std::string& socket_name, |
81 const std::string& url, | 81 const std::string& url, |
82 AndroidWebSocket::Delegate* delegate); | 82 AndroidWebSocket::Delegate* delegate); |
83 void Connected(int result, scoped_ptr<net::StreamSocket> socket); | 83 void Connected(int result, scoped_ptr<net::StreamSocket> socket); |
84 void OnFrameRead(const std::string& message); | 84 void OnFrameRead(const std::string& message); |
85 void OnSocketClosed(); | 85 void OnSocketClosed(); |
| 86 void Terminate(); |
86 | 87 |
87 scoped_refptr<Device> device_; | 88 Device* device_; |
88 WebSocketImpl* socket_impl_; | 89 WebSocketImpl* socket_impl_; |
89 Delegate* delegate_; | 90 Delegate* delegate_; |
90 base::WeakPtrFactory<AndroidWebSocket> weak_factory_; | 91 base::WeakPtrFactory<AndroidWebSocket> weak_factory_; |
91 DISALLOW_COPY_AND_ASSIGN(AndroidWebSocket); | 92 DISALLOW_COPY_AND_ASSIGN(AndroidWebSocket); |
92 }; | 93 }; |
93 | 94 |
94 class DeviceProvider; | 95 class DeviceProvider; |
95 | 96 |
96 class Device : public base::RefCountedThreadSafe<Device>, | 97 class Device : public base::RefCountedThreadSafe<Device>, |
97 public base::NonThreadSafe { | 98 public base::NonThreadSafe { |
(...skipping 21 matching lines...) Expand all Loading... |
119 friend class base::RefCountedThreadSafe<Device>; | 120 friend class base::RefCountedThreadSafe<Device>; |
120 friend class AndroidDeviceManager; | 121 friend class AndroidDeviceManager; |
121 friend class AndroidWebSocket; | 122 friend class AndroidWebSocket; |
122 | 123 |
123 Device(scoped_refptr<base::MessageLoopProxy> device_message_loop, | 124 Device(scoped_refptr<base::MessageLoopProxy> device_message_loop, |
124 scoped_refptr<DeviceProvider> provider, | 125 scoped_refptr<DeviceProvider> provider, |
125 const std::string& serial); | 126 const std::string& serial); |
126 | 127 |
127 virtual ~Device(); | 128 virtual ~Device(); |
128 | 129 |
129 scoped_refptr<base::MessageLoopProxy> device_message_loop_; | 130 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
130 scoped_refptr<DeviceProvider> provider_; | 131 scoped_refptr<DeviceProvider> provider_; |
131 std::string serial_; | 132 std::string serial_; |
| 133 std::set<AndroidWebSocket*> sockets_; |
132 base::WeakPtrFactory<Device> weak_factory_; | 134 base::WeakPtrFactory<Device> weak_factory_; |
133 | 135 |
134 DISALLOW_COPY_AND_ASSIGN(Device); | 136 DISALLOW_COPY_AND_ASSIGN(Device); |
135 }; | 137 }; |
136 | 138 |
137 typedef std::vector<scoped_refptr<Device> > Devices; | 139 typedef std::vector<scoped_refptr<Device> > Devices; |
138 typedef base::Callback<void(const Devices&)> DevicesCallback; | 140 typedef base::Callback<void(const Devices&)> DevicesCallback; |
139 | 141 |
140 class DeviceProvider : public base::RefCountedThreadSafe<DeviceProvider> { | 142 class DeviceProvider : public base::RefCountedThreadSafe<DeviceProvider> { |
141 public: | 143 public: |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 DeviceDescriptors* descriptors); | 217 DeviceDescriptors* descriptors); |
216 | 218 |
217 typedef std::map<std::string, base::WeakPtr<Device> > DeviceWeakMap; | 219 typedef std::map<std::string, base::WeakPtr<Device> > DeviceWeakMap; |
218 | 220 |
219 scoped_refptr<HandlerThread> handler_thread_; | 221 scoped_refptr<HandlerThread> handler_thread_; |
220 DeviceProviders providers_; | 222 DeviceProviders providers_; |
221 DeviceWeakMap devices_; | 223 DeviceWeakMap devices_; |
222 }; | 224 }; |
223 | 225 |
224 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ | 226 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ |
OLD | NEW |