| 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_mojo.h" | 5 #include "net/proxy/proxy_resolver_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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 ~ProxyResolverMojo() override; | 84 ~ProxyResolverMojo() override; |
| 85 | 85 |
| 86 // ProxyResolver implementation: | 86 // ProxyResolver implementation: |
| 87 int GetProxyForURL(const GURL& url, | 87 int GetProxyForURL(const GURL& url, |
| 88 ProxyInfo* results, | 88 ProxyInfo* results, |
| 89 const net::CompletionCallback& callback, | 89 const net::CompletionCallback& callback, |
| 90 RequestHandle* request, | 90 RequestHandle* request, |
| 91 const BoundNetLog& net_log) override; | 91 const BoundNetLog& net_log) override; |
| 92 void CancelRequest(RequestHandle request) override; | 92 void CancelRequest(RequestHandle request) override; |
| 93 LoadState GetLoadState(RequestHandle request) const override; | 93 LoadState GetLoadState(RequestHandle request) const override; |
| 94 void CancelSetPacScript() override; | |
| 95 int SetPacScript(const scoped_refptr<ProxyResolverScriptData>& pac_script, | |
| 96 const net::CompletionCallback& callback) override; | |
| 97 | 94 |
| 98 private: | 95 private: |
| 99 class Job; | 96 class Job; |
| 100 | 97 |
| 101 // Overridden from mojo::ErrorHandler: | 98 // Overridden from mojo::ErrorHandler: |
| 102 void OnConnectionError() override; | 99 void OnConnectionError() override; |
| 103 | 100 |
| 104 void RemoveJob(Job* job); | 101 void RemoveJob(Job* job); |
| 105 | 102 |
| 106 // Connection to the Mojo proxy resolver. | 103 // Connection to the Mojo proxy resolver. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 void ProxyResolverMojo::Job::LoadStateChanged(int32_t load_state) { | 209 void ProxyResolverMojo::Job::LoadStateChanged(int32_t load_state) { |
| 213 load_state_ = static_cast<LoadState>(load_state); | 210 load_state_ = static_cast<LoadState>(load_state); |
| 214 } | 211 } |
| 215 | 212 |
| 216 ProxyResolverMojo::ProxyResolverMojo( | 213 ProxyResolverMojo::ProxyResolverMojo( |
| 217 interfaces::ProxyResolverPtr resolver_ptr, | 214 interfaces::ProxyResolverPtr resolver_ptr, |
| 218 scoped_ptr<interfaces::HostResolver> host_resolver, | 215 scoped_ptr<interfaces::HostResolver> host_resolver, |
| 219 scoped_ptr<mojo::Binding<interfaces::HostResolver>> host_resolver_binding, | 216 scoped_ptr<mojo::Binding<interfaces::HostResolver>> host_resolver_binding, |
| 220 scoped_ptr<base::ScopedClosureRunner> on_delete_callback_runner, | 217 scoped_ptr<base::ScopedClosureRunner> on_delete_callback_runner, |
| 221 scoped_ptr<ErrorObserverHolder> error_observer) | 218 scoped_ptr<ErrorObserverHolder> error_observer) |
| 222 : ProxyResolver(true), | 219 : mojo_proxy_resolver_ptr_(resolver_ptr.Pass()), |
| 223 mojo_proxy_resolver_ptr_(resolver_ptr.Pass()), | |
| 224 mojo_host_resolver_(host_resolver.Pass()), | 220 mojo_host_resolver_(host_resolver.Pass()), |
| 225 mojo_host_resolver_binding_(host_resolver_binding.Pass()), | 221 mojo_host_resolver_binding_(host_resolver_binding.Pass()), |
| 226 error_observer_(error_observer.Pass()), | 222 error_observer_(error_observer.Pass()), |
| 227 on_delete_callback_runner_(on_delete_callback_runner.Pass()) { | 223 on_delete_callback_runner_(on_delete_callback_runner.Pass()) { |
| 228 mojo_proxy_resolver_ptr_.set_error_handler(this); | 224 mojo_proxy_resolver_ptr_.set_error_handler(this); |
| 229 } | 225 } |
| 230 | 226 |
| 231 ProxyResolverMojo::~ProxyResolverMojo() { | 227 ProxyResolverMojo::~ProxyResolverMojo() { |
| 232 DCHECK(thread_checker_.CalledOnValidThread()); | 228 DCHECK(thread_checker_.CalledOnValidThread()); |
| 233 // All pending requests should have been cancelled. | 229 // All pending requests should have been cancelled. |
| 234 DCHECK(pending_jobs_.empty()); | 230 DCHECK(pending_jobs_.empty()); |
| 235 } | 231 } |
| 236 | 232 |
| 237 void ProxyResolverMojo::CancelSetPacScript() { | |
| 238 NOTREACHED(); | |
| 239 } | |
| 240 | |
| 241 int ProxyResolverMojo::SetPacScript( | |
| 242 const scoped_refptr<ProxyResolverScriptData>& pac_script, | |
| 243 const CompletionCallback& callback) { | |
| 244 NOTREACHED(); | |
| 245 return ERR_NOT_IMPLEMENTED; | |
| 246 } | |
| 247 | |
| 248 void ProxyResolverMojo::OnConnectionError() { | 233 void ProxyResolverMojo::OnConnectionError() { |
| 249 DCHECK(thread_checker_.CalledOnValidThread()); | 234 DCHECK(thread_checker_.CalledOnValidThread()); |
| 250 DVLOG(1) << "ProxyResolverMojo::OnConnectionError"; | 235 DVLOG(1) << "ProxyResolverMojo::OnConnectionError"; |
| 251 | 236 |
| 252 // Disconnect from the Mojo proxy resolver service. | 237 // Disconnect from the Mojo proxy resolver service. |
| 253 mojo_proxy_resolver_ptr_.reset(); | 238 mojo_proxy_resolver_ptr_.reset(); |
| 254 } | 239 } |
| 255 | 240 |
| 256 void ProxyResolverMojo::RemoveJob(Job* job) { | 241 void ProxyResolverMojo::RemoveJob(Job* job) { |
| 257 DCHECK(thread_checker_.CalledOnValidThread()); | 242 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 DCHECK(request); | 367 DCHECK(request); |
| 383 if (pac_script->type() != ProxyResolverScriptData::TYPE_SCRIPT_CONTENTS || | 368 if (pac_script->type() != ProxyResolverScriptData::TYPE_SCRIPT_CONTENTS || |
| 384 pac_script->utf16().empty()) { | 369 pac_script->utf16().empty()) { |
| 385 return ERR_PAC_SCRIPT_FAILED; | 370 return ERR_PAC_SCRIPT_FAILED; |
| 386 } | 371 } |
| 387 request->reset(new Job(this, pac_script, resolver, callback)); | 372 request->reset(new Job(this, pac_script, resolver, callback)); |
| 388 return ERR_IO_PENDING; | 373 return ERR_IO_PENDING; |
| 389 } | 374 } |
| 390 | 375 |
| 391 } // namespace net | 376 } // namespace net |
| OLD | NEW |