| 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_source_stream.h" |
| 36 #include "net/filter/filter_source_stream.h" |
| 37 #include "net/filter/gzip_source_stream.h" |
| 38 #include "net/filter/sdch_source_stream.h" |
| 39 #include "net/filter/source_stream.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 10 matching lines...) Expand all Loading... |
| 55 #include "net/url_request/url_request_job_factory.h" | 60 #include "net/url_request/url_request_job_factory.h" |
| 56 #include "net/url_request/url_request_redirect_job.h" | 61 #include "net/url_request/url_request_redirect_job.h" |
| 57 #include "net/url_request/url_request_throttler_manager.h" | 62 #include "net/url_request/url_request_throttler_manager.h" |
| 58 #include "net/websockets/websocket_handshake_stream_base.h" | 63 #include "net/websockets/websocket_handshake_stream_base.h" |
| 59 #include "url/origin.h" | 64 #include "url/origin.h" |
| 60 | 65 |
| 61 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; | 66 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; |
| 62 | 67 |
| 63 namespace { | 68 namespace { |
| 64 | 69 |
| 70 const char kDeflate[] = "deflate"; |
| 71 const char kGZip[] = "gzip"; |
| 72 const char kSdch[] = "sdch"; |
| 73 const char kXGZip[] = "x-gzip"; |
| 74 const char kBrotli[] = "br"; |
| 75 |
| 65 // True if the request method is "safe" (per section 4.2.1 of RFC 7231). | 76 // True if the request method is "safe" (per section 4.2.1 of RFC 7231). |
| 66 bool IsMethodSafe(const std::string& method) { | 77 bool IsMethodSafe(const std::string& method) { |
| 67 return method == "GET" || method == "HEAD" || method == "OPTIONS" || | 78 return method == "GET" || method == "HEAD" || method == "OPTIONS" || |
| 68 method == "TRACE"; | 79 method == "TRACE"; |
| 69 } | 80 } |
| 70 | 81 |
| 71 // Logs whether the CookieStore used for this request matches the | 82 // Logs whether the CookieStore used for this request matches the |
| 72 // ChannelIDService used when establishing the connection that this request is | 83 // ChannelIDService used when establishing the connection that this request is |
| 73 // sent over. This logging is only done for requests to accounts.google.com, and | 84 // sent over. This logging is only done for requests to accounts.google.com, and |
| 74 // only for requests where Channel ID was sent when establishing the connection. | 85 // 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... |
| 171 return new net::URLRequestRedirectJob( | 182 return new net::URLRequestRedirectJob( |
| 172 request, network_delegate, url.ReplaceComponents(replacements), | 183 request, network_delegate, url.ReplaceComponents(replacements), |
| 173 // Use status code 307 to preserve the method, so POST requests work. | 184 // Use status code 307 to preserve the method, so POST requests work. |
| 174 net::URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT, "HSTS"); | 185 net::URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT, "HSTS"); |
| 175 } | 186 } |
| 176 | 187 |
| 177 } // namespace | 188 } // namespace |
| 178 | 189 |
| 179 namespace net { | 190 namespace net { |
| 180 | 191 |
| 181 class URLRequestHttpJob::HttpFilterContext : public FilterContext { | 192 class URLRequestHttpJob::SdchContext : public SdchPolicyDelegate::Context { |
| 182 public: | 193 public: |
| 183 explicit HttpFilterContext(URLRequestHttpJob* job); | 194 explicit SdchContext(URLRequestHttpJob* job); |
| 184 ~HttpFilterContext() override; | 195 ~SdchContext() override; |
| 185 | 196 // SdchPolicyDelegate::Context implementation |
| 186 // FilterContext implementation. | |
| 187 bool GetMimeType(std::string* mime_type) const override; | 197 bool GetMimeType(std::string* mime_type) const override; |
| 188 bool GetURL(GURL* gurl) const override; | 198 bool GetURL(GURL* url) const override; |
| 189 base::Time GetRequestTime() const override; | 199 // base::Time GetRequestTime() const override; |
| 190 bool IsCachedContent() const override; | 200 bool IsCachedContent() const override; |
| 201 SdchManager* GetSdchManager() const override; |
| 191 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override; | 202 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override; |
| 192 int64_t GetByteReadCount() const override; | 203 // int64_t GetByteReadCount() const override; |
| 193 int GetResponseCode() const override; | 204 int GetResponseCode() const override; |
| 194 const URLRequestContext* GetURLRequestContext() const override; | |
| 195 void RecordPacketStats(StatisticSelector statistic) const override; | |
| 196 const BoundNetLog& GetNetLog() const override; | 205 const BoundNetLog& GetNetLog() const override; |
| 197 | 206 |
| 198 private: | 207 private: |
| 208 // URLRequestHttpJob owns SdchPolicyDelegate which owns the context, so it |
| 209 // is okay to have a raw pointer reference to |job_|. |
| 199 URLRequestHttpJob* job_; | 210 URLRequestHttpJob* job_; |
| 200 | 211 |
| 201 // URLRequestHttpJob may be detached from URLRequest, but we still need to | 212 // URLRequestHttpJob may be detached from URLRequest, but still need to |
| 202 // return something. | 213 // return something. |
| 203 BoundNetLog dummy_log_; | 214 BoundNetLog dummy_log_; |
| 204 | 215 |
| 205 DISALLOW_COPY_AND_ASSIGN(HttpFilterContext); | 216 DISALLOW_COPY_AND_ASSIGN(SdchContext); |
| 206 }; | 217 }; |
| 207 | 218 |
| 208 URLRequestHttpJob::HttpFilterContext::HttpFilterContext(URLRequestHttpJob* job) | 219 URLRequestHttpJob::SdchContext::SdchContext(URLRequestHttpJob* job) |
| 209 : job_(job) { | 220 : job_(job) {} |
| 210 DCHECK(job_); | |
| 211 } | |
| 212 | 221 |
| 213 URLRequestHttpJob::HttpFilterContext::~HttpFilterContext() { | 222 URLRequestHttpJob::SdchContext::~SdchContext() {} |
| 214 } | |
| 215 | 223 |
| 216 bool URLRequestHttpJob::HttpFilterContext::GetMimeType( | 224 bool URLRequestHttpJob::SdchContext::GetMimeType(std::string* mime_type) const { |
| 217 std::string* mime_type) const { | |
| 218 return job_->GetMimeType(mime_type); | 225 return job_->GetMimeType(mime_type); |
| 219 } | 226 } |
| 220 | 227 |
| 221 bool URLRequestHttpJob::HttpFilterContext::GetURL(GURL* gurl) const { | 228 bool URLRequestHttpJob::SdchContext::GetURL(GURL* gurl) const { |
| 222 if (!job_->request()) | 229 if (!job_->request()) |
| 223 return false; | 230 return false; |
| 224 *gurl = job_->request()->url(); | 231 *gurl = job_->request()->url(); |
| 225 return true; | 232 return true; |
| 226 } | 233 } |
| 227 | 234 |
| 228 base::Time URLRequestHttpJob::HttpFilterContext::GetRequestTime() const { | 235 bool URLRequestHttpJob::SdchContext::IsCachedContent() const { |
| 229 return job_->request() ? job_->request()->request_time() : base::Time(); | |
| 230 } | |
| 231 | |
| 232 bool URLRequestHttpJob::HttpFilterContext::IsCachedContent() const { | |
| 233 return job_->is_cached_content_; | 236 return job_->is_cached_content_; |
| 234 } | 237 } |
| 235 | 238 |
| 239 SdchManager* URLRequestHttpJob::SdchContext::GetSdchManager() const { |
| 240 return job_->request() ? job_->request()->context()->sdch_manager() : nullptr; |
| 241 } |
| 242 |
| 236 SdchManager::DictionarySet* | 243 SdchManager::DictionarySet* |
| 237 URLRequestHttpJob::HttpFilterContext::SdchDictionariesAdvertised() const { | 244 URLRequestHttpJob::SdchContext::SdchDictionariesAdvertised() const { |
| 238 return job_->dictionaries_advertised_.get(); | 245 return job_->dictionaries_advertised_.get(); |
| 239 } | 246 } |
| 240 | 247 |
| 241 int64_t URLRequestHttpJob::HttpFilterContext::GetByteReadCount() const { | 248 int URLRequestHttpJob::SdchContext::GetResponseCode() const { |
| 242 return job_->prefilter_bytes_read(); | |
| 243 } | |
| 244 | |
| 245 int URLRequestHttpJob::HttpFilterContext::GetResponseCode() const { | |
| 246 return job_->GetResponseCode(); | 249 return job_->GetResponseCode(); |
| 247 } | 250 } |
| 248 | 251 |
| 249 const URLRequestContext* | 252 const BoundNetLog& URLRequestHttpJob::SdchContext::GetNetLog() const { |
| 250 URLRequestHttpJob::HttpFilterContext::GetURLRequestContext() const { | |
| 251 return job_->request() ? job_->request()->context() : NULL; | |
| 252 } | |
| 253 | |
| 254 void URLRequestHttpJob::HttpFilterContext::RecordPacketStats( | |
| 255 StatisticSelector statistic) const { | |
| 256 job_->RecordPacketStats(statistic); | |
| 257 } | |
| 258 | |
| 259 const BoundNetLog& URLRequestHttpJob::HttpFilterContext::GetNetLog() const { | |
| 260 return job_->request() ? job_->request()->net_log() : dummy_log_; | 253 return job_->request() ? job_->request()->net_log() : dummy_log_; |
| 261 } | 254 } |
| 262 | 255 |
| 263 // TODO(darin): make sure the port blocking code is not lost | 256 // TODO(darin): make sure the port blocking code is not lost |
| 264 // static | 257 // static |
| 265 URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request, | 258 URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request, |
| 266 NetworkDelegate* network_delegate, | 259 NetworkDelegate* network_delegate, |
| 267 const std::string& scheme) { | 260 const std::string& scheme) { |
| 268 DCHECK(scheme == "http" || scheme == "https" || scheme == "ws" || | 261 DCHECK(scheme == "http" || scheme == "https" || scheme == "ws" || |
| 269 scheme == "wss"); | 262 scheme == "wss"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 throttling_entry_(nullptr), | 295 throttling_entry_(nullptr), |
| 303 sdch_test_activated_(false), | 296 sdch_test_activated_(false), |
| 304 sdch_test_control_(false), | 297 sdch_test_control_(false), |
| 305 is_cached_content_(false), | 298 is_cached_content_(false), |
| 306 request_creation_time_(), | 299 request_creation_time_(), |
| 307 packet_timing_enabled_(false), | 300 packet_timing_enabled_(false), |
| 308 done_(false), | 301 done_(false), |
| 309 bytes_observed_in_packets_(0), | 302 bytes_observed_in_packets_(0), |
| 310 request_time_snapshot_(), | 303 request_time_snapshot_(), |
| 311 final_packet_time_(), | 304 final_packet_time_(), |
| 312 filter_context_(new HttpFilterContext(this)), | |
| 313 on_headers_received_callback_( | 305 on_headers_received_callback_( |
| 314 base::Bind(&URLRequestHttpJob::OnHeadersReceivedCallback, | 306 base::Bind(&URLRequestHttpJob::OnHeadersReceivedCallback, |
| 315 base::Unretained(this))), | 307 base::Unretained(this))), |
| 316 awaiting_callback_(false), | 308 awaiting_callback_(false), |
| 317 http_user_agent_settings_(http_user_agent_settings), | 309 http_user_agent_settings_(http_user_agent_settings), |
| 318 total_received_bytes_from_previous_transactions_(0), | 310 total_received_bytes_from_previous_transactions_(0), |
| 319 total_sent_bytes_from_previous_transactions_(0), | 311 total_sent_bytes_from_previous_transactions_(0), |
| 320 weak_factory_(this) { | 312 weak_factory_(this) { |
| 321 URLRequestThrottlerManager* manager = request->context()->throttler_manager(); | 313 URLRequestThrottlerManager* manager = request->context()->throttler_manager(); |
| 322 if (manager) | 314 if (manager) |
| 323 throttling_entry_ = manager->RegisterRequestUrl(request->url()); | 315 throttling_entry_ = manager->RegisterRequestUrl(request->url()); |
| 324 | 316 |
| 325 ResetTimer(); | 317 ResetTimer(); |
| 326 } | 318 } |
| 327 | 319 |
| 328 URLRequestHttpJob::~URLRequestHttpJob() { | 320 URLRequestHttpJob::~URLRequestHttpJob() { |
| 329 CHECK(!awaiting_callback_); | 321 CHECK(!awaiting_callback_); |
| 330 | 322 |
| 331 DCHECK(!sdch_test_control_ || !sdch_test_activated_); | 323 DCHECK(!sdch_test_control_ || !sdch_test_activated_); |
| 332 if (!is_cached_content_) { | 324 if (!is_cached_content_) { |
| 333 if (sdch_test_control_) | 325 if (sdch_test_control_) |
| 334 RecordPacketStats(FilterContext::SDCH_EXPERIMENT_HOLDBACK); | 326 RecordPacketStats(SdchPolicyDelegate::Context::SDCH_EXPERIMENT_HOLDBACK); |
| 335 if (sdch_test_activated_) | 327 if (sdch_test_activated_) |
| 336 RecordPacketStats(FilterContext::SDCH_EXPERIMENT_DECODE); | 328 RecordPacketStats(SdchPolicyDelegate::Context::SDCH_EXPERIMENT_DECODE); |
| 337 } | 329 } |
| 338 // Make sure SDCH filters are told to emit histogram data while | |
| 339 // filter_context_ is still alive. | |
| 340 DestroyFilters(); | |
| 341 | |
| 342 DoneWithRequest(ABORTED); | 330 DoneWithRequest(ABORTED); |
| 343 } | 331 } |
| 344 | 332 |
| 345 void URLRequestHttpJob::SetPriority(RequestPriority priority) { | 333 void URLRequestHttpJob::SetPriority(RequestPriority priority) { |
| 346 priority_ = priority; | 334 priority_ = priority; |
| 347 if (transaction_) | 335 if (transaction_) |
| 348 transaction_->SetPriority(priority_); | 336 transaction_->SetPriority(priority_); |
| 349 } | 337 } |
| 350 | 338 |
| 351 void URLRequestHttpJob::Start() { | 339 void URLRequestHttpJob::Start() { |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 return GetResponseHeaders()->response_code(); | 1139 return GetResponseHeaders()->response_code(); |
| 1152 } | 1140 } |
| 1153 | 1141 |
| 1154 void URLRequestHttpJob::PopulateNetErrorDetails( | 1142 void URLRequestHttpJob::PopulateNetErrorDetails( |
| 1155 NetErrorDetails* details) const { | 1143 NetErrorDetails* details) const { |
| 1156 if (!transaction_) | 1144 if (!transaction_) |
| 1157 return; | 1145 return; |
| 1158 return transaction_->PopulateNetErrorDetails(details); | 1146 return transaction_->PopulateNetErrorDetails(details); |
| 1159 } | 1147 } |
| 1160 | 1148 |
| 1161 std::unique_ptr<Filter> URLRequestHttpJob::SetupFilter() const { | 1149 std::unique_ptr<SourceStream> URLRequestHttpJob::SetUpSourceStream() { |
| 1162 DCHECK(transaction_.get()); | 1150 DCHECK(transaction_.get()); |
| 1163 if (!response_info_) | 1151 if (!response_info_) |
| 1164 return nullptr; | 1152 return nullptr; |
| 1165 | 1153 |
| 1166 std::vector<Filter::FilterType> encoding_types; | |
| 1167 std::string encoding_type; | |
| 1168 HttpResponseHeaders* headers = GetResponseHeaders(); | 1154 HttpResponseHeaders* headers = GetResponseHeaders(); |
| 1155 std::string type; |
| 1156 std::vector<SourceStream::SourceType> types; |
| 1169 size_t iter = 0; | 1157 size_t iter = 0; |
| 1170 while (headers->EnumerateHeader(&iter, "Content-Encoding", &encoding_type)) { | 1158 while (headers->EnumerateHeader(&iter, "Content-Encoding", &type)) { |
| 1171 encoding_types.push_back(Filter::ConvertEncodingToType(encoding_type)); | 1159 if (base::LowerCaseEqualsASCII(type, kBrotli)) { |
| 1160 types.push_back(SourceStream::TYPE_BROTLI); |
| 1161 } else if (base::LowerCaseEqualsASCII(type, kDeflate)) { |
| 1162 types.push_back(SourceStream::TYPE_DEFLATE); |
| 1163 } else if (base::LowerCaseEqualsASCII(type, kGZip) || |
| 1164 base::LowerCaseEqualsASCII(type, kXGZip)) { |
| 1165 types.push_back(SourceStream::TYPE_GZIP); |
| 1166 } else if (base::LowerCaseEqualsASCII(type, kSdch)) { |
| 1167 types.push_back(SourceStream::TYPE_SDCH); |
| 1168 } |
| 1172 } | 1169 } |
| 1173 | 1170 |
| 1174 // Even if encoding types are empty, there is a chance that we need to add | 1171 // SDCH-specific hack: if the first filter is SDCH, add a gzip filter in front |
| 1175 // some decoding, as some proxies strip encoding completely. In such cases, | 1172 // of it in fallback mode. |
| 1176 // we may need to add (for example) SDCH filtering (when the context suggests | 1173 // Some proxies (found currently in Argentina) strip the Content-Encoding |
| 1177 // it is appropriate). | 1174 // text from "sdch,gzip" to a mere "sdch" without modifying the compressed |
| 1178 Filter::FixupEncodingTypes(*filter_context_, &encoding_types); | 1175 // payload. To handle this gracefully, we simulate the "probably" deleted |
| 1176 // ",gzip" by appending a tentative gzip decode, which will default to a |
| 1177 // no-op pass through filter if it doesn't get gzip headers where expected. |
| 1178 if (types.size() == 1 && types.at(0) == SourceStream::TYPE_SDCH) { |
| 1179 types.insert(types.begin(), SourceStream::TYPE_GZIP_FALLBACK); |
| 1180 // TODO(xunjieli): Add UMA to see how common this is. |
| 1181 } |
| 1179 | 1182 |
| 1180 return !encoding_types.empty() | 1183 std::unique_ptr<SourceStream> upstream = URLRequestJob::SetUpSourceStream(); |
| 1181 ? Filter::Factory(encoding_types, *filter_context_) : NULL; | 1184 for (std::vector<SourceStream::SourceType>::reverse_iterator r_iter = |
| 1185 types.rbegin(); |
| 1186 r_iter != types.rend(); ++r_iter) { |
| 1187 std::unique_ptr<FilterSourceStream> downstream; |
| 1188 SourceStream::SourceType type = *r_iter; |
| 1189 switch (type) { |
| 1190 case SourceStream::TYPE_BROTLI: |
| 1191 downstream = CreateBrotliSourceStream(std::move(upstream)); |
| 1192 break; |
| 1193 case SourceStream::TYPE_SDCH: { |
| 1194 std::unique_ptr<SdchContext> context(new SdchContext(this)); |
| 1195 sdch_delegate_.reset(new SdchPolicyDelegate(std::move(context))); |
| 1196 downstream.reset( |
| 1197 new SdchSourceStream(std::move(upstream), sdch_delegate_.get())); |
| 1198 break; |
| 1199 } |
| 1200 case SourceStream::TYPE_GZIP: |
| 1201 downstream = GzipSourceStream::Create( |
| 1202 std::move(upstream), GzipSourceStream::GZIP_SOURCE_STREAM_GZIP); |
| 1203 break; |
| 1204 case SourceStream::TYPE_DEFLATE: |
| 1205 downstream = GzipSourceStream::Create( |
| 1206 std::move(upstream), GzipSourceStream::GZIP_SOURCE_STREAM_DEFLATE); |
| 1207 break; |
| 1208 case SourceStream::TYPE_GZIP_FALLBACK: |
| 1209 downstream = GzipSourceStream::Create( |
| 1210 std::move(upstream), |
| 1211 GzipSourceStream::GZIP_SOURCE_STREAM_GZIP_WITH_FALLBACK); |
| 1212 break; |
| 1213 default: |
| 1214 NOTREACHED(); |
| 1215 return nullptr; |
| 1216 } |
| 1217 if (downstream == nullptr) |
| 1218 return nullptr; |
| 1219 upstream = std::move(downstream); |
| 1220 } |
| 1221 return upstream; |
| 1182 } | 1222 } |
| 1183 | 1223 |
| 1184 bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const { | 1224 bool URLRequestHttpJob::CopyFragmentOnRedirect(const GURL& location) const { |
| 1185 // Allow modification of reference fragments by default, unless | 1225 // Allow modification of reference fragments by default, unless |
| 1186 // |allowed_unsafe_redirect_url_| is set and equal to the redirect URL. | 1226 // |allowed_unsafe_redirect_url_| is set and equal to the redirect URL. |
| 1187 // When this is the case, we assume that the network delegate has set the | 1227 // When this is the case, we assume that the network delegate has set the |
| 1188 // desired redirect URL (with or without fragment), so it must not be changed | 1228 // desired redirect URL (with or without fragment), so it must not be changed |
| 1189 // any more. | 1229 // any more. |
| 1190 return !allowed_unsafe_redirect_url_.is_valid() || | 1230 return !allowed_unsafe_redirect_url_.is_valid() || |
| 1191 allowed_unsafe_redirect_url_ != location; | 1231 allowed_unsafe_redirect_url_ != location; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 | 1510 |
| 1471 base::Time now(base::Time::Now()); | 1511 base::Time now(base::Time::Now()); |
| 1472 if (!bytes_observed_in_packets_) | 1512 if (!bytes_observed_in_packets_) |
| 1473 request_time_snapshot_ = now; | 1513 request_time_snapshot_ = now; |
| 1474 final_packet_time_ = now; | 1514 final_packet_time_ = now; |
| 1475 | 1515 |
| 1476 bytes_observed_in_packets_ = prefilter_bytes_read(); | 1516 bytes_observed_in_packets_ = prefilter_bytes_read(); |
| 1477 } | 1517 } |
| 1478 | 1518 |
| 1479 void URLRequestHttpJob::RecordPacketStats( | 1519 void URLRequestHttpJob::RecordPacketStats( |
| 1480 FilterContext::StatisticSelector statistic) const { | 1520 SdchPolicyDelegate::Context::StatisticSelector statistic) const { |
| 1481 if (!packet_timing_enabled_ || (final_packet_time_ == base::Time())) | 1521 if (!packet_timing_enabled_ || (final_packet_time_ == base::Time())) |
| 1482 return; | 1522 return; |
| 1483 | 1523 |
| 1484 base::TimeDelta duration = final_packet_time_ - request_time_snapshot_; | 1524 base::TimeDelta duration = final_packet_time_ - request_time_snapshot_; |
| 1485 switch (statistic) { | 1525 switch (statistic) { |
| 1486 case FilterContext::SDCH_DECODE: { | 1526 case SdchPolicyDelegate::Context::StatisticSelector::SDCH_DECODE: { |
| 1487 UMA_HISTOGRAM_CUSTOM_COUNTS("Sdch3.Network_Decode_Bytes_Processed_b", | 1527 UMA_HISTOGRAM_CUSTOM_COUNTS("Sdch3.Network_Decode_Bytes_Processed_b", |
| 1488 static_cast<int>(bytes_observed_in_packets_), 500, 100000, 100); | 1528 static_cast<int>(bytes_observed_in_packets_), |
| 1529 500, 100000, 100); |
| 1489 return; | 1530 return; |
| 1490 } | 1531 } |
| 1491 case FilterContext::SDCH_PASSTHROUGH: { | 1532 case SdchPolicyDelegate::Context::StatisticSelector::SDCH_PASSTHROUGH: { |
| 1492 // Despite advertising a dictionary, we handled non-sdch compressed | 1533 // Despite advertising a dictionary, we handled non-sdch compressed |
| 1493 // content. | 1534 // content. |
| 1494 return; | 1535 return; |
| 1495 } | 1536 } |
| 1496 | 1537 |
| 1497 case FilterContext::SDCH_EXPERIMENT_DECODE: { | 1538 case SdchPolicyDelegate::Context::SDCH_EXPERIMENT_DECODE: { |
| 1498 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment3_Decode", | 1539 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment3_Decode", duration, |
| 1499 duration, | 1540 base::TimeDelta::FromMilliseconds(20), |
| 1500 base::TimeDelta::FromMilliseconds(20), | 1541 base::TimeDelta::FromMinutes(10), 100); |
| 1501 base::TimeDelta::FromMinutes(10), 100); | |
| 1502 return; | 1542 return; |
| 1503 } | 1543 } |
| 1504 case FilterContext::SDCH_EXPERIMENT_HOLDBACK: { | 1544 case SdchPolicyDelegate::Context::SDCH_EXPERIMENT_HOLDBACK: { |
| 1505 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment3_Holdback", | 1545 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment3_Holdback", duration, |
| 1506 duration, | 1546 base::TimeDelta::FromMilliseconds(20), |
| 1507 base::TimeDelta::FromMilliseconds(20), | 1547 base::TimeDelta::FromMinutes(10), 100); |
| 1508 base::TimeDelta::FromMinutes(10), 100); | |
| 1509 return; | 1548 return; |
| 1510 } | 1549 } |
| 1511 default: | 1550 default: |
| 1512 NOTREACHED(); | 1551 NOTREACHED(); |
| 1513 return; | 1552 return; |
| 1514 } | 1553 } |
| 1515 } | 1554 } |
| 1516 | 1555 |
| 1517 void URLRequestHttpJob::RecordPerfHistograms(CompletionCause reason) { | 1556 void URLRequestHttpJob::RecordPerfHistograms(CompletionCause reason) { |
| 1518 if (start_time_.is_null()) | 1557 if (start_time_.is_null()) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 // Notify NetworkQualityEstimator. | 1647 // Notify NetworkQualityEstimator. |
| 1609 if (request()) { | 1648 if (request()) { |
| 1610 NetworkQualityEstimator* network_quality_estimator = | 1649 NetworkQualityEstimator* network_quality_estimator = |
| 1611 request()->context()->network_quality_estimator(); | 1650 request()->context()->network_quality_estimator(); |
| 1612 if (network_quality_estimator) | 1651 if (network_quality_estimator) |
| 1613 network_quality_estimator->NotifyURLRequestDestroyed(*request()); | 1652 network_quality_estimator->NotifyURLRequestDestroyed(*request()); |
| 1614 } | 1653 } |
| 1615 } | 1654 } |
| 1616 | 1655 |
| 1617 } // namespace net | 1656 } // namespace net |
| OLD | NEW |