OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_ADB_ANDROID_USB_DEVICE_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_ADB_ANDROID_USB_DEVICE_H_ |
6 #define CHROME_BROWSER_DEVTOOLS_ADB_ANDROID_USB_DEVICE_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_ADB_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 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "chrome/browser/usb/usb_device.h" | 12 #include "chrome/browser/usb/usb_device.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class MessageLoop; | 15 class MessageLoop; |
16 } | 16 } |
17 | 17 |
| 18 namespace crypto { |
| 19 class RSAPrivateKey; |
| 20 } |
| 21 |
18 namespace net { | 22 namespace net { |
19 class StreamSocket; | 23 class StreamSocket; |
20 } | 24 } |
21 | 25 |
22 class AndroidUsbSocket; | 26 class AndroidUsbSocket; |
23 class Profile; | 27 class Profile; |
24 | 28 |
25 class AdbMessage : public base::RefCounted<AdbMessage> { | 29 class AdbMessage : public base::RefCounted<AdbMessage> { |
26 public: | 30 public: |
27 enum Command { | 31 enum Command { |
(...skipping 21 matching lines...) Expand all Loading... |
49 uint32 arg0; | 53 uint32 arg0; |
50 uint32 arg1; | 54 uint32 arg1; |
51 std::string body; | 55 std::string body; |
52 private: | 56 private: |
53 friend class base::RefCounted<AdbMessage>; | 57 friend class base::RefCounted<AdbMessage>; |
54 ~AdbMessage(); | 58 ~AdbMessage(); |
55 | 59 |
56 DISALLOW_COPY_AND_ASSIGN(AdbMessage); | 60 DISALLOW_COPY_AND_ASSIGN(AdbMessage); |
57 }; | 61 }; |
58 | 62 |
59 typedef base::Callback<void(int, AdbMessage*)> AdbCallback; | 63 class AndroidUsbDevice; |
| 64 typedef std::vector<scoped_refptr<AndroidUsbDevice> > AndroidUsbDevices; |
60 | 65 |
61 class AndroidUsbDevice : public base::RefCountedThreadSafe<AndroidUsbDevice> { | 66 class AndroidUsbDevice : public base::RefCountedThreadSafe<AndroidUsbDevice> { |
62 public: | 67 public: |
63 typedef std::vector<scoped_refptr<AndroidUsbDevice> > Devices; | 68 static void Enumerate(Profile* profile, |
| 69 crypto::RSAPrivateKey* rsa_key, |
| 70 AndroidUsbDevices* devices); |
64 | 71 |
65 static void Enumerate(Profile* profile, Devices* devices); | 72 AndroidUsbDevice(crypto::RSAPrivateKey* rsa_key, |
66 | |
67 AndroidUsbDevice(Profile* profile, | |
68 scoped_refptr<UsbDevice> device, | 73 scoped_refptr<UsbDevice> device, |
69 const std::string& serial, | 74 const std::string& serial, |
70 int inbound_address, | 75 int inbound_address, |
71 int outbound_address, | 76 int outbound_address, |
72 int zero_mask); | 77 int zero_mask); |
73 | 78 |
74 net::StreamSocket* CreateSocket(const std::string& command); | 79 net::StreamSocket* CreateSocket(const std::string& command); |
75 | 80 |
76 void Send(uint32 command, | 81 void Send(uint32 command, |
77 uint32 arg0, | 82 uint32 arg0, |
(...skipping 30 matching lines...) Expand all Loading... |
108 void HandleIncoming(scoped_refptr<AdbMessage> message); | 113 void HandleIncoming(scoped_refptr<AdbMessage> message); |
109 | 114 |
110 void TransferError(UsbTransferStatus status); | 115 void TransferError(UsbTransferStatus status); |
111 | 116 |
112 void Terminate(); | 117 void Terminate(); |
113 | 118 |
114 void SocketDeleted(uint32 socket_id); | 119 void SocketDeleted(uint32 socket_id); |
115 | 120 |
116 base::MessageLoop* message_loop_; | 121 base::MessageLoop* message_loop_; |
117 | 122 |
118 Profile* profile_; | 123 scoped_ptr<crypto::RSAPrivateKey> rsa_key_; |
119 | 124 |
120 // Device info | 125 // Device info |
121 scoped_refptr<UsbDevice> usb_device_; | 126 scoped_refptr<UsbDevice> usb_device_; |
122 std::string serial_; | 127 std::string serial_; |
123 int inbound_address_; | 128 int inbound_address_; |
124 int outbound_address_; | 129 int outbound_address_; |
125 int zero_mask_; | 130 int zero_mask_; |
126 | 131 |
127 bool is_connected_; | 132 bool is_connected_; |
128 bool signature_sent_; | 133 bool signature_sent_; |
129 | 134 |
130 // Created sockets info | 135 // Created sockets info |
131 uint32 last_socket_id_; | 136 uint32 last_socket_id_; |
| 137 bool terminated_; |
132 typedef std::map<uint32, AndroidUsbSocket*> AndroidUsbSockets; | 138 typedef std::map<uint32, AndroidUsbSocket*> AndroidUsbSockets; |
133 AndroidUsbSockets sockets_; | 139 AndroidUsbSockets sockets_; |
134 | 140 |
135 // Outgoing bulk queue | 141 // Outgoing bulk queue |
136 typedef std::pair<scoped_refptr<net::IOBuffer>, size_t> BulkMessage; | 142 typedef std::pair<scoped_refptr<net::IOBuffer>, size_t> BulkMessage; |
137 std::queue<BulkMessage> outgoing_queue_; | 143 std::queue<BulkMessage> outgoing_queue_; |
138 | 144 |
139 // Outgoing messages pending connect | 145 // Outgoing messages pending connect |
140 typedef std::vector<scoped_refptr<AdbMessage> > PendingMessages; | 146 typedef std::vector<scoped_refptr<AdbMessage> > PendingMessages; |
141 PendingMessages pending_messages_; | 147 PendingMessages pending_messages_; |
142 | 148 |
143 DISALLOW_COPY_AND_ASSIGN(AndroidUsbDevice); | 149 DISALLOW_COPY_AND_ASSIGN(AndroidUsbDevice); |
144 }; | 150 }; |
145 | 151 |
146 #endif // CHROME_BROWSER_DEVTOOLS_ADB_ANDROID_USB_DEVICE_H_ | 152 #endif // CHROME_BROWSER_DEVTOOLS_ADB_ANDROID_USB_DEVICE_H_ |
OLD | NEW |