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/adb/adb_client_socket.h" | 5 #include "chrome/browser/devtools/device/adb/adb_client_socket.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 void AdbClientSocket::Connect(const net::CompletionCallback& callback) { | 177 void AdbClientSocket::Connect(const net::CompletionCallback& callback) { |
178 net::IPAddress ip_address; | 178 net::IPAddress ip_address; |
179 if (!ip_address.AssignFromIPLiteral(host_)) { | 179 if (!ip_address.AssignFromIPLiteral(host_)) { |
180 callback.Run(net::ERR_FAILED); | 180 callback.Run(net::ERR_FAILED); |
181 return; | 181 return; |
182 } | 182 } |
183 | 183 |
184 net::AddressList address_list = | 184 net::AddressList address_list = |
185 net::AddressList::CreateFromIPAddress(ip_address, port_); | 185 net::AddressList::CreateFromIPAddress(ip_address, port_); |
186 socket_.reset(new net::TCPClientSocket(address_list, NULL, | 186 socket_.reset(new net::TCPClientSocket(address_list, NULL, NULL, |
187 net::NetLog::Source())); | 187 net::NetLog::Source())); |
188 int result = socket_->Connect(callback); | 188 int result = socket_->Connect(callback); |
189 if (result != net::ERR_IO_PENDING) | 189 if (result != net::ERR_IO_PENDING) |
190 callback.Run(result); | 190 callback.Run(result); |
191 } | 191 } |
192 | 192 |
193 void AdbClientSocket::SendCommand(const std::string& command, | 193 void AdbClientSocket::SendCommand(const std::string& command, |
194 bool is_void, | 194 bool is_void, |
195 const CommandCallback& callback) { | 195 const CommandCallback& callback) { |
196 scoped_refptr<net::StringIOBuffer> request_buffer = | 196 scoped_refptr<net::StringIOBuffer> request_buffer = |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 base::Unretained(this), | 294 base::Unretained(this), |
295 callback, | 295 callback, |
296 new_response, | 296 new_response, |
297 response_buffer, | 297 response_buffer, |
298 bytes_left)); | 298 bytes_left)); |
299 if (result > 0) | 299 if (result > 0) |
300 OnResponseData(callback, new_response, response_buffer, bytes_left, result); | 300 OnResponseData(callback, new_response, response_buffer, bytes_left, result); |
301 else if (result != net::ERR_IO_PENDING) | 301 else if (result != net::ERR_IO_PENDING) |
302 callback.Run(net::OK, new_response); | 302 callback.Run(net::OK, new_response); |
303 } | 303 } |
OLD | NEW |