15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/proxy/proxy_service_v8.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/logging.h"
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/proxy/network_delegate_error_observer.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/proxy/proxy_resolver.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/proxy/proxy_resolver_v8_tracing.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/proxy/proxy_service.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace net {
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ProxyService* CreateProxyServiceUsingV8ProxyResolver(
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ProxyConfigService* proxy_config_service,
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ProxyScriptFetcher* proxy_script_fetcher,
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    HostResolver* host_resolver,
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    NetLog* net_log,
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    NetworkDelegate* network_delegate) {
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DCHECK(proxy_config_service);
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DCHECK(proxy_script_fetcher);
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DCHECK(dhcp_proxy_script_fetcher);
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DCHECK(host_resolver);
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
287d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  ProxyResolverErrorObserver* error_observer = new NetworkDelegateErrorObserver(
297d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)      network_delegate, base::MessageLoopProxy::current().get());
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ProxyResolver* proxy_resolver =
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      new ProxyResolverV8Tracing(host_resolver, error_observer, net_log);
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ProxyService* proxy_service =
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      new ProxyService(proxy_config_service, proxy_resolver, net_log);
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Configure fetchers to use for PAC script downloads and auto-detect.
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  proxy_service->SetProxyScriptFetchers(proxy_script_fetcher,
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        dhcp_proxy_script_fetcher);
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return proxy_service;
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace net
45