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/tcp_device_provider.h" | 5 #include "chrome/browser/devtools/device/tcp_device_provider.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 OnResolved(result); | 45 OnResolved(result); |
46 } | 46 } |
47 | 47 |
48 private: | 48 private: |
49 void OnResolved(int result) { | 49 void OnResolved(int result) { |
50 if (result < 0) { | 50 if (result < 0) { |
51 RunSocketCallback(callback_, nullptr, result); | 51 RunSocketCallback(callback_, nullptr, result); |
52 delete this; | 52 delete this; |
53 return; | 53 return; |
54 } | 54 } |
55 std::unique_ptr<net::StreamSocket> socket( | 55 std::unique_ptr<net::StreamSocket> socket(new net::TCPClientSocket( |
56 new net::TCPClientSocket(address_list_, NULL, net::NetLog::Source())); | 56 address_list_, NULL, NULL, net::NetLog::Source())); |
57 socket->Connect( | 57 socket->Connect( |
58 base::Bind(&RunSocketCallback, callback_, base::Passed(&socket))); | 58 base::Bind(&RunSocketCallback, callback_, base::Passed(&socket))); |
59 delete this; | 59 delete this; |
60 } | 60 } |
61 | 61 |
62 std::unique_ptr<net::HostResolver> host_resolver_; | 62 std::unique_ptr<net::HostResolver> host_resolver_; |
63 net::AddressList address_list_; | 63 net::AddressList address_list_; |
64 AdbClientSocket::SocketCallback callback_; | 64 AdbClientSocket::SocketCallback callback_; |
65 }; | 65 }; |
66 | 66 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 release_callback_.Run(); | 125 release_callback_.Run(); |
126 } | 126 } |
127 | 127 |
128 void TCPDeviceProvider::set_release_callback_for_test( | 128 void TCPDeviceProvider::set_release_callback_for_test( |
129 const base::Closure& callback) { | 129 const base::Closure& callback) { |
130 release_callback_ = callback; | 130 release_callback_ = callback; |
131 } | 131 } |
132 | 132 |
133 TCPDeviceProvider::~TCPDeviceProvider() { | 133 TCPDeviceProvider::~TCPDeviceProvider() { |
134 } | 134 } |
OLD | NEW |