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/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 CheckCurrentlyOnIOThread(); | 89 CheckCurrentlyOnIOThread(); |
90 | 90 |
91 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); | 91 bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver); |
92 if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) { | 92 if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) { |
93 // See the note about V8 multithreading in net/proxy/proxy_resolver_v8.h | 93 // See the note about V8 multithreading in net/proxy/proxy_resolver_v8.h |
94 // to understand why we have this limitation. | 94 // to understand why we have this limitation. |
95 LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode."; | 95 LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode."; |
96 use_v8 = false; // Fallback to non-v8 implementation. | 96 use_v8 = false; // Fallback to non-v8 implementation. |
97 } | 97 } |
98 | 98 |
| 99 size_t num_pac_threads = 0u; // Use default number of threads. |
| 100 |
| 101 // Check the command line for an override on the number of proxy resolver |
| 102 // threads to use. |
| 103 if (command_line.HasSwitch(switches::kNumPacThreads)) { |
| 104 std::string s = command_line.GetSwitchValueASCII(switches::kNumPacThreads); |
| 105 |
| 106 // Parse the switch (it should be a positive integer formatted as decimal). |
| 107 int n; |
| 108 if (StringToInt(s, &n) && n > 0) { |
| 109 num_pac_threads = static_cast<size_t>(n); |
| 110 } else { |
| 111 LOG(ERROR) << "Invalid switch for number of PAC threads: " << s; |
| 112 } |
| 113 } |
| 114 |
99 return net::ProxyService::Create( | 115 return net::ProxyService::Create( |
100 proxy_config_service, | 116 proxy_config_service, |
101 use_v8, | 117 use_v8, |
| 118 num_pac_threads, |
102 context, | 119 context, |
103 net_log, | 120 net_log, |
104 io_loop); | 121 io_loop); |
105 } | 122 } |
106 | 123 |
107 // ---------------------------------------------------------------------------- | 124 // ---------------------------------------------------------------------------- |
108 // CookieMonster::Delegate implementation | 125 // CookieMonster::Delegate implementation |
109 // ---------------------------------------------------------------------------- | 126 // ---------------------------------------------------------------------------- |
110 class ChromeCookieMonsterDelegate : public net::CookieMonster::Delegate { | 127 class ChromeCookieMonsterDelegate : public net::CookieMonster::Delegate { |
111 public: | 128 public: |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 prefs::kProxyAutoDetect)); | 1039 prefs::kProxyAutoDetect)); |
1023 | 1040 |
1024 if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { | 1041 if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { |
1025 std::string proxy_bypass = | 1042 std::string proxy_bypass = |
1026 pref_service->GetString(prefs::kProxyBypassList); | 1043 pref_service->GetString(prefs::kProxyBypassList); |
1027 proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); | 1044 proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); |
1028 } | 1045 } |
1029 | 1046 |
1030 return proxy_config; | 1047 return proxy_config; |
1031 } | 1048 } |
OLD | NEW |