| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "net/proxy/init_proxy_resolver.h" | 5 #include "net/proxy/init_proxy_resolver.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 next_state_ = STATE_FETCH_PAC_SCRIPT_COMPLETE; | 163 next_state_ = STATE_FETCH_PAC_SCRIPT_COMPLETE; |
| 164 | 164 |
| 165 const PacURL& pac_url = current_pac_url(); | 165 const PacURL& pac_url = current_pac_url(); |
| 166 | 166 |
| 167 const GURL effective_pac_url = | 167 const GURL effective_pac_url = |
| 168 pac_url.auto_detect ? GURL(kWpadUrl) : pac_url.url; | 168 pac_url.auto_detect ? GURL(kWpadUrl) : pac_url.url; |
| 169 | 169 |
| 170 net_log_.BeginEvent( | 170 net_log_.BeginEvent( |
| 171 NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, | 171 NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, |
| 172 new NetLogStringParameter("url", | 172 make_scoped_refptr(new NetLogStringParameter( |
| 173 effective_pac_url.possibly_invalid_spec())); | 173 "url", effective_pac_url.possibly_invalid_spec()))); |
| 174 | 174 |
| 175 if (!proxy_script_fetcher_) { | 175 if (!proxy_script_fetcher_) { |
| 176 net_log_.AddEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_HAS_NO_FETCHER, NULL); | 176 net_log_.AddEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_HAS_NO_FETCHER, NULL); |
| 177 return ERR_UNEXPECTED; | 177 return ERR_UNEXPECTED; |
| 178 } | 178 } |
| 179 | 179 |
| 180 return proxy_script_fetcher_->Fetch(effective_pac_url, | 180 return proxy_script_fetcher_->Fetch(effective_pac_url, |
| 181 &pac_script_, | 181 &pac_script_, |
| 182 &io_callback_); | 182 &io_callback_); |
| 183 } | 183 } |
| 184 | 184 |
| 185 int InitProxyResolver::DoFetchPacScriptComplete(int result) { | 185 int InitProxyResolver::DoFetchPacScriptComplete(int result) { |
| 186 DCHECK(resolver_->expects_pac_bytes()); | 186 DCHECK(resolver_->expects_pac_bytes()); |
| 187 | 187 |
| 188 if (result == OK) { | 188 if (result == OK) { |
| 189 net_log_.EndEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, NULL); | 189 net_log_.EndEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, NULL); |
| 190 } else { | 190 } else { |
| 191 net_log_.EndEvent( | 191 net_log_.EndEvent( |
| 192 NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, | 192 NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, |
| 193 new NetLogIntegerParameter("net_error", result)); | 193 make_scoped_refptr(new NetLogIntegerParameter("net_error", result))); |
| 194 return TryToFallbackPacUrl(result); | 194 return TryToFallbackPacUrl(result); |
| 195 } | 195 } |
| 196 | 196 |
| 197 next_state_ = STATE_SET_PAC_SCRIPT; | 197 next_state_ = STATE_SET_PAC_SCRIPT; |
| 198 return result; | 198 return result; |
| 199 } | 199 } |
| 200 | 200 |
| 201 int InitProxyResolver::DoSetPacScript() { | 201 int InitProxyResolver::DoSetPacScript() { |
| 202 net_log_.BeginEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, NULL); | 202 net_log_.BeginEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, NULL); |
| 203 | 203 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 215 ProxyResolverScriptData::FromURL(pac_url.url); | 215 ProxyResolverScriptData::FromURL(pac_url.url); |
| 216 } | 216 } |
| 217 | 217 |
| 218 return resolver_->SetPacScript(script_data, &io_callback_); | 218 return resolver_->SetPacScript(script_data, &io_callback_); |
| 219 } | 219 } |
| 220 | 220 |
| 221 int InitProxyResolver::DoSetPacScriptComplete(int result) { | 221 int InitProxyResolver::DoSetPacScriptComplete(int result) { |
| 222 if (result != OK) { | 222 if (result != OK) { |
| 223 net_log_.EndEvent( | 223 net_log_.EndEvent( |
| 224 NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, | 224 NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, |
| 225 new NetLogIntegerParameter("net_error", result)); | 225 make_scoped_refptr(new NetLogIntegerParameter("net_error", result))); |
| 226 return TryToFallbackPacUrl(result); | 226 return TryToFallbackPacUrl(result); |
| 227 } | 227 } |
| 228 | 228 |
| 229 // Let the caller know which automatic setting we ended up initializing the | 229 // Let the caller know which automatic setting we ended up initializing the |
| 230 // resolver for (there may have been multiple fallbacks to choose from.) | 230 // resolver for (there may have been multiple fallbacks to choose from.) |
| 231 if (effective_config_) { | 231 if (effective_config_) { |
| 232 if (current_pac_url().auto_detect && resolver_->expects_pac_bytes()) { | 232 if (current_pac_url().auto_detect && resolver_->expects_pac_bytes()) { |
| 233 *effective_config_ = | 233 *effective_config_ = |
| 234 ProxyConfig::CreateFromCustomPacURL(GURL(kWpadUrl)); | 234 ProxyConfig::CreateFromCustomPacURL(GURL(kWpadUrl)); |
| 235 } else if (current_pac_url().auto_detect) { | 235 } else if (current_pac_url().auto_detect) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 break; | 298 break; |
| 299 default: | 299 default: |
| 300 NOTREACHED(); | 300 NOTREACHED(); |
| 301 break; | 301 break; |
| 302 } | 302 } |
| 303 | 303 |
| 304 DidCompleteInit(); | 304 DidCompleteInit(); |
| 305 } | 305 } |
| 306 | 306 |
| 307 } // namespace net | 307 } // namespace net |
| OLD | NEW |