Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 14 matching lines...) Expand all Loading... | |
| 25 #include "net/base/host_port_pair.h" | 25 #include "net/base/host_port_pair.h" |
| 26 #include "net/base/load_flags.h" | 26 #include "net/base/load_flags.h" |
| 27 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
| 28 #include "net/base/network_delegate.h" | 28 #include "net/base/network_delegate.h" |
| 29 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 29 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 30 #include "net/base/sdch_manager.h" | 30 #include "net/base/sdch_manager.h" |
| 31 #include "net/base/sdch_net_log_params.h" | 31 #include "net/base/sdch_net_log_params.h" |
| 32 #include "net/base/url_util.h" | 32 #include "net/base/url_util.h" |
| 33 #include "net/cert/cert_status_flags.h" | 33 #include "net/cert/cert_status_flags.h" |
| 34 #include "net/cookies/cookie_store.h" | 34 #include "net/cookies/cookie_store.h" |
| 35 #include "net/filter/brotli_stream_source.h" | |
| 36 #include "net/filter/filter_stream_source.h" | |
| 37 #include "net/filter/gzip_stream_source.h" | |
| 38 #include "net/filter/sdch_stream_source.h" | |
| 39 #include "net/filter/stream_source.h" | |
| 35 #include "net/http/http_content_disposition.h" | 40 #include "net/http/http_content_disposition.h" |
| 36 #include "net/http/http_network_session.h" | 41 #include "net/http/http_network_session.h" |
| 37 #include "net/http/http_request_headers.h" | 42 #include "net/http/http_request_headers.h" |
| 38 #include "net/http/http_response_headers.h" | 43 #include "net/http/http_response_headers.h" |
| 39 #include "net/http/http_response_info.h" | 44 #include "net/http/http_response_info.h" |
| 40 #include "net/http/http_status_code.h" | 45 #include "net/http/http_status_code.h" |
| 41 #include "net/http/http_transaction.h" | 46 #include "net/http/http_transaction.h" |
| 42 #include "net/http/http_transaction_factory.h" | 47 #include "net/http/http_transaction_factory.h" |
| 43 #include "net/http/http_util.h" | 48 #include "net/http/http_util.h" |
| 44 #include "net/nqe/network_quality_estimator.h" | 49 #include "net/nqe/network_quality_estimator.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 56 #include "net/url_request/url_request_job_factory.h" | 61 #include "net/url_request/url_request_job_factory.h" |
| 57 #include "net/url_request/url_request_redirect_job.h" | 62 #include "net/url_request/url_request_redirect_job.h" |
| 58 #include "net/url_request/url_request_throttler_manager.h" | 63 #include "net/url_request/url_request_throttler_manager.h" |
| 59 #include "net/websockets/websocket_handshake_stream_base.h" | 64 #include "net/websockets/websocket_handshake_stream_base.h" |
| 60 #include "url/origin.h" | 65 #include "url/origin.h" |
| 61 | 66 |
| 62 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; | 67 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; |
| 63 | 68 |
| 64 namespace { | 69 namespace { |
| 65 | 70 |
| 71 const char kDeflate[] = "deflate"; | |
| 72 const char kGZip[] = "gzip"; | |
| 73 const char kSdch[] = "sdch"; | |
| 74 const char kXGZip[] = "x-gzip"; | |
| 75 const char kBrotli[] = "br"; | |
| 76 | |
| 66 // True if the request method is "safe" (per section 4.2.1 of RFC 7231). | 77 // True if the request method is "safe" (per section 4.2.1 of RFC 7231). |
| 67 bool IsMethodSafe(const std::string& method) { | 78 bool IsMethodSafe(const std::string& method) { |
| 68 return method == "GET" || method == "HEAD" || method == "OPTIONS" || | 79 return method == "GET" || method == "HEAD" || method == "OPTIONS" || |
| 69 method == "TRACE"; | 80 method == "TRACE"; |
| 70 } | 81 } |
| 71 | 82 |
| 72 // Logs whether the CookieStore used for this request matches the | 83 // Logs whether the CookieStore used for this request matches the |
| 73 // ChannelIDService used when establishing the connection that this request is | 84 // ChannelIDService used when establishing the connection that this request is |
| 74 // sent over. This logging is only done for requests to accounts.google.com, and | 85 // sent over. This logging is only done for requests to accounts.google.com, and |
| 75 // only for requests where Channel ID was sent when establishing the connection. | 86 // only for requests where Channel ID was sent when establishing the connection. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 return new net::URLRequestRedirectJob( | 183 return new net::URLRequestRedirectJob( |
| 173 request, network_delegate, url.ReplaceComponents(replacements), | 184 request, network_delegate, url.ReplaceComponents(replacements), |
| 174 // Use status code 307 to preserve the method, so POST requests work. | 185 // Use status code 307 to preserve the method, so POST requests work. |
| 175 net::URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT, "HSTS"); | 186 net::URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT, "HSTS"); |
| 176 } | 187 } |
| 177 | 188 |
| 178 } // namespace | 189 } // namespace |
| 179 | 190 |
| 180 namespace net { | 191 namespace net { |
| 181 | 192 |
| 182 class URLRequestHttpJob::HttpFilterContext : public FilterContext { | 193 class URLRequestHttpJob::SdchContext : public SdchPolicyDelegate::Context { |
| 183 public: | 194 public: |
| 184 explicit HttpFilterContext(URLRequestHttpJob* job); | 195 explicit SdchContext(URLRequestHttpJob* job); |
| 185 ~HttpFilterContext() override; | 196 ~SdchContext() override; |
| 186 | 197 // SdchPolicyDelegate::Context implementation |
| 187 // FilterContext implementation. | |
| 188 bool GetMimeType(std::string* mime_type) const override; | 198 bool GetMimeType(std::string* mime_type) const override; |
| 189 bool GetURL(GURL* gurl) const override; | 199 bool GetURL(GURL* url) const override; |
| 190 base::Time GetRequestTime() const override; | 200 // base::Time GetRequestTime() const override; |
| 191 bool IsCachedContent() const override; | 201 bool IsCachedContent() const override; |
| 202 SdchManager* GetSdchManager() const override; | |
| 192 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override; | 203 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override; |
| 193 int64_t GetByteReadCount() const override; | 204 // int64_t GetByteReadCount() const override; |
| 194 int GetResponseCode() const override; | 205 int GetResponseCode() const override; |
| 195 const URLRequestContext* GetURLRequestContext() const override; | |
| 196 void RecordPacketStats(StatisticSelector statistic) const override; | |
| 197 const BoundNetLog& GetNetLog() const override; | 206 const BoundNetLog& GetNetLog() const override; |
| 198 | 207 |
| 199 private: | 208 private: |
| 209 // URLRequestHttpJob owns SdchPolicyDelegate which owns the context, so it | |
| 210 // is okay to have a raw pointer reference to |job_|. | |
| 200 URLRequestHttpJob* job_; | 211 URLRequestHttpJob* job_; |
| 201 | 212 |
| 202 // URLRequestHttpJob may be detached from URLRequest, but we still need to | 213 // URLRequestHttpJob may be detached from URLRequest, but still need to |
| 203 // return something. | 214 // return something. |
| 204 BoundNetLog dummy_log_; | 215 BoundNetLog dummy_log_; |
| 205 | 216 |
| 206 DISALLOW_COPY_AND_ASSIGN(HttpFilterContext); | 217 DISALLOW_COPY_AND_ASSIGN(SdchContext); |
| 207 }; | 218 }; |
| 208 | 219 |
| 209 URLRequestHttpJob::HttpFilterContext::HttpFilterContext(URLRequestHttpJob* job) | 220 URLRequestHttpJob::SdchContext::SdchContext(URLRequestHttpJob* job) |
| 210 : job_(job) { | 221 : job_(job) {} |
| 211 DCHECK(job_); | |
| 212 } | |
| 213 | 222 |
| 214 URLRequestHttpJob::HttpFilterContext::~HttpFilterContext() { | 223 URLRequestHttpJob::SdchContext::~SdchContext() {} |
| 215 } | |
| 216 | 224 |
| 217 bool URLRequestHttpJob::HttpFilterContext::GetMimeType( | 225 bool URLRequestHttpJob::SdchContext::GetMimeType(std::string* mime_type) const { |
| 218 std::string* mime_type) const { | |
| 219 return job_->GetMimeType(mime_type); | 226 return job_->GetMimeType(mime_type); |
| 220 } | 227 } |
| 221 | 228 |
| 222 bool URLRequestHttpJob::HttpFilterContext::GetURL(GURL* gurl) const { | 229 bool URLRequestHttpJob::SdchContext::GetURL(GURL* gurl) const { |
| 223 if (!job_->request()) | 230 if (!job_->request()) |
| 224 return false; | 231 return false; |
| 225 *gurl = job_->request()->url(); | 232 *gurl = job_->request()->url(); |
| 226 return true; | 233 return true; |
| 227 } | 234 } |
| 228 | 235 |
| 229 base::Time URLRequestHttpJob::HttpFilterContext::GetRequestTime() const { | 236 bool URLRequestHttpJob::SdchContext::IsCachedContent() const { |
| 230 return job_->request() ? job_->request()->request_time() : base::Time(); | |
| 231 } | |
| 232 | |
| 233 bool URLRequestHttpJob::HttpFilterContext::IsCachedContent() const { | |
| 234 return job_->is_cached_content_; | 237 return job_->is_cached_content_; |
| 235 } | 238 } |
| 236 | 239 |
| 240 SdchManager* URLRequestHttpJob::SdchContext::GetSdchManager() const { | |
| 241 return job_->request() ? job_->request()->context()->sdch_manager() : nullptr; | |
| 242 } | |
| 243 | |
| 237 SdchManager::DictionarySet* | 244 SdchManager::DictionarySet* |
| 238 URLRequestHttpJob::HttpFilterContext::SdchDictionariesAdvertised() const { | 245 URLRequestHttpJob::SdchContext::SdchDictionariesAdvertised() const { |
| 239 return job_->dictionaries_advertised_.get(); | 246 return job_->dictionaries_advertised_.get(); |
| 240 } | 247 } |
| 241 | 248 |
| 242 int64_t URLRequestHttpJob::HttpFilterContext::GetByteReadCount() const { | 249 int URLRequestHttpJob::SdchContext::GetResponseCode() const { |
| 243 return job_->prefilter_bytes_read(); | |
| 244 } | |
| 245 | |
| 246 int URLRequestHttpJob::HttpFilterContext::GetResponseCode() const { | |
| 247 return job_->GetResponseCode(); | 250 return job_->GetResponseCode(); |
| 248 } | 251 } |
| 249 | 252 |
| 250 const URLRequestContext* | 253 const BoundNetLog& URLRequestHttpJob::SdchContext::GetNetLog() const { |
| 251 URLRequestHttpJob::HttpFilterContext::GetURLRequestContext() const { | |
| 252 return job_->request() ? job_->request()->context() : NULL; | |
| 253 } | |
| 254 | |
| 255 void URLRequestHttpJob::HttpFilterContext::RecordPacketStats( | |
| 256 StatisticSelector statistic) const { | |
| 257 job_->RecordPacketStats(statistic); | |
| 258 } | |
| 259 | |
| 260 const BoundNetLog& URLRequestHttpJob::HttpFilterContext::GetNetLog() const { | |
| 261 return job_->request() ? job_->request()->net_log() : dummy_log_; | 254 return job_->request() ? job_->request()->net_log() : dummy_log_; |
| 262 } | 255 } |
| 263 | 256 |
| 264 // TODO(darin): make sure the port blocking code is not lost | 257 // TODO(darin): make sure the port blocking code is not lost |
| 265 // static | 258 // static |
| 266 URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request, | 259 URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request, |
| 267 NetworkDelegate* network_delegate, | 260 NetworkDelegate* network_delegate, |
| 268 const std::string& scheme) { | 261 const std::string& scheme) { |
| 269 DCHECK(scheme == "http" || scheme == "https" || scheme == "ws" || | 262 DCHECK(scheme == "http" || scheme == "https" || scheme == "ws" || |
| 270 scheme == "wss"); | 263 scheme == "wss"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 throttling_entry_(nullptr), | 296 throttling_entry_(nullptr), |
| 304 sdch_test_activated_(false), | 297 sdch_test_activated_(false), |
| 305 sdch_test_control_(false), | 298 sdch_test_control_(false), |
| 306 is_cached_content_(false), | 299 is_cached_content_(false), |
| 307 request_creation_time_(), | 300 request_creation_time_(), |
| 308 packet_timing_enabled_(false), | 301 packet_timing_enabled_(false), |
| 309 done_(false), | 302 done_(false), |
| 310 bytes_observed_in_packets_(0), | 303 bytes_observed_in_packets_(0), |
| 311 request_time_snapshot_(), | 304 request_time_snapshot_(), |
| 312 final_packet_time_(), | 305 final_packet_time_(), |
| 313 filter_context_(new HttpFilterContext(this)), | |
| 314 on_headers_received_callback_( | 306 on_headers_received_callback_( |
| 315 base::Bind(&URLRequestHttpJob::OnHeadersReceivedCallback, | 307 base::Bind(&URLRequestHttpJob::OnHeadersReceivedCallback, |
| 316 base::Unretained(this))), | 308 base::Unretained(this))), |
| 317 awaiting_callback_(false), | 309 awaiting_callback_(false), |
| 318 http_user_agent_settings_(http_user_agent_settings), | 310 http_user_agent_settings_(http_user_agent_settings), |
| 319 backoff_manager_(request->context()->backoff_manager()), | 311 backoff_manager_(request->context()->backoff_manager()), |
| 320 total_received_bytes_from_previous_transactions_(0), | 312 total_received_bytes_from_previous_transactions_(0), |
| 321 total_sent_bytes_from_previous_transactions_(0), | 313 total_sent_bytes_from_previous_transactions_(0), |
| 322 weak_factory_(this) { | 314 weak_factory_(this) { |
| 323 URLRequestThrottlerManager* manager = request->context()->throttler_manager(); | 315 URLRequestThrottlerManager* manager = request->context()->throttler_manager(); |
| 324 if (manager) | 316 if (manager) |
| 325 throttling_entry_ = manager->RegisterRequestUrl(request->url()); | 317 throttling_entry_ = manager->RegisterRequestUrl(request->url()); |
| 326 | 318 |
| 327 ResetTimer(); | 319 ResetTimer(); |
| 328 } | 320 } |
| 329 | 321 |
| 330 URLRequestHttpJob::~URLRequestHttpJob() { | 322 URLRequestHttpJob::~URLRequestHttpJob() { |
| 331 CHECK(!awaiting_callback_); | 323 CHECK(!awaiting_callback_); |
| 332 | 324 |
| 333 DCHECK(!sdch_test_control_ || !sdch_test_activated_); | 325 DCHECK(!sdch_test_control_ || !sdch_test_activated_); |
| 334 if (!is_cached_content_) { | 326 if (!is_cached_content_) { |
| 335 if (sdch_test_control_) | 327 if (sdch_test_control_) |
| 336 RecordPacketStats(FilterContext::SDCH_EXPERIMENT_HOLDBACK); | 328 RecordPacketStats(SdchPolicyDelegate::Context::SDCH_EXPERIMENT_HOLDBACK); |
| 337 if (sdch_test_activated_) | 329 if (sdch_test_activated_) |
| 338 RecordPacketStats(FilterContext::SDCH_EXPERIMENT_DECODE); | 330 RecordPacketStats(SdchPolicyDelegate::Context::SDCH_EXPERIMENT_DECODE); |
| 339 } | 331 } |
| 340 // Make sure SDCH filters are told to emit histogram data while | |
| 341 // filter_context_ is still alive. | |
| 342 DestroyFilters(); | |
| 343 | |
| 344 DoneWithRequest(ABORTED); | 332 DoneWithRequest(ABORTED); |
| 345 } | 333 } |
| 346 | 334 |
| 347 void URLRequestHttpJob::SetPriority(RequestPriority priority) { | 335 void URLRequestHttpJob::SetPriority(RequestPriority priority) { |
| 348 priority_ = priority; | 336 priority_ = priority; |
| 349 if (transaction_) | 337 if (transaction_) |
| 350 transaction_->SetPriority(priority_); | 338 transaction_->SetPriority(priority_); |
| 351 } | 339 } |
| 352 | 340 |
| 353 void URLRequestHttpJob::Start() { | 341 void URLRequestHttpJob::Start() { |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1196 return GetResponseHeaders()->response_code(); | 1184 return GetResponseHeaders()->response_code(); |
| 1197 } | 1185 } |
| 1198 | 1186 |
| 1199 void URLRequestHttpJob::PopulateNetErrorDetails( | 1187 void URLRequestHttpJob::PopulateNetErrorDetails( |
| 1200 NetErrorDetails* details) const { | 1188 NetErrorDetails* details) const { |
| 1201 if (!transaction_) | 1189 if (!transaction_) |
| 1202 return; | 1190 return; |
| 1203 return transaction_->PopulateNetErrorDetails(details); | 1191 return transaction_->PopulateNetErrorDetails(details); |
| 1204 } | 1192 } |
| 1205 | 1193 |
| 1206 std::unique_ptr<Filter> URLRequestHttpJob::SetupFilter() const { | 1194 std::unique_ptr<StreamSource> URLRequestHttpJob::SetupSource() { |
| 1207 DCHECK(transaction_.get()); | 1195 DCHECK(transaction_.get()); |
| 1208 if (!response_info_) | 1196 if (!response_info_) |
| 1209 return nullptr; | 1197 return nullptr; |
| 1210 | 1198 |
| 1211 std::vector<Filter::FilterType> encoding_types; | |
| 1212 std::string encoding_type; | |
| 1213 HttpResponseHeaders* headers = GetResponseHeaders(); | 1199 HttpResponseHeaders* headers = GetResponseHeaders(); |
| 1200 std::string type; | |
| 1201 std::vector<StreamSource::SourceType> types; | |
| 1214 size_t iter = 0; | 1202 size_t iter = 0; |
| 1215 while (headers->EnumerateHeader(&iter, "Content-Encoding", &encoding_type)) { | 1203 while (headers->EnumerateHeader(&iter, "Content-Encoding", &type)) { |
| 1216 encoding_types.push_back(Filter::ConvertEncodingToType(encoding_type)); | 1204 if (base::LowerCaseEqualsASCII(type, kBrotli)) { |
| 1205 types.push_back(StreamSource::TYPE_BROTLI); | |
| 1206 } else if (base::LowerCaseEqualsASCII(type, kDeflate)) { | |
| 1207 types.push_back(StreamSource::TYPE_DEFLATE); | |
| 1208 } else if (base::LowerCaseEqualsASCII(type, kGZip) || | |
| 1209 base::LowerCaseEqualsASCII(type, kXGZip)) { | |
| 1210 types.push_back(StreamSource::TYPE_GZIP); | |
| 1211 } else if (base::LowerCaseEqualsASCII(type, kSdch)) { | |
| 1212 types.push_back(StreamSource::TYPE_SDCH); | |
| 1213 } | |
| 1217 } | 1214 } |
| 1218 | 1215 |
| 1219 // Even if encoding types are empty, there is a chance that we need to add | 1216 // SDCH-specific hack: if the first filter is SDCH, add a gzip filter in front |
| 1220 // some decoding, as some proxies strip encoding completely. In such cases, | 1217 // of it in fallback mode. |
| 1221 // we may need to add (for example) SDCH filtering (when the context suggests | 1218 // Some proxies (found currently in Argentina) strip the Content-Encoding |
| 1222 // it is appropriate). | 1219 // text from "sdch,gzip" to a mere "sdch" without modifying the compressed |
| 1223 Filter::FixupEncodingTypes(*filter_context_, &encoding_types); | 1220 // payload. To handle this gracefully, we simulate the "probably" deleted |
| 1221 // ",gzip" by appending a tentative gzip decode, which will default to a | |
| 1222 // no-op pass through filter if it doesn't get gzip headers where expected. | |
| 1223 if (types.size() == 1 && types.at(0) == StreamSource::TYPE_SDCH) { | |
| 1224 types.insert(types.begin(), StreamSource::TYPE_GZIP_FALLBACK); | |
| 1225 // TODO(xunjieli): Add UMA to see how common this is. | |
| 1226 } | |
| 1224 | 1227 |
| 1225 return !encoding_types.empty() | 1228 std::unique_ptr<StreamSource> previous = URLRequestJob::SetupSource(); |
| 1226 ? Filter::Factory(encoding_types, *filter_context_) : NULL; | 1229 for (std::vector<StreamSource::SourceType>::reverse_iterator r_iter = |
| 1230 types.rbegin(); | |
| 1231 r_iter != types.rend(); ++r_iter) { | |
| 1232 std::unique_ptr<FilterStreamSource> next = nullptr; | |
|
mmenke
2016/07/28 18:40:13
nit: nullptr not needed.
xunjieli
2016/08/01 16:46:23
Done.
| |
| 1233 StreamSource::SourceType type = *r_iter; | |
| 1234 switch (type) { | |
| 1235 case StreamSource::TYPE_BROTLI: | |
| 1236 next = CreateBrotliStreamSource(std::move(previous)); | |
| 1237 break; | |
| 1238 case StreamSource::TYPE_SDCH: { | |
| 1239 std::unique_ptr<SdchContext> context(new SdchContext(this)); | |
| 1240 sdch_delegate_.reset(new SdchPolicyDelegate(std::move(context))); | |
| 1241 next.reset( | |
| 1242 new SdchStreamSource(std::move(previous), sdch_delegate_.get())); | |
| 1243 break; | |
| 1244 } | |
| 1245 case StreamSource::TYPE_GZIP: | |
| 1246 next = GzipStreamSource::Create( | |
| 1247 std::move(previous), GzipStreamSource::GZIP_STREAM_SOURCE_GZIP); | |
| 1248 break; | |
| 1249 case StreamSource::TYPE_DEFLATE: | |
| 1250 next = GzipStreamSource::Create( | |
| 1251 std::move(previous), GzipStreamSource::GZIP_STREAM_SOURCE_DEFLATE); | |
| 1252 break; | |
| 1253 case StreamSource::TYPE_GZIP_FALLBACK: | |
| 1254 next = GzipStreamSource::Create( | |
| 1255 std::move(previous), | |
| 1256 GzipStreamSource::GZIP_STREAM_SOURCE_GZIP_WITH_FALLBACK); | |
| 1257 break; | |
| 1258 default: | |
| 1259 NOTREACHED(); | |
| 1260 return nullptr; | |
| 1261 } | |
| 1262 if (next == nullptr) | |
| 1263 return nullptr; | |
| 1264 previous = std::move(next); | |
| 1265 } | |
| 1266 return previous; | |
| 1227 } | 1267 } |
| 1228 | 1268 |
| 1229 bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const { | 1269 bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const { |
| 1230 // Allow modification of reference fragments by default, unless | 1270 // Allow modification of reference fragments by default, unless |
| 1231 // |allowed_unsafe_redirect_url_| is set and equal to the redirect URL. | 1271 // |allowed_unsafe_redirect_url_| is set and equal to the redirect URL. |
| 1232 // When this is the case, we assume that the network delegate has set the | 1272 // When this is the case, we assume that the network delegate has set the |
| 1233 // desired redirect URL (with or without fragment), so it must not be changed | 1273 // desired redirect URL (with or without fragment), so it must not be changed |
| 1234 // any more. | 1274 // any more. |
| 1235 return !allowed_unsafe_redirect_url_.is_valid() || | 1275 return !allowed_unsafe_redirect_url_.is_valid() || |
| 1236 allowed_unsafe_redirect_url_ != location; | 1276 allowed_unsafe_redirect_url_ != location; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1401 } | 1441 } |
| 1402 } | 1442 } |
| 1403 } | 1443 } |
| 1404 return false; | 1444 return false; |
| 1405 } | 1445 } |
| 1406 | 1446 |
| 1407 int URLRequestHttpJob::ReadRawData(IOBuffer* buf, int buf_size) { | 1447 int URLRequestHttpJob::ReadRawData(IOBuffer* buf, int buf_size) { |
| 1408 DCHECK_NE(buf_size, 0); | 1448 DCHECK_NE(buf_size, 0); |
| 1409 DCHECK(!read_in_progress_); | 1449 DCHECK(!read_in_progress_); |
| 1410 | 1450 |
| 1411 int rv = transaction_->Read( | 1451 int rv = transaction_->Read(buf, buf_size, |
| 1412 buf, buf_size, | 1452 base::Bind(&URLRequestHttpJob::OnReadCompleted, |
| 1413 base::Bind(&URLRequestHttpJob::OnReadCompleted, base::Unretained(this))); | 1453 weak_factory_.GetWeakPtr())); |
|
mmenke
2016/07/28 18:40:13
Is there a reason for switching to a weak_factory_
xunjieli
2016/08/01 16:46:23
Done. No reason. I think I changed that during deb
| |
| 1414 | 1454 |
| 1415 if (ShouldFixMismatchedContentLength(rv)) | 1455 if (ShouldFixMismatchedContentLength(rv)) |
| 1416 rv = OK; | 1456 rv = OK; |
| 1417 | 1457 |
| 1418 if (rv == 0 || (rv < 0 && rv != ERR_IO_PENDING)) | 1458 if (rv == 0 || (rv < 0 && rv != ERR_IO_PENDING)) |
| 1419 DoneWithRequest(FINISHED); | 1459 DoneWithRequest(FINISHED); |
| 1420 | 1460 |
| 1421 if (rv == ERR_IO_PENDING) | 1461 if (rv == ERR_IO_PENDING) |
| 1422 read_in_progress_ = true; | 1462 read_in_progress_ = true; |
| 1423 | 1463 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1515 | 1555 |
| 1516 base::Time now(base::Time::Now()); | 1556 base::Time now(base::Time::Now()); |
| 1517 if (!bytes_observed_in_packets_) | 1557 if (!bytes_observed_in_packets_) |
| 1518 request_time_snapshot_ = now; | 1558 request_time_snapshot_ = now; |
| 1519 final_packet_time_ = now; | 1559 final_packet_time_ = now; |
| 1520 | 1560 |
| 1521 bytes_observed_in_packets_ = prefilter_bytes_read(); | 1561 bytes_observed_in_packets_ = prefilter_bytes_read(); |
| 1522 } | 1562 } |
| 1523 | 1563 |
| 1524 void URLRequestHttpJob::RecordPacketStats( | 1564 void URLRequestHttpJob::RecordPacketStats( |
| 1525 FilterContext::StatisticSelector statistic) const { | 1565 SdchPolicyDelegate::Context::StatisticSelector statistic) const { |
| 1526 if (!packet_timing_enabled_ || (final_packet_time_ == base::Time())) | 1566 if (!packet_timing_enabled_ || (final_packet_time_ == base::Time())) |
| 1527 return; | 1567 return; |
| 1528 | 1568 |
| 1529 base::TimeDelta duration = final_packet_time_ - request_time_snapshot_; | 1569 base::TimeDelta duration = final_packet_time_ - request_time_snapshot_; |
| 1530 switch (statistic) { | 1570 switch (statistic) { |
| 1531 case FilterContext::SDCH_DECODE: { | 1571 case SdchPolicyDelegate::Context::StatisticSelector::SDCH_DECODE: { |
| 1532 UMA_HISTOGRAM_CUSTOM_COUNTS("Sdch3.Network_Decode_Bytes_Processed_b", | 1572 UMA_HISTOGRAM_CUSTOM_COUNTS("Sdch3.Network_Decode_Bytes_Processed_b", |
| 1533 static_cast<int>(bytes_observed_in_packets_), 500, 100000, 100); | 1573 static_cast<int>(bytes_observed_in_packets_), |
| 1574 500, 100000, 100); | |
| 1534 return; | 1575 return; |
| 1535 } | 1576 } |
| 1536 case FilterContext::SDCH_PASSTHROUGH: { | 1577 case SdchPolicyDelegate::Context::StatisticSelector::SDCH_PASSTHROUGH: { |
| 1537 // Despite advertising a dictionary, we handled non-sdch compressed | 1578 // Despite advertising a dictionary, we handled non-sdch compressed |
| 1538 // content. | 1579 // content. |
| 1539 return; | 1580 return; |
| 1540 } | 1581 } |
| 1541 | 1582 |
| 1542 case FilterContext::SDCH_EXPERIMENT_DECODE: { | 1583 case SdchPolicyDelegate::Context::SDCH_EXPERIMENT_DECODE: { |
| 1543 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment3_Decode", | 1584 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment3_Decode", duration, |
| 1544 duration, | 1585 base::TimeDelta::FromMilliseconds(20), |
| 1545 base::TimeDelta::FromMilliseconds(20), | 1586 base::TimeDelta::FromMinutes(10), 100); |
| 1546 base::TimeDelta::FromMinutes(10), 100); | |
| 1547 return; | 1587 return; |
| 1548 } | 1588 } |
| 1549 case FilterContext::SDCH_EXPERIMENT_HOLDBACK: { | 1589 case SdchPolicyDelegate::Context::SDCH_EXPERIMENT_HOLDBACK: { |
| 1550 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment3_Holdback", | 1590 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment3_Holdback", duration, |
| 1551 duration, | 1591 base::TimeDelta::FromMilliseconds(20), |
| 1552 base::TimeDelta::FromMilliseconds(20), | 1592 base::TimeDelta::FromMinutes(10), 100); |
| 1553 base::TimeDelta::FromMinutes(10), 100); | |
| 1554 return; | 1593 return; |
| 1555 } | 1594 } |
| 1556 default: | 1595 default: |
| 1557 NOTREACHED(); | 1596 NOTREACHED(); |
| 1558 return; | 1597 return; |
| 1559 } | 1598 } |
| 1560 } | 1599 } |
| 1561 | 1600 |
| 1562 void URLRequestHttpJob::RecordPerfHistograms(CompletionCause reason) { | 1601 void URLRequestHttpJob::RecordPerfHistograms(CompletionCause reason) { |
| 1563 if (start_time_.is_null()) | 1602 if (start_time_.is_null()) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1653 // Notify NetworkQualityEstimator. | 1692 // Notify NetworkQualityEstimator. |
| 1654 if (request()) { | 1693 if (request()) { |
| 1655 NetworkQualityEstimator* network_quality_estimator = | 1694 NetworkQualityEstimator* network_quality_estimator = |
| 1656 request()->context()->network_quality_estimator(); | 1695 request()->context()->network_quality_estimator(); |
| 1657 if (network_quality_estimator) | 1696 if (network_quality_estimator) |
| 1658 network_quality_estimator->NotifyURLRequestDestroyed(*request()); | 1697 network_quality_estimator->NotifyURLRequestDestroyed(*request()); |
| 1659 } | 1698 } |
| 1660 } | 1699 } |
| 1661 | 1700 |
| 1662 } // namespace net | 1701 } // namespace net |
| OLD | NEW |