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

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

Issue 939503004: Add LoadState reporting to the mojo proxy resolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@proxy-resolver-mojo
Patch Set: Created 5 years, 10 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/proxy_resolver_mojo.h" 5 #include "net/proxy/proxy_resolver_mojo.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "mojo/common/common_type_converters.h" 10 #include "mojo/common/common_type_converters.h"
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 Job(ProxyResolverMojo* resolver, 24 Job(ProxyResolverMojo* resolver,
25 const GURL& url, 25 const GURL& url,
26 ProxyInfo* results, 26 ProxyInfo* results,
27 const net::CompletionCallback& callback); 27 const net::CompletionCallback& callback);
28 ~Job() override; 28 ~Job() override;
29 29
30 // Cancels the job and prevents the callback from being run. 30 // Cancels the job and prevents the callback from being run.
31 void Cancel(); 31 void Cancel();
32 32
33 // Returns the LoadState of this job.
34 LoadState load_state() { return load_state_; }
35
33 private: 36 private:
34 // Overridden from mojo::ErrorHandler: 37 // Overridden from mojo::ErrorHandler:
35 void OnConnectionError() override; 38 void OnConnectionError() override;
36 39
37 // Overridden from interfaces::ProxyResolverRequestClient: 40 // Overridden from interfaces::ProxyResolverRequestClient:
38 void ReportResult( 41 void ReportResult(
39 int32_t error, 42 int32_t error,
40 mojo::Array<interfaces::ProxyServerPtr> proxy_servers) override; 43 mojo::Array<interfaces::ProxyServerPtr> proxy_servers) override;
44 void LoadStateChanged(int32_t load_state) override;
41 45
42 ProxyResolverMojo* resolver_; 46 ProxyResolverMojo* resolver_;
43 const GURL url_; 47 const GURL url_;
44 ProxyInfo* results_; 48 ProxyInfo* results_;
45 net::CompletionCallback callback_; 49 net::CompletionCallback callback_;
50 LoadState load_state_ = LOAD_STATE_RESOLVING_PROXY_FOR_URL;
46 51
47 base::ThreadChecker thread_checker_; 52 base::ThreadChecker thread_checker_;
48 mojo::Binding<interfaces::ProxyResolverRequestClient> binding_; 53 mojo::Binding<interfaces::ProxyResolverRequestClient> binding_;
49 }; 54 };
50 55
51 ProxyResolverMojo::Job::Job(ProxyResolverMojo* resolver, 56 ProxyResolverMojo::Job::Job(ProxyResolverMojo* resolver,
52 const GURL& url, 57 const GURL& url,
53 ProxyInfo* results, 58 ProxyInfo* results,
54 const net::CompletionCallback& callback) 59 const net::CompletionCallback& callback)
55 : resolver_(resolver), 60 : resolver_(resolver),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 if (error == OK) { 97 if (error == OK) {
93 *results_ = proxy_servers.To<ProxyInfo>(); 98 *results_ = proxy_servers.To<ProxyInfo>();
94 DVLOG(1) << "Servers: " << results_->ToPacString(); 99 DVLOG(1) << "Servers: " << results_->ToPacString();
95 } 100 }
96 101
97 callback_.Run(error); 102 callback_.Run(error);
98 callback_.Reset(); 103 callback_.Reset();
99 resolver_->RemoveJob(this); 104 resolver_->RemoveJob(this);
100 } 105 }
101 106
107 void ProxyResolverMojo::Job::LoadStateChanged(int32_t load_state) {
108 load_state_ = static_cast<LoadState>(load_state);
109 }
110
102 ProxyResolverMojo::ProxyResolverMojo( 111 ProxyResolverMojo::ProxyResolverMojo(
103 MojoProxyResolverFactory* mojo_proxy_resolver_factory, 112 MojoProxyResolverFactory* mojo_proxy_resolver_factory,
104 HostResolver* host_resolver) 113 HostResolver* host_resolver)
105 : ProxyResolver(true /* |expects_pac_bytes| */), 114 : ProxyResolver(true /* |expects_pac_bytes| */),
106 mojo_proxy_resolver_factory_(mojo_proxy_resolver_factory), 115 mojo_proxy_resolver_factory_(mojo_proxy_resolver_factory),
107 host_resolver_(host_resolver) { 116 host_resolver_(host_resolver) {
108 SetUpServices(); 117 SetUpServices();
109 } 118 }
110 119
111 ProxyResolverMojo::~ProxyResolverMojo() { 120 ProxyResolverMojo::~ProxyResolverMojo() {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 234
226 void ProxyResolverMojo::CancelRequest(RequestHandle request) { 235 void ProxyResolverMojo::CancelRequest(RequestHandle request) {
227 DCHECK(thread_checker_.CalledOnValidThread()); 236 DCHECK(thread_checker_.CalledOnValidThread());
228 Job* job = static_cast<Job*>(request); 237 Job* job = static_cast<Job*>(request);
229 DCHECK(job); 238 DCHECK(job);
230 job->Cancel(); 239 job->Cancel();
231 RemoveJob(job); 240 RemoveJob(job);
232 } 241 }
233 242
234 LoadState ProxyResolverMojo::GetLoadState(RequestHandle request) const { 243 LoadState ProxyResolverMojo::GetLoadState(RequestHandle request) const {
235 // TODO(amistry): Implement real LoadState. 244 Job* job = static_cast<Job*>(request);
236 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; 245 CHECK_EQ(1u, pending_jobs_.count(job));
246 return job->load_state();
237 } 247 }
238 248
239 } // namespace net 249 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698