| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 net_log_.BeginEvent( | 128 net_log_.BeginEvent( |
| 129 NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, | 129 NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, |
| 130 new NetLogStringParameter("url", pac_url.spec())); | 130 new NetLogStringParameter("url", pac_url.spec())); |
| 131 | 131 |
| 132 if (!proxy_script_fetcher_) { | 132 if (!proxy_script_fetcher_) { |
| 133 net_log_.AddEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_HAS_NO_FETCHER, NULL); | 133 net_log_.AddEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_HAS_NO_FETCHER, NULL); |
| 134 return ERR_UNEXPECTED; | 134 return ERR_UNEXPECTED; |
| 135 } | 135 } |
| 136 | 136 |
| 137 return proxy_script_fetcher_->Fetch(pac_url, &pac_bytes_, &io_callback_); | 137 return proxy_script_fetcher_->Fetch(pac_url, &pac_script_, &io_callback_); |
| 138 } | 138 } |
| 139 | 139 |
| 140 int InitProxyResolver::DoFetchPacScriptComplete(int result) { | 140 int InitProxyResolver::DoFetchPacScriptComplete(int result) { |
| 141 DCHECK(resolver_->expects_pac_bytes()); | 141 DCHECK(resolver_->expects_pac_bytes()); |
| 142 | 142 |
| 143 if (result == OK) { | 143 if (result == OK) { |
| 144 net_log_.EndEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, NULL); | 144 net_log_.EndEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, NULL); |
| 145 } else { | 145 } else { |
| 146 net_log_.EndEvent( | 146 net_log_.EndEvent( |
| 147 NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, | 147 NetLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, |
| 148 new NetLogIntegerParameter("net_error", result)); | 148 new NetLogIntegerParameter("net_error", result)); |
| 149 return TryToFallbackPacUrl(result); | 149 return TryToFallbackPacUrl(result); |
| 150 } | 150 } |
| 151 | 151 |
| 152 next_state_ = STATE_SET_PAC_SCRIPT; | 152 next_state_ = STATE_SET_PAC_SCRIPT; |
| 153 return result; | 153 return result; |
| 154 } | 154 } |
| 155 | 155 |
| 156 int InitProxyResolver::DoSetPacScript() { | 156 int InitProxyResolver::DoSetPacScript() { |
| 157 net_log_.BeginEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, NULL); | 157 net_log_.BeginEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, NULL); |
| 158 | 158 |
| 159 const GURL& pac_url = current_pac_url(); | 159 const GURL& pac_url = current_pac_url(); |
| 160 | 160 |
| 161 next_state_ = STATE_SET_PAC_SCRIPT_COMPLETE; | 161 next_state_ = STATE_SET_PAC_SCRIPT_COMPLETE; |
| 162 | 162 |
| 163 return resolver_->expects_pac_bytes() ? | 163 return resolver_->expects_pac_bytes() ? |
| 164 resolver_->SetPacScriptByData(pac_bytes_, &io_callback_) : | 164 resolver_->SetPacScriptByData(pac_script_, &io_callback_) : |
| 165 resolver_->SetPacScriptByUrl(pac_url, &io_callback_); | 165 resolver_->SetPacScriptByUrl(pac_url, &io_callback_); |
| 166 } | 166 } |
| 167 | 167 |
| 168 int InitProxyResolver::DoSetPacScriptComplete(int result) { | 168 int InitProxyResolver::DoSetPacScriptComplete(int result) { |
| 169 if (result != OK) { | 169 if (result != OK) { |
| 170 net_log_.EndEvent( | 170 net_log_.EndEvent( |
| 171 NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, | 171 NetLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, |
| 172 new NetLogIntegerParameter("net_error", result)); | 172 new NetLogIntegerParameter("net_error", result)); |
| 173 return TryToFallbackPacUrl(result); | 173 return TryToFallbackPacUrl(result); |
| 174 } | 174 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 break; | 224 break; |
| 225 default: | 225 default: |
| 226 NOTREACHED(); | 226 NOTREACHED(); |
| 227 break; | 227 break; |
| 228 } | 228 } |
| 229 | 229 |
| 230 DidCompleteInit(); | 230 DidCompleteInit(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace net | 233 } // namespace net |
| OLD | NEW |