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

Side by Side Diff: chrome/browser/devtools/adb/android_usb_device.h

Issue 230773003: DevTools: do not retain android_usb_devices in their manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments addressed. Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/devtools/adb/android_usb_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/memory/weak_ptr.h"
12 #include "chrome/browser/usb/usb_device_handle.h" 13 #include "chrome/browser/usb/usb_device_handle.h"
13 14
14 namespace base { 15 namespace base {
15 class MessageLoop; 16 class MessageLoop;
16 } 17 }
17 18
18 namespace crypto { 19 namespace crypto {
19 class RSAPrivateKey; 20 class RSAPrivateKey;
20 } 21 }
21 22
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 static void Enumerate(crypto::RSAPrivateKey* rsa_key, 70 static void Enumerate(crypto::RSAPrivateKey* rsa_key,
70 const AndroidUsbDevicesCallback& callback); 71 const AndroidUsbDevicesCallback& callback);
71 72
72 static void CountDevices(const base::Callback<void(int)>& callback); 73 static void CountDevices(const base::Callback<void(int)>& callback);
73 74
74 AndroidUsbDevice(crypto::RSAPrivateKey* rsa_key, 75 AndroidUsbDevice(crypto::RSAPrivateKey* rsa_key,
75 scoped_refptr<UsbDeviceHandle> device, 76 scoped_refptr<UsbDeviceHandle> device,
76 const std::string& serial, 77 const std::string& serial,
77 int inbound_address, 78 int inbound_address,
78 int outbound_address, 79 int outbound_address,
79 int zero_mask); 80 int zero_mask,
81 int interface_id);
80 82
81 void InitOnCallerThread(); 83 void InitOnCallerThread();
82 84
83 net::StreamSocket* CreateSocket(const std::string& command); 85 net::StreamSocket* CreateSocket(const std::string& command);
84 86
85 void Send(uint32 command, 87 void Send(uint32 command,
86 uint32 arg0, 88 uint32 arg0,
87 uint32 arg1, 89 uint32 arg1,
88 const std::string& body); 90 const std::string& body);
89 91
90 scoped_refptr<UsbDeviceHandle> usb_device() { return usb_device_; } 92 scoped_refptr<UsbDeviceHandle> usb_device() { return usb_handle_; }
91 93
92 std::string serial() { return serial_; } 94 std::string serial() { return serial_; }
93 95
94 bool terminated() { return terminated_; }
95
96 bool is_connected() { return is_connected_; } 96 bool is_connected() { return is_connected_; }
97 97
98 private: 98 private:
99 friend class base::RefCountedThreadSafe<AndroidUsbDevice>; 99 friend class base::RefCountedThreadSafe<AndroidUsbDevice>;
100 virtual ~AndroidUsbDevice(); 100 virtual ~AndroidUsbDevice();
101 101
102 void Queue(scoped_refptr<AdbMessage> message); 102 void Queue(scoped_refptr<AdbMessage> message);
103 void ProcessOutgoing(); 103 void ProcessOutgoing();
104 void OutgoingMessageSent(UsbTransferStatus status, 104 void OutgoingMessageSent(UsbTransferStatus status,
105 scoped_refptr<net::IOBuffer> buffer, 105 scoped_refptr<net::IOBuffer> buffer,
106 size_t result); 106 size_t result);
107 107
108 void ReadHeader(bool initial); 108 void ReadHeader();
109 void ParseHeader(UsbTransferStatus status, 109 void ParseHeader(UsbTransferStatus status,
110 scoped_refptr<net::IOBuffer> buffer, 110 scoped_refptr<net::IOBuffer> buffer,
111 size_t result); 111 size_t result);
112 112
113 void ReadBody(scoped_refptr<AdbMessage> message, 113 void ReadBody(scoped_refptr<AdbMessage> message,
114 uint32 data_length, 114 uint32 data_length,
115 uint32 data_check); 115 uint32 data_check);
116 void ParseBody(scoped_refptr<AdbMessage> message, 116 void ParseBody(scoped_refptr<AdbMessage> message,
117 uint32 data_length, 117 uint32 data_length,
118 uint32 data_check, 118 uint32 data_check,
119 UsbTransferStatus status, 119 UsbTransferStatus status,
120 scoped_refptr<net::IOBuffer> buffer, 120 scoped_refptr<net::IOBuffer> buffer,
121 size_t result); 121 size_t result);
122 122
123 void HandleIncoming(scoped_refptr<AdbMessage> message); 123 void HandleIncoming(scoped_refptr<AdbMessage> message);
124 124
125 void TransferError(UsbTransferStatus status); 125 void TransferError(UsbTransferStatus status);
126 126
127 void TerminateIfReleased(scoped_refptr<UsbDeviceHandle> usb_handle);
127 void Terminate(); 128 void Terminate();
128 129
129 void SocketDeleted(uint32 socket_id); 130 void SocketDeleted(uint32 socket_id);
130 131
131 base::MessageLoop* message_loop_; 132 base::MessageLoop* message_loop_;
132 133
133 scoped_ptr<crypto::RSAPrivateKey> rsa_key_; 134 scoped_ptr<crypto::RSAPrivateKey> rsa_key_;
134 135
135 // Device info 136 // Device info
136 scoped_refptr<UsbDeviceHandle> usb_device_; 137 scoped_refptr<UsbDeviceHandle> usb_handle_;
137 std::string serial_; 138 std::string serial_;
138 int inbound_address_; 139 int inbound_address_;
139 int outbound_address_; 140 int outbound_address_;
140 int zero_mask_; 141 int zero_mask_;
142 int interface_id_;
141 143
142 bool is_connected_; 144 bool is_connected_;
143 bool signature_sent_; 145 bool signature_sent_;
144 146
145 // Created sockets info 147 // Created sockets info
146 uint32 last_socket_id_; 148 uint32 last_socket_id_;
147 bool terminated_;
148 typedef std::map<uint32, AndroidUsbSocket*> AndroidUsbSockets; 149 typedef std::map<uint32, AndroidUsbSocket*> AndroidUsbSockets;
149 AndroidUsbSockets sockets_; 150 AndroidUsbSockets sockets_;
150 151
151 // Outgoing bulk queue 152 // Outgoing bulk queue
152 typedef std::pair<scoped_refptr<net::IOBuffer>, size_t> BulkMessage; 153 typedef std::pair<scoped_refptr<net::IOBuffer>, size_t> BulkMessage;
153 std::queue<BulkMessage> outgoing_queue_; 154 std::queue<BulkMessage> outgoing_queue_;
154 155
155 // Outgoing messages pending connect 156 // Outgoing messages pending connect
156 typedef std::vector<scoped_refptr<AdbMessage> > PendingMessages; 157 typedef std::vector<scoped_refptr<AdbMessage> > PendingMessages;
157 PendingMessages pending_messages_; 158 PendingMessages pending_messages_;
158 159
160 base::WeakPtrFactory<AndroidUsbDevice> weak_factory_;
161
159 DISALLOW_COPY_AND_ASSIGN(AndroidUsbDevice); 162 DISALLOW_COPY_AND_ASSIGN(AndroidUsbDevice);
160 }; 163 };
161 164
162 #endif // CHROME_BROWSER_DEVTOOLS_ADB_ANDROID_USB_DEVICE_H_ 165 #endif // CHROME_BROWSER_DEVTOOLS_ADB_ANDROID_USB_DEVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/devtools/adb/android_usb_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698