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" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/single_thread_task_runner.h" |
12 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
15 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
16 | 17 |
17 namespace net { | 18 namespace net { |
18 class StreamSocket; | 19 class StreamSocket; |
19 } | 20 } |
20 | 21 |
21 class AndroidDeviceManager : public base::NonThreadSafe { | 22 class AndroidDeviceManager : public base::NonThreadSafe { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 const std::string& url, | 126 const std::string& url, |
126 AndroidWebSocket::Delegate* delegate); | 127 AndroidWebSocket::Delegate* delegate); |
127 | 128 |
128 std::string serial() { return serial_; } | 129 std::string serial() { return serial_; } |
129 | 130 |
130 private: | 131 private: |
131 friend class base::RefCountedThreadSafe<Device>; | 132 friend class base::RefCountedThreadSafe<Device>; |
132 friend class AndroidDeviceManager; | 133 friend class AndroidDeviceManager; |
133 friend class AndroidWebSocket; | 134 friend class AndroidWebSocket; |
134 | 135 |
135 Device(scoped_refptr<base::MessageLoopProxy> device_message_loop, | 136 Device(scoped_refptr<base::SingleThreadTaskRunner> device_task_runner, |
136 scoped_refptr<DeviceProvider> provider, | 137 scoped_refptr<DeviceProvider> provider, |
137 const std::string& serial); | 138 const std::string& serial); |
138 | 139 |
139 virtual ~Device(); | 140 virtual ~Device(); |
140 | 141 |
141 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 142 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
142 scoped_refptr<DeviceProvider> provider_; | 143 scoped_refptr<DeviceProvider> provider_; |
143 std::string serial_; | 144 std::string serial_; |
144 std::set<AndroidWebSocket*> sockets_; | 145 std::set<AndroidWebSocket*> sockets_; |
145 base::WeakPtrFactory<Device> weak_factory_; | 146 base::WeakPtrFactory<Device> weak_factory_; |
146 | 147 |
147 DISALLOW_COPY_AND_ASSIGN(Device); | 148 DISALLOW_COPY_AND_ASSIGN(Device); |
148 }; | 149 }; |
149 | 150 |
150 typedef std::vector<scoped_refptr<Device> > Devices; | 151 typedef std::vector<scoped_refptr<Device> > Devices; |
151 typedef base::Callback<void(const Devices&)> DevicesCallback; | 152 typedef base::Callback<void(const Devices&)> DevicesCallback; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 scoped_refptr<DeviceProvider> provider; | 211 scoped_refptr<DeviceProvider> provider; |
211 std::string serial; | 212 std::string serial; |
212 }; | 213 }; |
213 | 214 |
214 typedef std::vector<DeviceDescriptor> DeviceDescriptors; | 215 typedef std::vector<DeviceDescriptor> DeviceDescriptors; |
215 | 216 |
216 private: | 217 private: |
217 class HandlerThread : public base::RefCountedThreadSafe<HandlerThread> { | 218 class HandlerThread : public base::RefCountedThreadSafe<HandlerThread> { |
218 public: | 219 public: |
219 static scoped_refptr<HandlerThread> GetInstance(); | 220 static scoped_refptr<HandlerThread> GetInstance(); |
220 scoped_refptr<base::MessageLoopProxy> message_loop(); | 221 scoped_refptr<base::SingleThreadTaskRunner> message_loop(); |
221 | 222 |
222 private: | 223 private: |
223 friend class base::RefCountedThreadSafe<HandlerThread>; | 224 friend class base::RefCountedThreadSafe<HandlerThread>; |
224 static HandlerThread* instance_; | 225 static HandlerThread* instance_; |
225 static void StopThread(base::Thread* thread); | 226 static void StopThread(base::Thread* thread); |
226 | 227 |
227 HandlerThread(); | 228 HandlerThread(); |
228 virtual ~HandlerThread(); | 229 virtual ~HandlerThread(); |
229 base::Thread* thread_; | 230 base::Thread* thread_; |
230 }; | 231 }; |
231 | 232 |
232 AndroidDeviceManager(); | 233 AndroidDeviceManager(); |
233 | 234 |
234 void UpdateDevices(const DevicesCallback& callback, | 235 void UpdateDevices(const DevicesCallback& callback, |
235 scoped_ptr<DeviceDescriptors> descriptors); | 236 scoped_ptr<DeviceDescriptors> descriptors); |
236 | 237 |
237 typedef std::map<std::string, base::WeakPtr<Device> > DeviceWeakMap; | 238 typedef std::map<std::string, base::WeakPtr<Device> > DeviceWeakMap; |
238 | 239 |
239 scoped_refptr<HandlerThread> handler_thread_; | 240 scoped_refptr<HandlerThread> handler_thread_; |
240 DeviceProviders providers_; | 241 DeviceProviders providers_; |
241 DeviceWeakMap devices_; | 242 DeviceWeakMap devices_; |
242 | 243 |
243 base::WeakPtrFactory<AndroidDeviceManager> weak_factory_; | 244 base::WeakPtrFactory<AndroidDeviceManager> weak_factory_; |
244 }; | 245 }; |
245 | 246 |
246 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ | 247 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ |
OLD | NEW |