| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/net/chrome_url_request_context.h" | 5 #include "chrome/browser/net/chrome_url_request_context.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/chrome_thread.h" | 10 #include "chrome/browser/chrome_thread.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 g_browser_process->file_thread()->message_loop()); | 75 g_browser_process->file_thread()->message_loop()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Otherwise use the fixed settings from the command line. | 78 // Otherwise use the fixed settings from the command line. |
| 79 return new net::ProxyConfigServiceFixed(*proxy_config_from_cmd_line.get()); | 79 return new net::ProxyConfigServiceFixed(*proxy_config_from_cmd_line.get()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Create a proxy service according to the options on command line. | 82 // Create a proxy service according to the options on command line. |
| 83 net::ProxyService* CreateProxyService( | 83 net::ProxyService* CreateProxyService( |
| 84 net::NetworkChangeNotifier* network_change_notifier, | 84 net::NetworkChangeNotifier* network_change_notifier, |
| 85 net::NetLog* net_log, |
| 85 URLRequestContext* context, | 86 URLRequestContext* context, |
| 86 net::ProxyConfigService* proxy_config_service, | 87 net::ProxyConfigService* proxy_config_service, |
| 87 const CommandLine& command_line, | 88 const CommandLine& command_line, |
| 88 MessageLoop* io_loop) { | 89 MessageLoop* io_loop) { |
| 89 CheckCurrentlyOnIOThread(); | 90 CheckCurrentlyOnIOThread(); |
| 90 | 91 |
| 91 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); | 92 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); |
| 92 if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) { | 93 if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) { |
| 93 // See the note about V8 multithreading in net/proxy/proxy_resolver_v8.h | 94 // See the note about V8 multithreading in net/proxy/proxy_resolver_v8.h |
| 94 // to understand why we have this limitation. | 95 // to understand why we have this limitation. |
| 95 LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode."; | 96 LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode."; |
| 96 use_v8 = false; // Fallback to non-v8 implementation. | 97 use_v8 = false; // Fallback to non-v8 implementation. |
| 97 } | 98 } |
| 98 | 99 |
| 99 return net::ProxyService::Create( | 100 return net::ProxyService::Create( |
| 100 proxy_config_service, | 101 proxy_config_service, |
| 101 use_v8, | 102 use_v8, |
| 102 context, | 103 context, |
| 103 network_change_notifier, | 104 network_change_notifier, |
| 105 net_log, |
| 104 io_loop); | 106 io_loop); |
| 105 } | 107 } |
| 106 | 108 |
| 107 // ---------------------------------------------------------------------------- | 109 // ---------------------------------------------------------------------------- |
| 108 // Helper factories | 110 // Helper factories |
| 109 // ---------------------------------------------------------------------------- | 111 // ---------------------------------------------------------------------------- |
| 110 | 112 |
| 111 // Factory that creates the main ChromeURLRequestContext. | 113 // Factory that creates the main ChromeURLRequestContext. |
| 112 class FactoryForOriginal : public ChromeURLRequestContextFactory { | 114 class FactoryForOriginal : public ChromeURLRequestContextFactory { |
| 113 public: | 115 public: |
| (...skipping 29 matching lines...) Expand all Loading... |
| 143 | 145 |
| 144 // Global host resolver for the context. | 146 // Global host resolver for the context. |
| 145 context->set_host_resolver(io_thread()->globals()->host_resolver); | 147 context->set_host_resolver(io_thread()->globals()->host_resolver); |
| 146 context->set_http_auth_handler_factory( | 148 context->set_http_auth_handler_factory( |
| 147 io_thread()->globals()->http_auth_handler_factory.get()); | 149 io_thread()->globals()->http_auth_handler_factory.get()); |
| 148 | 150 |
| 149 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 151 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 150 | 152 |
| 151 context->set_proxy_service( | 153 context->set_proxy_service( |
| 152 CreateProxyService(io_thread()->globals()->network_change_notifier.get(), | 154 CreateProxyService(io_thread()->globals()->network_change_notifier.get(), |
| 155 io_thread()->globals()->net_log.get(), |
| 153 context, | 156 context, |
| 154 proxy_config_service_.release(), | 157 proxy_config_service_.release(), |
| 155 command_line, | 158 command_line, |
| 156 MessageLoop::current() /*io_loop*/)); | 159 MessageLoop::current() /*io_loop*/)); |
| 157 | 160 |
| 158 net::HttpCache* cache = | 161 net::HttpCache* cache = |
| 159 new net::HttpCache(io_thread()->globals()->network_change_notifier.get(), | 162 new net::HttpCache(io_thread()->globals()->network_change_notifier.get(), |
| 160 context->host_resolver(), | 163 context->host_resolver(), |
| 161 context->proxy_service(), | 164 context->proxy_service(), |
| 162 context->ssl_config_service(), | 165 context->ssl_config_service(), |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 } | 942 } |
| 940 | 943 |
| 941 if (command_line.HasSwitch(switches::kProxyBypassList)) { | 944 if (command_line.HasSwitch(switches::kProxyBypassList)) { |
| 942 proxy_config->proxy_rules().bypass_rules.ParseFromString( | 945 proxy_config->proxy_rules().bypass_rules.ParseFromString( |
| 943 WideToASCII(command_line.GetSwitchValue( | 946 WideToASCII(command_line.GetSwitchValue( |
| 944 switches::kProxyBypassList))); | 947 switches::kProxyBypassList))); |
| 945 } | 948 } |
| 946 | 949 |
| 947 return proxy_config; | 950 return proxy_config; |
| 948 } | 951 } |
| OLD | NEW |