Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 1662763002: [ON HOLD] Implement pull-based design for content decoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor common logic Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 DCHECK(!sdch_test_control_ || !sdch_test_activated_); 224 DCHECK(!sdch_test_control_ || !sdch_test_activated_);
225 if (!is_cached_content_) { 225 if (!is_cached_content_) {
226 if (sdch_test_control_) 226 if (sdch_test_control_)
227 RecordPacketStats(FilterContext::SDCH_EXPERIMENT_HOLDBACK); 227 RecordPacketStats(FilterContext::SDCH_EXPERIMENT_HOLDBACK);
228 if (sdch_test_activated_) 228 if (sdch_test_activated_)
229 RecordPacketStats(FilterContext::SDCH_EXPERIMENT_DECODE); 229 RecordPacketStats(FilterContext::SDCH_EXPERIMENT_DECODE);
230 } 230 }
231 // Make sure SDCH filters are told to emit histogram data while 231 // Make sure SDCH filters are told to emit histogram data while
232 // filter_context_ is still alive. 232 // filter_context_ is still alive.
233 DestroyFilters(); 233 // DestroyFilters();
234 234
235 DoneWithRequest(ABORTED); 235 DoneWithRequest(ABORTED);
236 } 236 }
237 237
238 void URLRequestHttpJob::SetPriority(RequestPriority priority) { 238 void URLRequestHttpJob::SetPriority(RequestPriority priority) {
239 priority_ = priority; 239 priority_ = priority;
240 if (transaction_) 240 if (transaction_)
241 transaction_->SetPriority(priority_); 241 transaction_->SetPriority(priority_);
242 } 242 }
243 243
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 return GetResponseHeaders()->response_code(); 1078 return GetResponseHeaders()->response_code();
1079 } 1079 }
1080 1080
1081 void URLRequestHttpJob::PopulateNetErrorDetails( 1081 void URLRequestHttpJob::PopulateNetErrorDetails(
1082 NetErrorDetails* details) const { 1082 NetErrorDetails* details) const {
1083 if (!transaction_) 1083 if (!transaction_)
1084 return; 1084 return;
1085 return transaction_->PopulateNetErrorDetails(details); 1085 return transaction_->PopulateNetErrorDetails(details);
1086 } 1086 }
1087 1087
1088 Filter* URLRequestHttpJob::SetupFilter() const { 1088 scoped_ptr<StreamSource> URLRequestHttpJob::SetupSource() {
1089 DCHECK(transaction_.get()); 1089 DCHECK(transaction_.get());
1090 if (!response_info_) 1090 if (!response_info_)
1091 return NULL; 1091 return NULL;
1092 1092
1093 std::vector<Filter::FilterType> encoding_types;
1094 std::string encoding_type; 1093 std::string encoding_type;
1094 std::vector<std::string> encoding_types;
1095 HttpResponseHeaders* headers = GetResponseHeaders(); 1095 HttpResponseHeaders* headers = GetResponseHeaders();
1096 size_t iter = 0; 1096 size_t iter = 0;
1097 while (headers->EnumerateHeader(&iter, "Content-Encoding", &encoding_type)) { 1097 while (headers->EnumerateHeader(&iter, "Content-Encoding", &encoding_type)) {
1098 encoding_types.push_back(Filter::ConvertEncodingToType(encoding_type)); 1098 encoding_types.push_back(base::ToLowerASCII(encoding_type));
1099 } 1099 }
1100 1100
1101 // Even if encoding types are empty, there is a chance that we need to add 1101 return StreamSource::BuildSourceChain(URLRequestJob::SetupSource(),
1102 // some decoding, as some proxies strip encoding completely. In such cases, 1102 encoding_types, nullptr);
1103 // we may need to add (for example) SDCH filtering (when the context suggests
1104 // it is appropriate).
1105 Filter::FixupEncodingTypes(*filter_context_, &encoding_types);
1106
1107 return !encoding_types.empty()
1108 ? Filter::Factory(encoding_types, *filter_context_) : NULL;
1109 } 1103 }
1110 1104
1111 bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const { 1105 bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const {
1112 // Allow modification of reference fragments by default, unless 1106 // Allow modification of reference fragments by default, unless
1113 // |allowed_unsafe_redirect_url_| is set and equal to the redirect URL. 1107 // |allowed_unsafe_redirect_url_| is set and equal to the redirect URL.
1114 // When this is the case, we assume that the network delegate has set the 1108 // When this is the case, we assume that the network delegate has set the
1115 // desired redirect URL (with or without fragment), so it must not be changed 1109 // desired redirect URL (with or without fragment), so it must not be changed
1116 // any more. 1110 // any more.
1117 return !allowed_unsafe_redirect_url_.is_valid() || 1111 return !allowed_unsafe_redirect_url_.is_valid() ||
1118 allowed_unsafe_redirect_url_ != location; 1112 allowed_unsafe_redirect_url_ != location;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 return override_response_headers_.get() ? 1516 return override_response_headers_.get() ?
1523 override_response_headers_.get() : 1517 override_response_headers_.get() :
1524 transaction_->GetResponseInfo()->headers.get(); 1518 transaction_->GetResponseInfo()->headers.get();
1525 } 1519 }
1526 1520
1527 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1521 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1528 awaiting_callback_ = false; 1522 awaiting_callback_ = false;
1529 } 1523 }
1530 1524
1531 } // namespace net 1525 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698