| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/url_request/url_request_job.h" | 5 #include "net/url_request/url_request_job.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 return false; | 114 return false; |
| 115 } | 115 } |
| 116 | 116 |
| 117 void URLRequestJob::GetResponseInfo(net::HttpResponseInfo* info) { | 117 void URLRequestJob::GetResponseInfo(net::HttpResponseInfo* info) { |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool URLRequestJob::GetResponseCookies(std::vector<std::string>* cookies) { | 120 bool URLRequestJob::GetResponseCookies(std::vector<std::string>* cookies) { |
| 121 return false; | 121 return false; |
| 122 } | 122 } |
| 123 | 123 |
| 124 bool URLRequestJob::GetContentEncodings( | 124 Filter* URLRequestJob::SetupFilter() const { |
| 125 std::vector<Filter::FilterType>* encoding_types) { | 125 return NULL; |
| 126 return false; | |
| 127 } | |
| 128 | |
| 129 void URLRequestJob::SetupFilter() { | |
| 130 std::vector<Filter::FilterType> encoding_types; | |
| 131 if (GetContentEncodings(&encoding_types)) { | |
| 132 filter_.reset(Filter::Factory(encoding_types, *this)); | |
| 133 } | |
| 134 } | 126 } |
| 135 | 127 |
| 136 bool URLRequestJob::IsRedirectResponse(GURL* location, | 128 bool URLRequestJob::IsRedirectResponse(GURL* location, |
| 137 int* http_status_code) { | 129 int* http_status_code) { |
| 138 // For non-HTTP jobs, headers will be null. | 130 // For non-HTTP jobs, headers will be null. |
| 139 net::HttpResponseHeaders* headers = request_->response_headers(); | 131 net::HttpResponseHeaders* headers = request_->response_headers(); |
| 140 if (!headers) | 132 if (!headers) |
| 141 return false; | 133 return false; |
| 142 | 134 |
| 143 std::string value; | 135 std::string value; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 // to send a challenge with the 401 response. | 442 // to send a challenge with the 401 response. |
| 451 if (auth_info) { | 443 if (auth_info) { |
| 452 request_->delegate()->OnAuthRequired(request_, auth_info); | 444 request_->delegate()->OnAuthRequired(request_, auth_info); |
| 453 // Wait for SetAuth or CancelAuth to be called. | 445 // Wait for SetAuth or CancelAuth to be called. |
| 454 return; | 446 return; |
| 455 } | 447 } |
| 456 } | 448 } |
| 457 | 449 |
| 458 has_handled_response_ = true; | 450 has_handled_response_ = true; |
| 459 if (request_->status().is_success()) { | 451 if (request_->status().is_success()) { |
| 460 SetupFilter(); | 452 filter_.reset(SetupFilter()); |
| 461 | 453 |
| 462 // Check if this content appears to be compressible. | 454 // Check if this content appears to be compressible. |
| 463 std::string mime_type; | 455 std::string mime_type; |
| 464 if (GetMimeType(&mime_type) && | 456 if (GetMimeType(&mime_type) && |
| 465 (net::IsSupportedJavascriptMimeType(mime_type.c_str()) || | 457 (net::IsSupportedJavascriptMimeType(mime_type.c_str()) || |
| 466 net::IsSupportedNonImageMimeType(mime_type.c_str()))) { | 458 net::IsSupportedNonImageMimeType(mime_type.c_str()))) { |
| 467 is_compressible_content_ = true; | 459 is_compressible_content_ = true; |
| 468 } | 460 } |
| 469 } | 461 } |
| 470 | 462 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 | 897 |
| 906 if (is_compressed_) { | 898 if (is_compressed_) { |
| 907 COMPRESSION_HISTOGRAM("NoProxy.BytesBeforeCompression", compressed_B); | 899 COMPRESSION_HISTOGRAM("NoProxy.BytesBeforeCompression", compressed_B); |
| 908 COMPRESSION_HISTOGRAM("NoProxy.BytesAfterCompression", decompressed_B); | 900 COMPRESSION_HISTOGRAM("NoProxy.BytesAfterCompression", decompressed_B); |
| 909 } else { | 901 } else { |
| 910 COMPRESSION_HISTOGRAM("NoProxy.ShouldHaveBeenCompressed", decompressed_B); | 902 COMPRESSION_HISTOGRAM("NoProxy.ShouldHaveBeenCompressed", decompressed_B); |
| 911 } | 903 } |
| 912 } | 904 } |
| 913 | 905 |
| 914 } // namespace net | 906 } // namespace net |
| OLD | NEW |