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_USB_ANDROID_USB_DEVICE_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_DEVICE_H_ |
6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_DEVICE_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_DEVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "device/usb/usb_device_handle.h" | 15 #include "device/usb/usb_device_handle.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class MessageLoop; | 18 class SingleThreadTaskRunner; |
19 } | 19 } |
20 | 20 |
21 namespace crypto { | 21 namespace crypto { |
22 class RSAPrivateKey; | 22 class RSAPrivateKey; |
23 } | 23 } |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 class StreamSocket; | 26 class StreamSocket; |
27 } | 27 } |
28 | 28 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 DISALLOW_COPY_AND_ASSIGN(AdbMessage); | 61 DISALLOW_COPY_AND_ASSIGN(AdbMessage); |
62 }; | 62 }; |
63 | 63 |
64 class AndroidUsbDevice; | 64 class AndroidUsbDevice; |
65 typedef std::vector<scoped_refptr<AndroidUsbDevice> > AndroidUsbDevices; | 65 typedef std::vector<scoped_refptr<AndroidUsbDevice> > AndroidUsbDevices; |
66 typedef base::Callback<void(const AndroidUsbDevices&)> | 66 typedef base::Callback<void(const AndroidUsbDevices&)> |
67 AndroidUsbDevicesCallback; | 67 AndroidUsbDevicesCallback; |
68 | 68 |
69 class AndroidUsbDevice : public base::RefCountedThreadSafe<AndroidUsbDevice> { | 69 class AndroidUsbDevice : public base::RefCountedThreadSafe<AndroidUsbDevice> { |
70 public: | 70 public: |
| 71 static void CountDevices(const base::Callback<void(int)>& callback); |
71 static void Enumerate(crypto::RSAPrivateKey* rsa_key, | 72 static void Enumerate(crypto::RSAPrivateKey* rsa_key, |
72 const AndroidUsbDevicesCallback& callback); | 73 const AndroidUsbDevicesCallback& callback); |
73 | 74 |
74 static void CountDevices(const base::Callback<void(int)>& callback); | |
75 | |
76 AndroidUsbDevice(crypto::RSAPrivateKey* rsa_key, | 75 AndroidUsbDevice(crypto::RSAPrivateKey* rsa_key, |
77 scoped_refptr<device::UsbDeviceHandle> device, | 76 scoped_refptr<device::UsbDeviceHandle> device, |
78 const std::string& serial, | 77 const std::string& serial, |
79 int inbound_address, | 78 int inbound_address, |
80 int outbound_address, | 79 int outbound_address, |
81 int zero_mask, | 80 int zero_mask, |
82 int interface_id); | 81 int interface_id); |
83 | 82 |
84 void InitOnCallerThread(); | 83 void InitOnCallerThread(); |
85 | 84 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 122 |
124 void HandleIncoming(scoped_ptr<AdbMessage> message); | 123 void HandleIncoming(scoped_ptr<AdbMessage> message); |
125 | 124 |
126 void TransferError(device::UsbTransferStatus status); | 125 void TransferError(device::UsbTransferStatus status); |
127 | 126 |
128 void TerminateIfReleased(scoped_refptr<device::UsbDeviceHandle> usb_handle); | 127 void TerminateIfReleased(scoped_refptr<device::UsbDeviceHandle> usb_handle); |
129 void Terminate(); | 128 void Terminate(); |
130 | 129 |
131 void SocketDeleted(uint32 socket_id); | 130 void SocketDeleted(uint32 socket_id); |
132 | 131 |
133 base::MessageLoop* message_loop_; | 132 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
134 | 133 |
135 scoped_ptr<crypto::RSAPrivateKey> rsa_key_; | 134 scoped_ptr<crypto::RSAPrivateKey> rsa_key_; |
136 | 135 |
137 // Device info | 136 // Device info |
138 scoped_refptr<device::UsbDeviceHandle> usb_handle_; | 137 scoped_refptr<device::UsbDeviceHandle> usb_handle_; |
139 std::string serial_; | 138 std::string serial_; |
140 int inbound_address_; | 139 int inbound_address_; |
141 int outbound_address_; | 140 int outbound_address_; |
142 int zero_mask_; | 141 int zero_mask_; |
143 int interface_id_; | 142 int interface_id_; |
(...skipping 13 matching lines...) Expand all Loading... |
157 // Outgoing messages pending connect | 156 // Outgoing messages pending connect |
158 typedef ScopedVector<AdbMessage> PendingMessages; | 157 typedef ScopedVector<AdbMessage> PendingMessages; |
159 PendingMessages pending_messages_; | 158 PendingMessages pending_messages_; |
160 | 159 |
161 base::WeakPtrFactory<AndroidUsbDevice> weak_factory_; | 160 base::WeakPtrFactory<AndroidUsbDevice> weak_factory_; |
162 | 161 |
163 DISALLOW_COPY_AND_ASSIGN(AndroidUsbDevice); | 162 DISALLOW_COPY_AND_ASSIGN(AndroidUsbDevice); |
164 }; | 163 }; |
165 | 164 |
166 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_DEVICE_H_ | 165 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_DEVICE_H_ |
OLD | NEW |