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

Side by Side Diff: net/proxy/mojo_proxy_resolver_impl.cc

Issue 2299963002: Reland "Change ProxyResolver::GetProxyForURL() to take a unique_ptr<Request>* " (Closed)
Patch Set: remove fields proposed by eroman Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "net/proxy/mojo_proxy_resolver_impl.h" 5 #include "net/proxy/mojo_proxy_resolver_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 19 matching lines...) Expand all
30 // disconnecting, indicating cancellation. 30 // disconnecting, indicating cancellation.
31 void OnConnectionError(); 31 void OnConnectionError();
32 32
33 void GetProxyDone(int error); 33 void GetProxyDone(int error);
34 34
35 MojoProxyResolverImpl* resolver_; 35 MojoProxyResolverImpl* resolver_;
36 36
37 interfaces::ProxyResolverRequestClientPtr client_; 37 interfaces::ProxyResolverRequestClientPtr client_;
38 ProxyInfo result_; 38 ProxyInfo result_;
39 GURL url_; 39 GURL url_;
40 net::ProxyResolver::RequestHandle request_handle_; 40 std::unique_ptr<net::ProxyResolver::Request> request_;
41 bool done_; 41 bool done_;
42 42
43 DISALLOW_COPY_AND_ASSIGN(Job); 43 DISALLOW_COPY_AND_ASSIGN(Job);
44 }; 44 };
45 45
46 MojoProxyResolverImpl::MojoProxyResolverImpl( 46 MojoProxyResolverImpl::MojoProxyResolverImpl(
47 std::unique_ptr<ProxyResolverV8Tracing> resolver) 47 std::unique_ptr<ProxyResolverV8Tracing> resolver)
48 : resolver_(std::move(resolver)) {} 48 : resolver_(std::move(resolver)) {}
49 49
50 MojoProxyResolverImpl::~MojoProxyResolverImpl() { 50 MojoProxyResolverImpl::~MojoProxyResolverImpl() {
(...skipping 16 matching lines...) Expand all
67 resolve_jobs_.erase(it); 67 resolve_jobs_.erase(it);
68 } 68 }
69 69
70 MojoProxyResolverImpl::Job::Job( 70 MojoProxyResolverImpl::Job::Job(
71 interfaces::ProxyResolverRequestClientPtr client, 71 interfaces::ProxyResolverRequestClientPtr client,
72 MojoProxyResolverImpl* resolver, 72 MojoProxyResolverImpl* resolver,
73 const GURL& url) 73 const GURL& url)
74 : resolver_(resolver), 74 : resolver_(resolver),
75 client_(std::move(client)), 75 client_(std::move(client)),
76 url_(url), 76 url_(url),
77 request_handle_(nullptr),
78 done_(false) {} 77 done_(false) {}
79 78
80 MojoProxyResolverImpl::Job::~Job() { 79 MojoProxyResolverImpl::Job::~Job() {}
81 if (request_handle_ && !done_)
82 resolver_->resolver_->CancelRequest(request_handle_);
83 }
84 80
85 void MojoProxyResolverImpl::Job::Start() { 81 void MojoProxyResolverImpl::Job::Start() {
86 resolver_->resolver_->GetProxyForURL( 82 resolver_->resolver_->GetProxyForURL(
87 url_, &result_, base::Bind(&Job::GetProxyDone, base::Unretained(this)), 83 url_, &result_, base::Bind(&Job::GetProxyDone, base::Unretained(this)),
88 &request_handle_, 84 &request_, base::MakeUnique<MojoProxyResolverV8TracingBindings<
89 base::MakeUnique<MojoProxyResolverV8TracingBindings< 85 interfaces::ProxyResolverRequestClient>>(client_.get()));
90 interfaces::ProxyResolverRequestClient>>(client_.get()));
91 client_.set_connection_error_handler(base::Bind( 86 client_.set_connection_error_handler(base::Bind(
92 &MojoProxyResolverImpl::Job::OnConnectionError, base::Unretained(this))); 87 &MojoProxyResolverImpl::Job::OnConnectionError, base::Unretained(this)));
93 } 88 }
94 89
95 void MojoProxyResolverImpl::Job::GetProxyDone(int error) { 90 void MojoProxyResolverImpl::Job::GetProxyDone(int error) {
96 done_ = true; 91 done_ = true;
97 DVLOG(1) << "GetProxyForUrl(" << url_ << ") finished with error " << error 92 DVLOG(1) << "GetProxyForUrl(" << url_ << ") finished with error " << error
98 << ". " << result_.proxy_list().size() << " Proxies returned:"; 93 << ". " << result_.proxy_list().size() << " Proxies returned:";
99 for (const auto& proxy : result_.proxy_list().GetAll()) { 94 for (const auto& proxy : result_.proxy_list().GetAll()) {
100 DVLOG(1) << proxy.ToURI(); 95 DVLOG(1) << proxy.ToURI();
101 } 96 }
102 if (error == OK) 97 if (error == OK)
103 client_->ReportResult(error, result_); 98 client_->ReportResult(error, result_);
104 else 99 else
105 client_->ReportResult(error, ProxyInfo()); 100 client_->ReportResult(error, ProxyInfo());
106 101
107 resolver_->DeleteJob(this); 102 resolver_->DeleteJob(this);
108 } 103 }
109 104
110 void MojoProxyResolverImpl::Job::OnConnectionError() { 105 void MojoProxyResolverImpl::Job::OnConnectionError() {
111 resolver_->DeleteJob(this); 106 resolver_->DeleteJob(this);
112 } 107 }
113 108
114 } // namespace net 109 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/mojo_proxy_resolver_factory_impl_unittest.cc ('k') | net/proxy/mojo_proxy_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698