| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "net/proxy/proxy_script_fetcher.h" | 5 #include "net/proxy/proxy_script_fetcher.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 virtual void Fetch(const GURL& url, std::string* bytes, | 60 virtual void Fetch(const GURL& url, std::string* bytes, |
| 61 CompletionCallback* callback); | 61 CompletionCallback* callback); |
| 62 virtual void Cancel(); | 62 virtual void Cancel(); |
| 63 | 63 |
| 64 // URLRequest::Delegate methods: | 64 // URLRequest::Delegate methods: |
| 65 | 65 |
| 66 virtual void OnAuthRequired(URLRequest* request, | 66 virtual void OnAuthRequired(URLRequest* request, |
| 67 AuthChallengeInfo* auth_info); | 67 AuthChallengeInfo* auth_info); |
| 68 virtual void OnSSLCertificateError(URLRequest* request, int cert_error, | 68 virtual void OnSSLCertificateError(URLRequest* request, int cert_error, |
| 69 X509Certificate* cert); | 69 X509Certificate* cert); |
| 70 virtual void OnReceivedRedirect(URLRequest* request, const GURL& to_url); | |
| 71 virtual void OnResponseStarted(URLRequest* request); | 70 virtual void OnResponseStarted(URLRequest* request); |
| 72 virtual void OnReadCompleted(URLRequest* request, int num_bytes); | 71 virtual void OnReadCompleted(URLRequest* request, int num_bytes); |
| 73 virtual void OnResponseCompleted(URLRequest* request); | 72 virtual void OnResponseCompleted(URLRequest* request); |
| 74 | 73 |
| 75 private: | 74 private: |
| 76 // Read more bytes from the response. | 75 // Read more bytes from the response. |
| 77 void ReadBody(URLRequest* request); | 76 void ReadBody(URLRequest* request); |
| 78 | 77 |
| 79 // Called once the request has completed to notify the caller of | 78 // Called once the request has completed to notify the caller of |
| 80 // |response_code_| and |response_bytes_|. | 79 // |response_code_| and |response_bytes_|. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 void ProxyScriptFetcherImpl::OnSSLCertificateError(URLRequest* request, | 191 void ProxyScriptFetcherImpl::OnSSLCertificateError(URLRequest* request, |
| 193 int cert_error, | 192 int cert_error, |
| 194 X509Certificate* cert) { | 193 X509Certificate* cert) { |
| 195 DCHECK(request == cur_request_.get()); | 194 DCHECK(request == cur_request_.get()); |
| 196 LOG(WARNING) << "SSL certificate error when fetching PAC script, aborting."; | 195 LOG(WARNING) << "SSL certificate error when fetching PAC script, aborting."; |
| 197 // Certificate errors are in same space as net errors. | 196 // Certificate errors are in same space as net errors. |
| 198 result_code_ = cert_error; | 197 result_code_ = cert_error; |
| 199 request->Cancel(); | 198 request->Cancel(); |
| 200 } | 199 } |
| 201 | 200 |
| 202 void ProxyScriptFetcherImpl::OnReceivedRedirect(URLRequest* request, | |
| 203 const GURL& to_url) { | |
| 204 DCHECK(request == cur_request_.get()); | |
| 205 // OK, thanks for telling. | |
| 206 } | |
| 207 | |
| 208 void ProxyScriptFetcherImpl::OnResponseStarted(URLRequest* request) { | 201 void ProxyScriptFetcherImpl::OnResponseStarted(URLRequest* request) { |
| 209 DCHECK(request == cur_request_.get()); | 202 DCHECK(request == cur_request_.get()); |
| 210 | 203 |
| 211 if (!request->status().is_success()) { | 204 if (!request->status().is_success()) { |
| 212 OnResponseCompleted(request); | 205 OnResponseCompleted(request); |
| 213 return; | 206 return; |
| 214 } | 207 } |
| 215 | 208 |
| 216 // Require HTTP responses to have a success status code. | 209 // Require HTTP responses to have a success status code. |
| 217 if (request->url().SchemeIs("http") || request->url().SchemeIs("https")) { | 210 if (request->url().SchemeIs("http") || request->url().SchemeIs("https")) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 318 } |
| 326 | 319 |
| 327 // static | 320 // static |
| 328 size_t ProxyScriptFetcher::SetSizeConstraintForUnittest(size_t size_bytes) { | 321 size_t ProxyScriptFetcher::SetSizeConstraintForUnittest(size_t size_bytes) { |
| 329 size_t prev = max_response_bytes; | 322 size_t prev = max_response_bytes; |
| 330 max_response_bytes = size_bytes; | 323 max_response_bytes = size_bytes; |
| 331 return prev; | 324 return prev; |
| 332 } | 325 } |
| 333 | 326 |
| 334 } // namespace net | 327 } // namespace net |
| OLD | NEW |