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

Side by Side Diff: chrome/browser/devtools/device/tcp_device_provider.cc

Issue 2116983002: Change HostResolver::Resolve() to take an std::unique_ptr<Request>* rather than a RequestHandle* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: http_stream_factory_impl_job_controller_unittest RequestHandle* to unique_ptr Created 4 years, 4 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
OLDNEW
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 22 matching lines...) Expand all
33 public: 33 public:
34 ResolveHostAndOpenSocket(const net::HostPortPair& address, 34 ResolveHostAndOpenSocket(const net::HostPortPair& address,
35 const AdbClientSocket::SocketCallback& callback) 35 const AdbClientSocket::SocketCallback& callback)
36 : callback_(callback) { 36 : callback_(callback) {
37 host_resolver_ = net::HostResolver::CreateDefaultResolver(nullptr); 37 host_resolver_ = net::HostResolver::CreateDefaultResolver(nullptr);
38 net::HostResolver::RequestInfo request_info(address); 38 net::HostResolver::RequestInfo request_info(address);
39 int result = host_resolver_->Resolve( 39 int result = host_resolver_->Resolve(
40 request_info, net::DEFAULT_PRIORITY, &address_list_, 40 request_info, net::DEFAULT_PRIORITY, &address_list_,
41 base::Bind(&ResolveHostAndOpenSocket::OnResolved, 41 base::Bind(&ResolveHostAndOpenSocket::OnResolved,
42 base::Unretained(this)), 42 base::Unretained(this)),
43 nullptr, net::BoundNetLog()); 43 &request_, net::BoundNetLog());
44 if (result != net::ERR_IO_PENDING) 44 if (result != net::ERR_IO_PENDING)
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(new net::TCPClientSocket( 55 std::unique_ptr<net::StreamSocket> socket(new net::TCPClientSocket(
56 address_list_, NULL, 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 std::unique_ptr<net::HostResolver::Request> request_;
63 net::AddressList address_list_; 64 net::AddressList address_list_;
64 AdbClientSocket::SocketCallback callback_; 65 AdbClientSocket::SocketCallback callback_;
65 }; 66 };
66 67
67 } // namespace 68 } // namespace
68 69
69 scoped_refptr<TCPDeviceProvider> TCPDeviceProvider::CreateForLocalhost( 70 scoped_refptr<TCPDeviceProvider> TCPDeviceProvider::CreateForLocalhost(
70 uint16_t port) { 71 uint16_t port) {
71 TCPDeviceProvider::HostPortSet targets; 72 TCPDeviceProvider::HostPortSet targets;
72 targets.insert(net::HostPortPair("127.0.0.1", port)); 73 targets.insert(net::HostPortPair("127.0.0.1", port));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 release_callback_.Run(); 126 release_callback_.Run();
126 } 127 }
127 128
128 void TCPDeviceProvider::set_release_callback_for_test( 129 void TCPDeviceProvider::set_release_callback_for_test(
129 const base::Closure& callback) { 130 const base::Closure& callback) {
130 release_callback_ = callback; 131 release_callback_ = callback;
131 } 132 }
132 133
133 TCPDeviceProvider::~TCPDeviceProvider() { 134 TCPDeviceProvider::~TCPDeviceProvider() {
134 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698