| 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/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 virtual void Fetch(const GURL& url, std::string* bytes, | 44 virtual void Fetch(const GURL& url, std::string* bytes, |
| 45 CompletionCallback* callback); | 45 CompletionCallback* callback); |
| 46 virtual void Cancel(); | 46 virtual void Cancel(); |
| 47 | 47 |
| 48 // URLRequest::Delegate methods: | 48 // URLRequest::Delegate methods: |
| 49 | 49 |
| 50 virtual void OnAuthRequired(URLRequest* request, | 50 virtual void OnAuthRequired(URLRequest* request, |
| 51 AuthChallengeInfo* auth_info); | 51 AuthChallengeInfo* auth_info); |
| 52 virtual void OnSSLCertificateError(URLRequest* request, int cert_error, | 52 virtual void OnSSLCertificateError(URLRequest* request, int cert_error, |
| 53 X509Certificate* cert); | 53 X509Certificate* cert); |
| 54 virtual void OnReceivedRedirect(URLRequest* request, const GURL& to_url); | |
| 55 virtual void OnResponseStarted(URLRequest* request); | 54 virtual void OnResponseStarted(URLRequest* request); |
| 56 virtual void OnReadCompleted(URLRequest* request, int num_bytes); | 55 virtual void OnReadCompleted(URLRequest* request, int num_bytes); |
| 57 virtual void OnResponseCompleted(URLRequest* request); | 56 virtual void OnResponseCompleted(URLRequest* request); |
| 58 | 57 |
| 59 private: | 58 private: |
| 60 // Read more bytes from the response. | 59 // Read more bytes from the response. |
| 61 void ReadBody(URLRequest* request); | 60 void ReadBody(URLRequest* request); |
| 62 | 61 |
| 63 // Called once the request has completed to notify the caller of | 62 // Called once the request has completed to notify the caller of |
| 64 // |response_code_| and |response_bytes_|. | 63 // |response_code_| and |response_bytes_|. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 170 |
| 172 void ProxyScriptFetcherImpl::OnSSLCertificateError(URLRequest* request, | 171 void ProxyScriptFetcherImpl::OnSSLCertificateError(URLRequest* request, |
| 173 int cert_error, | 172 int cert_error, |
| 174 X509Certificate* cert) { | 173 X509Certificate* cert) { |
| 175 DCHECK(request == cur_request_.get()); | 174 DCHECK(request == cur_request_.get()); |
| 176 // Certificate errors are in same space as net errors. | 175 // Certificate errors are in same space as net errors. |
| 177 result_code_ = cert_error; | 176 result_code_ = cert_error; |
| 178 request->Cancel(); | 177 request->Cancel(); |
| 179 } | 178 } |
| 180 | 179 |
| 181 void ProxyScriptFetcherImpl::OnReceivedRedirect(URLRequest* request, | |
| 182 const GURL& to_url) { | |
| 183 DCHECK(request == cur_request_.get()); | |
| 184 // OK, thanks for telling. | |
| 185 } | |
| 186 | |
| 187 void ProxyScriptFetcherImpl::OnResponseStarted(URLRequest* request) { | 180 void ProxyScriptFetcherImpl::OnResponseStarted(URLRequest* request) { |
| 188 DCHECK(request == cur_request_.get()); | 181 DCHECK(request == cur_request_.get()); |
| 189 | 182 |
| 190 if (!request->status().is_success()) { | 183 if (!request->status().is_success()) { |
| 191 OnResponseCompleted(request); | 184 OnResponseCompleted(request); |
| 192 return; | 185 return; |
| 193 } | 186 } |
| 194 | 187 |
| 195 // Require HTTP responses to have a success status code. | 188 // Require HTTP responses to have a success status code. |
| 196 if (request->url().SchemeIs("http") || request->url().SchemeIs("https")) { | 189 if (request->url().SchemeIs("http") || request->url().SchemeIs("https")) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 } | 288 } |
| 296 | 289 |
| 297 // static | 290 // static |
| 298 size_t ProxyScriptFetcher::SetSizeConstraintForUnittest(size_t size_bytes) { | 291 size_t ProxyScriptFetcher::SetSizeConstraintForUnittest(size_t size_bytes) { |
| 299 size_t prev = max_response_bytes; | 292 size_t prev = max_response_bytes; |
| 300 max_response_bytes = size_bytes; | 293 max_response_bytes = size_bytes; |
| 301 return prev; | 294 return prev; |
| 302 } | 295 } |
| 303 | 296 |
| 304 } // namespace net | 297 } // namespace net |
| OLD | NEW |