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

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

Issue 1439053002: Change ProxyResolver::GetProxyForURL() to take a scoped_ptr<Request>* rather than a RequestHandle* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "mojo/common/url_type_converters.h" 8 #include "mojo/common/url_type_converters.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/log/net_log.h" 10 #include "net/log/net_log.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 scoped_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 scoped_ptr<ProxyResolverV8Tracing> resolver) 47 scoped_ptr<ProxyResolverV8Tracing> resolver)
48 : resolver_(resolver.Pass()) { 48 : resolver_(resolver.Pass()) {
49 } 49 }
50 50
(...skipping 17 matching lines...) Expand all
68 delete job; 68 delete job;
69 } 69 }
70 70
71 MojoProxyResolverImpl::Job::Job( 71 MojoProxyResolverImpl::Job::Job(
72 interfaces::ProxyResolverRequestClientPtr client, 72 interfaces::ProxyResolverRequestClientPtr client,
73 MojoProxyResolverImpl* resolver, 73 MojoProxyResolverImpl* resolver,
74 const GURL& url) 74 const GURL& url)
75 : resolver_(resolver), 75 : resolver_(resolver),
76 client_(client.Pass()), 76 client_(client.Pass()),
77 url_(url), 77 url_(url),
78 request_handle_(nullptr),
79 done_(false) {} 78 done_(false) {}
80 79
81 MojoProxyResolverImpl::Job::~Job() { 80 MojoProxyResolverImpl::Job::~Job() {}
82 if (request_handle_ && !done_)
83 resolver_->resolver_->CancelRequest(request_handle_);
84 }
85 81
86 void MojoProxyResolverImpl::Job::Start() { 82 void MojoProxyResolverImpl::Job::Start() {
87 resolver_->resolver_->GetProxyForURL( 83 resolver_->resolver_->GetProxyForURL(
88 url_, &result_, base::Bind(&Job::GetProxyDone, base::Unretained(this)), 84 url_, &result_, base::Bind(&Job::GetProxyDone, base::Unretained(this)),
89 &request_handle_, 85 &request_,
90 make_scoped_ptr(new MojoProxyResolverV8TracingBindings< 86 make_scoped_ptr(new MojoProxyResolverV8TracingBindings<
91 interfaces::ProxyResolverRequestClient>(client_.get()))); 87 interfaces::ProxyResolverRequestClient>(client_.get())));
92 client_.set_connection_error_handler(base::Bind( 88 client_.set_connection_error_handler(base::Bind(
93 &MojoProxyResolverImpl::Job::OnConnectionError, base::Unretained(this))); 89 &MojoProxyResolverImpl::Job::OnConnectionError, base::Unretained(this)));
94 } 90 }
95 91
96 void MojoProxyResolverImpl::Job::GetProxyDone(int error) { 92 void MojoProxyResolverImpl::Job::GetProxyDone(int error) {
97 done_ = true; 93 done_ = true;
98 DVLOG(1) << "GetProxyForUrl(" << url_ << ") finished with error " << error 94 DVLOG(1) << "GetProxyForUrl(" << url_ << ") finished with error " << error
99 << ". " << result_.proxy_list().size() << " Proxies returned:"; 95 << ". " << result_.proxy_list().size() << " Proxies returned:";
100 for (const auto& proxy : result_.proxy_list().GetAll()) { 96 for (const auto& proxy : result_.proxy_list().GetAll()) {
101 DVLOG(1) << proxy.ToURI(); 97 DVLOG(1) << proxy.ToURI();
102 } 98 }
103 mojo::Array<interfaces::ProxyServerPtr> result; 99 mojo::Array<interfaces::ProxyServerPtr> result;
104 if (error == OK) { 100 if (error == OK) {
105 result = mojo::Array<interfaces::ProxyServerPtr>::From( 101 result = mojo::Array<interfaces::ProxyServerPtr>::From(
106 result_.proxy_list().GetAll()); 102 result_.proxy_list().GetAll());
107 } 103 }
108 client_->ReportResult(error, result.Pass()); 104 client_->ReportResult(error, result.Pass());
109 resolver_->DeleteJob(this); 105 resolver_->DeleteJob(this);
110 } 106 }
111 107
112 void MojoProxyResolverImpl::Job::OnConnectionError() { 108 void MojoProxyResolverImpl::Job::OnConnectionError() {
113 resolver_->DeleteJob(this); 109 resolver_->DeleteJob(this);
114 } 110 }
115 111
116 } // namespace net 112 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698