summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-15 18:31:03 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-15 18:31:03 +0000
commit004ec925e3f71aeba2acd1461741ccddd92eeedc (patch)
treee58efd0fc8f7b2baec92cde9d95fd8617d86d32d /chrome/browser/net
parent53f4636020e46d0ca54a60b1ecbbdcb677651c80 (diff)
downloadchromium_src-004ec925e3f71aeba2acd1461741ccddd92eeedc.zip
chromium_src-004ec925e3f71aeba2acd1461741ccddd92eeedc.tar.gz
chromium_src-004ec925e3f71aeba2acd1461741ccddd92eeedc.tar.bz2
Revert 78228 - Extended: Add "system" URLRequestContext (not ready for use!)
This is an extension of http://codereview.chromium.org/6280018 that provides a proxy configuration which respects command line parameters and policies BUG=67232,70732 TEST=Start chrome, observe two PROXY_CONFIG_CHANGED events in about:net-internals (if you are on a corporate network with PAC configurations), observe that everything behaves as usual. In particular the https://www.google.com/searchdomaincheck?format=domain&type=chrome request should not fail as it uses the new system URLRequestContext. Review URL: http://codereview.chromium.org/6292017 TBR=battre@chromium.org Review URL: http://codereview.chromium.org/6693023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78240 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc6
-rw-r--r--chrome/browser/net/pref_proxy_config_service.h4
-rw-r--r--chrome/browser/net/proxy_service_factory.cc107
-rw-r--r--chrome/browser/net/proxy_service_factory.h39
4 files changed, 7 insertions, 149 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 32a1f5d..e4c9794 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -25,6 +25,12 @@
#include "net/ocsp/nss_ocsp.h"
#endif
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/cros/libcros_service_library.h"
+#include "chrome/browser/chromeos/proxy_config_service.h"
+#endif // defined(OS_CHROMEOS)
+
class ChromeURLRequestContextFactory {
public:
ChromeURLRequestContextFactory() {}
diff --git a/chrome/browser/net/pref_proxy_config_service.h b/chrome/browser/net/pref_proxy_config_service.h
index b0e7fc3..490f06d 100644
--- a/chrome/browser/net/pref_proxy_config_service.h
+++ b/chrome/browser/net/pref_proxy_config_service.h
@@ -33,6 +33,7 @@ class PrefProxyConfigTracker
};
explicit PrefProxyConfigTracker(PrefService* pref_service);
+ virtual ~PrefProxyConfigTracker();
// Observer manipulation is only valid on the IO thread.
void AddObserver(Observer* observer);
@@ -49,9 +50,6 @@ class PrefProxyConfigTracker
void DetachFromPrefService();
private:
- friend class base::RefCountedThreadSafe<PrefProxyConfigTracker>;
- virtual ~PrefProxyConfigTracker();
-
// NotificationObserver implementation:
virtual void Observe(NotificationType type,
const NotificationSource& source,
diff --git a/chrome/browser/net/proxy_service_factory.cc b/chrome/browser/net/proxy_service_factory.cc
deleted file mode 100644
index bc74d71..0000000
--- a/chrome/browser/net/proxy_service_factory.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/net/proxy_service_factory.h"
-
-#include "base/command_line.h"
-#include "base/string_number_conversions.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/net/pref_proxy_config_service.h"
-#include "chrome/browser/io_thread.h"
-#include "chrome/common/chrome_switches.h"
-#include "content/browser/browser_thread.h"
-#include "net/base/net_log.h"
-#include "net/proxy/proxy_config_service.h"
-#include "net/proxy/proxy_script_fetcher_impl.h"
-#include "net/url_request/url_request_context.h"
-
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/cros/cros_library.h"
-#include "chrome/browser/chromeos/cros/libcros_service_library.h"
-#include "chrome/browser/chromeos/proxy_config_service.h"
-#endif // defined(OS_CHROMEOS)
-
-// static
-net::ProxyConfigService* ProxyServiceFactory::CreateProxyConfigService(
- PrefProxyConfigTracker* proxy_config_tracker) {
- // The linux gconf-based proxy settings getter relies on being initialized
- // from the UI thread.
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- // Create a baseline service that provides proxy configuration in case nothing
- // is configured through prefs (Note: prefs include command line and
- // configuration policy).
- net::ProxyConfigService* base_service = NULL;
-
- // TODO(port): the IO and FILE message loops are only used by Linux. Can
- // that code be moved to chrome/browser instead of being in net, so that it
- // can use BrowserThread instead of raw MessageLoop pointers? See bug 25354.
-#if defined(OS_CHROMEOS)
- base_service = new chromeos::ProxyConfigService(
- g_browser_process->chromeos_proxy_config_service_impl());
-#else
- base_service = net::ProxyService::CreateSystemProxyConfigService(
- g_browser_process->io_thread()->message_loop(),
- g_browser_process->file_thread()->message_loop());
-#endif // defined(OS_CHROMEOS)
-
- return new PrefProxyConfigService(proxy_config_tracker, base_service);
-}
-
-// static
-net::ProxyService* ProxyServiceFactory::CreateProxyService(
- net::NetLog* net_log,
- net::URLRequestContext* context,
- net::ProxyConfigService* proxy_config_service,
- const CommandLine& command_line) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-
- bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver);
- if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) {
- // See the note about V8 multithreading in net/proxy/proxy_resolver_v8.h
- // to understand why we have this limitation.
- LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode.";
- use_v8 = false; // Fallback to non-v8 implementation.
- }
-
- size_t num_pac_threads = 0u; // Use default number of threads.
-
- // Check the command line for an override on the number of proxy resolver
- // threads to use.
- if (command_line.HasSwitch(switches::kNumPacThreads)) {
- std::string s = command_line.GetSwitchValueASCII(switches::kNumPacThreads);
-
- // Parse the switch (it should be a positive integer formatted as decimal).
- int n;
- if (base::StringToInt(s, &n) && n > 0) {
- num_pac_threads = static_cast<size_t>(n);
- } else {
- LOG(ERROR) << "Invalid switch for number of PAC threads: " << s;
- }
- }
-
- net::ProxyService* proxy_service;
- if (use_v8) {
- proxy_service = net::ProxyService::CreateUsingV8ProxyResolver(
- proxy_config_service,
- num_pac_threads,
- new net::ProxyScriptFetcherImpl(context),
- context->host_resolver(),
- net_log);
- } else {
- proxy_service = net::ProxyService::CreateUsingSystemProxyResolver(
- proxy_config_service,
- num_pac_threads,
- net_log);
- }
-
-#if defined(OS_CHROMEOS)
- if (chromeos::CrosLibrary::Get()->EnsureLoaded()) {
- chromeos::CrosLibrary::Get()->GetLibCrosServiceLibrary()->
- RegisterNetworkProxyHandler(proxy_service);
- }
-#endif // defined(OS_CHROMEOS)
-
- return proxy_service;
-}
diff --git a/chrome/browser/net/proxy_service_factory.h b/chrome/browser/net/proxy_service_factory.h
deleted file mode 100644
index aa6796c..0000000
--- a/chrome/browser/net/proxy_service_factory.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_NET_PROXY_SERVICE_FACTORY_H_
-#define CHROME_BROWSER_NET_PROXY_SERVICE_FACTORY_H_
-#pragma once
-
-#include "base/basictypes.h"
-
-class CommandLine;
-class PrefProxyConfigTracker;
-
-namespace net {
-class NetLog;
-class ProxyConfigService;
-class ProxyService;
-class URLRequestContext;
-} // namespace net
-
-class ProxyServiceFactory {
- public:
- // Creates a ProxyConfigService that delivers the system preferences
- // (or the respective ChromeOS equivalent).
- static net::ProxyConfigService* CreateProxyConfigService(
- PrefProxyConfigTracker* proxy_config_tracker);
-
- // Create a proxy service according to the options on command line.
- static net::ProxyService* CreateProxyService(
- net::NetLog* net_log,
- net::URLRequestContext* context,
- net::ProxyConfigService* proxy_config_service,
- const CommandLine& command_line);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(ProxyServiceFactory);
-};
-
-#endif // CHROME_BROWSER_NET_PROXY_SERVICE_FACTORY_H_