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 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
16 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
17 #include "net/socket/tcp_client_socket.h" | 18 #include "net/socket/tcp_client_socket.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 if (!CheckNetResultOrDie(result)) | 67 if (!CheckNetResultOrDie(result)) |
67 return; | 68 return; |
68 SendCommand(socket_name_, true, | 69 SendCommand(socket_name_, true, |
69 base::Bind(&AdbTransportSocket::OnSocketAvailable, | 70 base::Bind(&AdbTransportSocket::OnSocketAvailable, |
70 base::Unretained(this))); | 71 base::Unretained(this))); |
71 } | 72 } |
72 | 73 |
73 void OnSocketAvailable(int result, const std::string& response) { | 74 void OnSocketAvailable(int result, const std::string& response) { |
74 if (!CheckNetResultOrDie(result)) | 75 if (!CheckNetResultOrDie(result)) |
75 return; | 76 return; |
76 callback_.Run(net::OK, socket_.Pass()); | 77 callback_.Run(net::OK, std::move(socket_)); |
77 delete this; | 78 delete this; |
78 } | 79 } |
79 | 80 |
80 bool CheckNetResultOrDie(int result) { | 81 bool CheckNetResultOrDie(int result) { |
81 if (result >= 0) | 82 if (result >= 0) |
82 return true; | 83 return true; |
83 callback_.Run(result, make_scoped_ptr<net::StreamSocket>(NULL)); | 84 callback_.Run(result, make_scoped_ptr<net::StreamSocket>(NULL)); |
84 delete this; | 85 delete this; |
85 return false; | 86 return false; |
86 } | 87 } |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 base::Unretained(this), | 292 base::Unretained(this), |
292 callback, | 293 callback, |
293 new_response, | 294 new_response, |
294 response_buffer, | 295 response_buffer, |
295 bytes_left)); | 296 bytes_left)); |
296 if (result > 0) | 297 if (result > 0) |
297 OnResponseData(callback, new_response, response_buffer, bytes_left, result); | 298 OnResponseData(callback, new_response, response_buffer, bytes_left, result); |
298 else if (result != net::ERR_IO_PENDING) | 299 else if (result != net::ERR_IO_PENDING) |
299 callback.Run(net::OK, new_response); | 300 callback.Run(net::OK, new_response); |
300 } | 301 } |
OLD | NEW |