Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: chrome/browser/devtools/device/usb/android_usb_device.h

Issue 1542413002: Switch to standard integer types in chrome/browser/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h>
9 #include <stdint.h>
10
8 #include <map> 11 #include <map>
9 #include <queue> 12 #include <queue>
10 #include <vector> 13 #include <vector>
11 14
15 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
14 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
15 #include "device/usb/usb_device_handle.h" 19 #include "device/usb/usb_device_handle.h"
16 20
17 namespace base { 21 namespace base {
18 class SingleThreadTaskRunner; 22 class SingleThreadTaskRunner;
19 } 23 }
20 24
21 namespace crypto { 25 namespace crypto {
(...skipping 17 matching lines...) Expand all
39 kCommandWRTE = 0x45545257, 43 kCommandWRTE = 0x45545257,
40 kCommandAUTH = 0x48545541 44 kCommandAUTH = 0x48545541
41 }; 45 };
42 46
43 enum Auth { 47 enum Auth {
44 kAuthToken = 1, 48 kAuthToken = 1,
45 kAuthSignature = 2, 49 kAuthSignature = 2,
46 kAuthRSAPublicKey = 3 50 kAuthRSAPublicKey = 3
47 }; 51 };
48 52
49 AdbMessage(uint32 command, 53 AdbMessage(uint32_t command,
50 uint32 arg0, 54 uint32_t arg0,
51 uint32 arg1, 55 uint32_t arg1,
52 const std::string& body); 56 const std::string& body);
53 ~AdbMessage(); 57 ~AdbMessage();
54 58
55 uint32 command; 59 uint32_t command;
56 uint32 arg0; 60 uint32_t arg0;
57 uint32 arg1; 61 uint32_t arg1;
58 std::string body; 62 std::string body;
59 63
60 private: 64 private:
61 DISALLOW_COPY_AND_ASSIGN(AdbMessage); 65 DISALLOW_COPY_AND_ASSIGN(AdbMessage);
62 }; 66 };
63 67
64 class AndroidUsbDevice; 68 class AndroidUsbDevice;
65 typedef std::vector<scoped_refptr<AndroidUsbDevice> > AndroidUsbDevices; 69 typedef std::vector<scoped_refptr<AndroidUsbDevice> > AndroidUsbDevices;
66 typedef base::Callback<void(const AndroidUsbDevices&)> 70 typedef base::Callback<void(const AndroidUsbDevices&)>
67 AndroidUsbDevicesCallback; 71 AndroidUsbDevicesCallback;
68 72
69 class AndroidUsbDevice : public base::RefCountedThreadSafe<AndroidUsbDevice> { 73 class AndroidUsbDevice : public base::RefCountedThreadSafe<AndroidUsbDevice> {
70 public: 74 public:
71 static void CountDevices(const base::Callback<void(int)>& callback); 75 static void CountDevices(const base::Callback<void(int)>& callback);
72 static void Enumerate(crypto::RSAPrivateKey* rsa_key, 76 static void Enumerate(crypto::RSAPrivateKey* rsa_key,
73 const AndroidUsbDevicesCallback& callback); 77 const AndroidUsbDevicesCallback& callback);
74 78
75 AndroidUsbDevice(crypto::RSAPrivateKey* rsa_key, 79 AndroidUsbDevice(crypto::RSAPrivateKey* rsa_key,
76 scoped_refptr<device::UsbDeviceHandle> device, 80 scoped_refptr<device::UsbDeviceHandle> device,
77 const std::string& serial, 81 const std::string& serial,
78 int inbound_address, 82 int inbound_address,
79 int outbound_address, 83 int outbound_address,
80 int zero_mask, 84 int zero_mask,
81 int interface_id); 85 int interface_id);
82 86
83 void InitOnCallerThread(); 87 void InitOnCallerThread();
84 88
85 net::StreamSocket* CreateSocket(const std::string& command); 89 net::StreamSocket* CreateSocket(const std::string& command);
86 90
87 void Send(uint32 command, 91 void Send(uint32_t command,
88 uint32 arg0, 92 uint32_t arg0,
89 uint32 arg1, 93 uint32_t arg1,
90 const std::string& body); 94 const std::string& body);
91 95
92 scoped_refptr<device::UsbDeviceHandle> usb_device() { return usb_handle_; } 96 scoped_refptr<device::UsbDeviceHandle> usb_device() { return usb_handle_; }
93 97
94 std::string serial() { return serial_; } 98 std::string serial() { return serial_; }
95 99
96 bool is_connected() { return is_connected_; } 100 bool is_connected() { return is_connected_; }
97 101
98 private: 102 private:
99 friend class base::RefCountedThreadSafe<AndroidUsbDevice>; 103 friend class base::RefCountedThreadSafe<AndroidUsbDevice>;
100 virtual ~AndroidUsbDevice(); 104 virtual ~AndroidUsbDevice();
101 105
102 void Queue(scoped_ptr<AdbMessage> message); 106 void Queue(scoped_ptr<AdbMessage> message);
103 void ProcessOutgoing(); 107 void ProcessOutgoing();
104 void OutgoingMessageSent(device::UsbTransferStatus status, 108 void OutgoingMessageSent(device::UsbTransferStatus status,
105 scoped_refptr<net::IOBuffer> buffer, 109 scoped_refptr<net::IOBuffer> buffer,
106 size_t result); 110 size_t result);
107 111
108 void ReadHeader(); 112 void ReadHeader();
109 void ParseHeader(device::UsbTransferStatus status, 113 void ParseHeader(device::UsbTransferStatus status,
110 scoped_refptr<net::IOBuffer> buffer, 114 scoped_refptr<net::IOBuffer> buffer,
111 size_t result); 115 size_t result);
112 116
113 void ReadBody(scoped_ptr<AdbMessage> message, 117 void ReadBody(scoped_ptr<AdbMessage> message,
114 uint32 data_length, 118 uint32_t data_length,
115 uint32 data_check); 119 uint32_t data_check);
116 void ParseBody(scoped_ptr<AdbMessage> message, 120 void ParseBody(scoped_ptr<AdbMessage> message,
117 uint32 data_length, 121 uint32_t data_length,
118 uint32 data_check, 122 uint32_t data_check,
119 device::UsbTransferStatus status, 123 device::UsbTransferStatus status,
120 scoped_refptr<net::IOBuffer> buffer, 124 scoped_refptr<net::IOBuffer> buffer,
121 size_t result); 125 size_t result);
122 126
123 void HandleIncoming(scoped_ptr<AdbMessage> message); 127 void HandleIncoming(scoped_ptr<AdbMessage> message);
124 128
125 void TransferError(device::UsbTransferStatus status); 129 void TransferError(device::UsbTransferStatus status);
126 130
127 void TerminateIfReleased(scoped_refptr<device::UsbDeviceHandle> usb_handle); 131 void TerminateIfReleased(scoped_refptr<device::UsbDeviceHandle> usb_handle);
128 void Terminate(); 132 void Terminate();
129 133
130 void SocketDeleted(uint32 socket_id); 134 void SocketDeleted(uint32_t socket_id);
131 135
132 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 136 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
133 137
134 scoped_ptr<crypto::RSAPrivateKey> rsa_key_; 138 scoped_ptr<crypto::RSAPrivateKey> rsa_key_;
135 139
136 // Device info 140 // Device info
137 scoped_refptr<device::UsbDeviceHandle> usb_handle_; 141 scoped_refptr<device::UsbDeviceHandle> usb_handle_;
138 std::string serial_; 142 std::string serial_;
139 int inbound_address_; 143 int inbound_address_;
140 int outbound_address_; 144 int outbound_address_;
141 int zero_mask_; 145 int zero_mask_;
142 int interface_id_; 146 int interface_id_;
143 147
144 bool is_connected_; 148 bool is_connected_;
145 bool signature_sent_; 149 bool signature_sent_;
146 150
147 // Created sockets info 151 // Created sockets info
148 uint32 last_socket_id_; 152 uint32_t last_socket_id_;
149 typedef std::map<uint32, AndroidUsbSocket*> AndroidUsbSockets; 153 typedef std::map<uint32_t, AndroidUsbSocket*> AndroidUsbSockets;
150 AndroidUsbSockets sockets_; 154 AndroidUsbSockets sockets_;
151 155
152 // Outgoing bulk queue 156 // Outgoing bulk queue
153 typedef scoped_refptr<net::IOBufferWithSize> BulkMessage; 157 typedef scoped_refptr<net::IOBufferWithSize> BulkMessage;
154 std::queue<BulkMessage> outgoing_queue_; 158 std::queue<BulkMessage> outgoing_queue_;
155 159
156 // Outgoing messages pending connect 160 // Outgoing messages pending connect
157 typedef ScopedVector<AdbMessage> PendingMessages; 161 typedef ScopedVector<AdbMessage> PendingMessages;
158 PendingMessages pending_messages_; 162 PendingMessages pending_messages_;
159 163
160 base::WeakPtrFactory<AndroidUsbDevice> weak_factory_; 164 base::WeakPtrFactory<AndroidUsbDevice> weak_factory_;
161 165
162 DISALLOW_COPY_AND_ASSIGN(AndroidUsbDevice); 166 DISALLOW_COPY_AND_ASSIGN(AndroidUsbDevice);
163 }; 167 };
164 168
165 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_DEVICE_H_ 169 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698