OLD | NEW |
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_factory_mojo.h" | 5 #include "net/proxy/proxy_resolver_factory_mojo.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 Job(ProxyResolverMojo* resolver, | 125 Job(ProxyResolverMojo* resolver, |
126 const GURL& url, | 126 const GURL& url, |
127 ProxyInfo* results, | 127 ProxyInfo* results, |
128 const CompletionCallback& callback); | 128 const CompletionCallback& callback); |
129 ~Job() override; | 129 ~Job() override; |
130 | 130 |
131 // Cancels the job and prevents the callback from being run. | 131 // Cancels the job and prevents the callback from being run. |
132 void Cancel(); | 132 void Cancel(); |
133 | 133 |
134 // Returns the LoadState of this job. | 134 // Returns the LoadState of this job. |
135 LoadState load_state() { return load_state_; } | 135 LoadState load_state() { return LOAD_STATE_RESOLVING_PROXY_FOR_URL; } |
136 | 136 |
137 private: | 137 private: |
138 // Overridden from mojo::ErrorHandler: | 138 // Overridden from mojo::ErrorHandler: |
139 void OnConnectionError() override; | 139 void OnConnectionError() override; |
140 | 140 |
141 // Overridden from interfaces::ProxyResolverRequestClient: | 141 // Overridden from interfaces::ProxyResolverRequestClient: |
142 void ReportResult( | 142 void ReportResult( |
143 int32_t error, | 143 int32_t error, |
144 mojo::Array<interfaces::ProxyServerPtr> proxy_servers) override; | 144 mojo::Array<interfaces::ProxyServerPtr> proxy_servers) override; |
145 void LoadStateChanged(int32_t load_state) override; | |
146 | 145 |
147 ProxyResolverMojo* resolver_; | 146 ProxyResolverMojo* resolver_; |
148 const GURL url_; | 147 const GURL url_; |
149 ProxyInfo* results_; | 148 ProxyInfo* results_; |
150 CompletionCallback callback_; | 149 CompletionCallback callback_; |
151 LoadState load_state_ = LOAD_STATE_RESOLVING_PROXY_FOR_URL; | |
152 | 150 |
153 base::ThreadChecker thread_checker_; | 151 base::ThreadChecker thread_checker_; |
154 mojo::Binding<interfaces::ProxyResolverRequestClient> binding_; | 152 mojo::Binding<interfaces::ProxyResolverRequestClient> binding_; |
155 }; | 153 }; |
156 | 154 |
157 ProxyResolverMojo::Job::Job(ProxyResolverMojo* resolver, | 155 ProxyResolverMojo::Job::Job(ProxyResolverMojo* resolver, |
158 const GURL& url, | 156 const GURL& url, |
159 ProxyInfo* results, | 157 ProxyInfo* results, |
160 const CompletionCallback& callback) | 158 const CompletionCallback& callback) |
161 : resolver_(resolver), | 159 : resolver_(resolver), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 *results_ = proxy_servers.To<ProxyInfo>(); | 197 *results_ = proxy_servers.To<ProxyInfo>(); |
200 DVLOG(1) << "Servers: " << results_->ToPacString(); | 198 DVLOG(1) << "Servers: " << results_->ToPacString(); |
201 } | 199 } |
202 | 200 |
203 CompletionCallback callback = callback_; | 201 CompletionCallback callback = callback_; |
204 callback_.Reset(); | 202 callback_.Reset(); |
205 resolver_->RemoveJob(this); | 203 resolver_->RemoveJob(this); |
206 callback.Run(error); | 204 callback.Run(error); |
207 } | 205 } |
208 | 206 |
209 void ProxyResolverMojo::Job::LoadStateChanged(int32_t load_state) { | |
210 load_state_ = static_cast<LoadState>(load_state); | |
211 } | |
212 | |
213 ProxyResolverMojo::ProxyResolverMojo( | 207 ProxyResolverMojo::ProxyResolverMojo( |
214 interfaces::ProxyResolverPtr resolver_ptr, | 208 interfaces::ProxyResolverPtr resolver_ptr, |
215 scoped_ptr<interfaces::HostResolver> host_resolver, | 209 scoped_ptr<interfaces::HostResolver> host_resolver, |
216 scoped_ptr<mojo::Binding<interfaces::HostResolver>> host_resolver_binding, | 210 scoped_ptr<mojo::Binding<interfaces::HostResolver>> host_resolver_binding, |
217 scoped_ptr<base::ScopedClosureRunner> on_delete_callback_runner, | 211 scoped_ptr<base::ScopedClosureRunner> on_delete_callback_runner, |
218 scoped_ptr<ErrorObserverHolder> error_observer) | 212 scoped_ptr<ErrorObserverHolder> error_observer) |
219 : mojo_proxy_resolver_ptr_(resolver_ptr.Pass()), | 213 : mojo_proxy_resolver_ptr_(resolver_ptr.Pass()), |
220 mojo_host_resolver_(host_resolver.Pass()), | 214 mojo_host_resolver_(host_resolver.Pass()), |
221 mojo_host_resolver_binding_(host_resolver_binding.Pass()), | 215 mojo_host_resolver_binding_(host_resolver_binding.Pass()), |
222 error_observer_(error_observer.Pass()), | 216 error_observer_(error_observer.Pass()), |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 DCHECK(request); | 361 DCHECK(request); |
368 if (pac_script->type() != ProxyResolverScriptData::TYPE_SCRIPT_CONTENTS || | 362 if (pac_script->type() != ProxyResolverScriptData::TYPE_SCRIPT_CONTENTS || |
369 pac_script->utf16().empty()) { | 363 pac_script->utf16().empty()) { |
370 return ERR_PAC_SCRIPT_FAILED; | 364 return ERR_PAC_SCRIPT_FAILED; |
371 } | 365 } |
372 request->reset(new Job(this, pac_script, resolver, callback)); | 366 request->reset(new Job(this, pac_script, resolver, callback)); |
373 return ERR_IO_PENDING; | 367 return ERR_IO_PENDING; |
374 } | 368 } |
375 | 369 |
376 } // namespace net | 370 } // namespace net |
OLD | NEW |