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

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: Created 4 years, 10 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 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 return GetResponseHeaders()->response_code(); 1161 return GetResponseHeaders()->response_code();
1162 } 1162 }
1163 1163
1164 void URLRequestHttpJob::PopulateNetErrorDetails( 1164 void URLRequestHttpJob::PopulateNetErrorDetails(
1165 NetErrorDetails* details) const { 1165 NetErrorDetails* details) const {
1166 if (!transaction_) 1166 if (!transaction_)
1167 return; 1167 return;
1168 return transaction_->PopulateNetErrorDetails(details); 1168 return transaction_->PopulateNetErrorDetails(details);
1169 } 1169 }
1170 1170
1171 #if 0
1171 Filter* URLRequestHttpJob::SetupFilter() const { 1172 Filter* URLRequestHttpJob::SetupFilter() const {
1172 DCHECK(transaction_.get()); 1173 DCHECK(transaction_.get());
1173 if (!response_info_) 1174 if (!response_info_)
1174 return NULL; 1175 return NULL;
1175 1176
1176 std::vector<Filter::FilterType> encoding_types; 1177 std::vector<Filter::FilterType> encoding_types;
1177 std::string encoding_type; 1178 std::string encoding_type;
1178 HttpResponseHeaders* headers = GetResponseHeaders(); 1179 HttpResponseHeaders* headers = GetResponseHeaders();
1179 size_t iter = 0; 1180 size_t iter = 0;
1180 while (headers->EnumerateHeader(&iter, "Content-Encoding", &encoding_type)) { 1181 while (headers->EnumerateHeader(&iter, "Content-Encoding", &encoding_type)) {
1181 encoding_types.push_back(Filter::ConvertEncodingToType(encoding_type)); 1182 encoding_types.push_back(Filter::ConvertEncodingToType(encoding_type));
1182 } 1183 }
1183 1184
1184 // Even if encoding types are empty, there is a chance that we need to add 1185 // Even if encoding types are empty, there is a chance that we need to add
1185 // some decoding, as some proxies strip encoding completely. In such cases, 1186 // some decoding, as some proxies strip encoding completely. In such cases,
1186 // we may need to add (for example) SDCH filtering (when the context suggests 1187 // we may need to add (for example) SDCH filtering (when the context suggests
1187 // it is appropriate). 1188 // it is appropriate).
1188 Filter::FixupEncodingTypes(*filter_context_, &encoding_types); 1189 Filter::FixupEncodingTypes(*filter_context_, &encoding_types);
1189 1190
1190 return !encoding_types.empty() 1191 return !encoding_types.empty()
1191 ? Filter::Factory(encoding_types, *filter_context_) : NULL; 1192 ? Filter::Factory(encoding_types, *filter_context_) : NULL;
1192 } 1193 }
1194 #endif
1195 scoped_ptr<StreamSource> URLRequestHttpJob::SetupSource() {
1196 DCHECK(transaction_.get());
1197 if (!response_info_)
1198 return NULL;
1199
1200 std::string encoding_type;
1201 std::vector<std::string> encoding_types;
1202 HttpResponseHeaders* headers = GetResponseHeaders();
1203 size_t iter = 0;
1204 while (headers->EnumerateHeader(&iter, "Content-Encoding", &encoding_type)) {
1205 encoding_types.push_back(base::ToLowerASCII(encoding_type));
1206 }
1207
1208 return StreamSource::BuildSourceChain(URLRequestJob::SetupSource(),
1209 encoding_types, nullptr);
1210 }
1193 1211
1194 bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const { 1212 bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const {
1195 // Allow modification of reference fragments by default, unless 1213 // Allow modification of reference fragments by default, unless
1196 // |allowed_unsafe_redirect_url_| is set and equal to the redirect URL. 1214 // |allowed_unsafe_redirect_url_| is set and equal to the redirect URL.
1197 // When this is the case, we assume that the network delegate has set the 1215 // When this is the case, we assume that the network delegate has set the
1198 // desired redirect URL (with or without fragment), so it must not be changed 1216 // desired redirect URL (with or without fragment), so it must not be changed
1199 // any more. 1217 // any more.
1200 return !allowed_unsafe_redirect_url_.is_valid() || 1218 return !allowed_unsafe_redirect_url_.is_valid() ||
1201 allowed_unsafe_redirect_url_ != location; 1219 allowed_unsafe_redirect_url_ != location;
1202 } 1220 }
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 return override_response_headers_.get() ? 1624 return override_response_headers_.get() ?
1607 override_response_headers_.get() : 1625 override_response_headers_.get() :
1608 transaction_->GetResponseInfo()->headers.get(); 1626 transaction_->GetResponseInfo()->headers.get();
1609 } 1627 }
1610 1628
1611 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1629 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1612 awaiting_callback_ = false; 1630 awaiting_callback_ = false;
1613 } 1631 }
1614 1632
1615 } // namespace net 1633 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698