| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/dbus/services/proxy_resolution_service_provider.h" | 5 #include "chromeos/dbus/services/proxy_resolution_service_provider.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "dbus/bus.h" | 14 #include "dbus/bus.h" |
| 15 #include "dbus/message.h" | 15 #include "dbus/message.h" |
| 16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 17 #include "net/log/net_log_with_source.h" | 17 #include "net/log/net_log_with_source.h" |
| 18 #include "net/proxy/proxy_service.h" | 18 #include "net/proxy/proxy_info.h" |
| 19 #include "net/url_request/url_request_context.h" | 19 #include "net/url_request/url_request_context.h" |
| 20 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
| 21 #include "third_party/cros_system_api/dbus/service_constants.h" | 21 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 22 #include "url/gurl.h" |
| 22 | 23 |
| 23 namespace chromeos { | 24 namespace chromeos { |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // The ProxyResolverInterface implementation used in production. | 27 // The ProxyResolverInterface implementation used in production. |
| 27 class ProxyResolverImpl : public ProxyResolverInterface { | 28 class ProxyResolverImpl : public ProxyResolverInterface { |
| 28 public: | 29 public: |
| 29 explicit ProxyResolverImpl(std::unique_ptr<ProxyResolverDelegate> delegate); | 30 explicit ProxyResolverImpl(std::unique_ptr<ProxyResolverDelegate> delegate); |
| 30 ~ProxyResolverImpl() override; | 31 ~ProxyResolverImpl() override; |
| 31 | 32 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return; | 143 return; |
| 143 } | 144 } |
| 144 | 145 |
| 145 Request* request_ptr = request.get(); | 146 Request* request_ptr = request.get(); |
| 146 net::CompletionCallback callback = base::Bind( | 147 net::CompletionCallback callback = base::Bind( |
| 147 &ProxyResolverImpl::OnResolutionComplete, weak_ptr_factory_.GetWeakPtr(), | 148 &ProxyResolverImpl::OnResolutionComplete, weak_ptr_factory_.GetWeakPtr(), |
| 148 base::Passed(std::move(request))); | 149 base::Passed(std::move(request))); |
| 149 | 150 |
| 150 VLOG(1) << "Starting network proxy resolution for " | 151 VLOG(1) << "Starting network proxy resolution for " |
| 151 << request_ptr->source_url; | 152 << request_ptr->source_url; |
| 152 const int result = proxy_service->ResolveProxy( | 153 const int result = |
| 153 GURL(request_ptr->source_url), std::string(), &request_ptr->proxy_info, | 154 delegate_->ResolveProxy(proxy_service, GURL(request_ptr->source_url), |
| 154 callback, nullptr, nullptr, net::NetLogWithSource()); | 155 &request_ptr->proxy_info, callback); |
| 155 if (result != net::ERR_IO_PENDING) { | 156 if (result != net::ERR_IO_PENDING) { |
| 156 VLOG(1) << "Network proxy resolution completed synchronously."; | 157 VLOG(1) << "Network proxy resolution completed synchronously."; |
| 157 callback.Run(result); | 158 callback.Run(result); |
| 158 } | 159 } |
| 159 } | 160 } |
| 160 | 161 |
| 161 void ProxyResolverImpl::OnResolutionComplete(std::unique_ptr<Request> request, | 162 void ProxyResolverImpl::OnResolutionComplete(std::unique_ptr<Request> request, |
| 162 int result) { | 163 int result) { |
| 163 DCHECK(request->context_getter->GetNetworkTaskRunner() | 164 DCHECK(request->context_getter->GetNetworkTaskRunner() |
| 164 ->BelongsToCurrentThread()); | 165 ->BelongsToCurrentThread()); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 273 |
| 273 ProxyResolutionServiceProvider* ProxyResolutionServiceProvider::Create( | 274 ProxyResolutionServiceProvider* ProxyResolutionServiceProvider::Create( |
| 274 std::unique_ptr<ProxyResolverDelegate> delegate) { | 275 std::unique_ptr<ProxyResolverDelegate> delegate) { |
| 275 return new ProxyResolutionServiceProvider( | 276 return new ProxyResolutionServiceProvider( |
| 276 new ProxyResolverImpl(std::move(delegate))); | 277 new ProxyResolverImpl(std::move(delegate))); |
| 277 } | 278 } |
| 278 | 279 |
| 279 ProxyResolverInterface::~ProxyResolverInterface() = default; | 280 ProxyResolverInterface::~ProxyResolverInterface() = default; |
| 280 | 281 |
| 281 } // namespace chromeos | 282 } // namespace chromeos |
| OLD | NEW |