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 #include "chrome/browser/devtools/device/usb/usb_device_provider.h" | 5 #include "chrome/browser/devtools/device/usb/usb_device_provider.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/devtools/device/usb/android_rsa.h" | 10 #include "chrome/browser/devtools/device/usb/android_rsa.h" |
9 #include "chrome/browser/devtools/device/usb/android_usb_device.h" | 11 #include "chrome/browser/devtools/device/usb/android_usb_device.h" |
10 #include "crypto/rsa_private_key.h" | 12 #include "crypto/rsa_private_key.h" |
11 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
12 #include "net/socket/stream_socket.h" | 14 #include "net/socket/stream_socket.h" |
13 | 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 const char kLocalAbstractCommand[] = "localabstract:%s"; | 18 const char kLocalAbstractCommand[] = "localabstract:%s"; |
17 | 19 |
18 const int kBufferSize = 16 * 1024; | 20 const int kBufferSize = 16 * 1024; |
19 | 21 |
20 void OnOpenSocket(const UsbDeviceProvider::SocketCallback& callback, | 22 void OnOpenSocket(const UsbDeviceProvider::SocketCallback& callback, |
21 net::StreamSocket* socket_raw, | 23 net::StreamSocket* socket_raw, |
22 int result) { | 24 int result) { |
23 scoped_ptr<net::StreamSocket> socket(socket_raw); | 25 scoped_ptr<net::StreamSocket> socket(socket_raw); |
24 if (result != net::OK) | 26 if (result != net::OK) |
25 socket.reset(); | 27 socket.reset(); |
26 callback.Run(result, socket.Pass()); | 28 callback.Run(result, std::move(socket)); |
27 } | 29 } |
28 | 30 |
29 void OnRead(net::StreamSocket* socket, | 31 void OnRead(net::StreamSocket* socket, |
30 scoped_refptr<net::IOBuffer> buffer, | 32 scoped_refptr<net::IOBuffer> buffer, |
31 const std::string& data, | 33 const std::string& data, |
32 const UsbDeviceProvider::CommandCallback& callback, | 34 const UsbDeviceProvider::CommandCallback& callback, |
33 int result) { | 35 int result) { |
34 if (result <= 0) { | 36 if (result <= 0) { |
35 callback.Run(result, result == 0 ? data : std::string()); | 37 callback.Run(result, result == 0 ? data : std::string()); |
36 delete socket; | 38 delete socket; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 device_map_.clear(); | 143 device_map_.clear(); |
142 for (AndroidUsbDevices::const_iterator it = devices.begin(); | 144 for (AndroidUsbDevices::const_iterator it = devices.begin(); |
143 it != devices.end(); ++it) { | 145 it != devices.end(); ++it) { |
144 result.push_back((*it)->serial()); | 146 result.push_back((*it)->serial()); |
145 device_map_[(*it)->serial()] = *it; | 147 device_map_[(*it)->serial()] = *it; |
146 (*it)->InitOnCallerThread(); | 148 (*it)->InitOnCallerThread(); |
147 } | 149 } |
148 callback.Run(result); | 150 callback.Run(result); |
149 } | 151 } |
150 | 152 |
OLD | NEW |