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

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: Fix components_unittests Created 4 years, 5 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 14 matching lines...) Expand all
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
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
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
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
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 riter =
mmenke 2016/07/21 18:14:09 r_iter? riter seems too much a misspelling of wri
xunjieli 2016/07/27 20:32:04 Done.
1230 types.rbegin();
1231 riter != types.rend(); ++riter) {
1232 std::unique_ptr<FilterStreamSource> next = nullptr;
1233 StreamSource::SourceType type = *riter;
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.reset(new GzipStreamSource(
1247 std::move(previous), GzipStreamSource::GZIP_STREAM_SOURCE_GZIP));
1248 break;
1249 case StreamSource::TYPE_DEFLATE:
1250 next.reset(new GzipStreamSource(
1251 std::move(previous), GzipStreamSource::GZIP_STREAM_SOURCE_DEFLATE));
1252 break;
1253 case StreamSource::TYPE_GZIP_FALLBACK:
1254 next.reset(new GzipStreamSource(
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 || !next->Init())
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 } 1442 }
1403 } 1443 }
1404 } 1444 }
1405 return false; 1445 return false;
1406 } 1446 }
1407 1447
1408 int URLRequestHttpJob::ReadRawData(IOBuffer* buf, int buf_size) { 1448 int URLRequestHttpJob::ReadRawData(IOBuffer* buf, int buf_size) {
1409 DCHECK_NE(buf_size, 0); 1449 DCHECK_NE(buf_size, 0);
1410 DCHECK(!read_in_progress_); 1450 DCHECK(!read_in_progress_);
1411 1451
1412 int rv = transaction_->Read( 1452 int rv = transaction_->Read(buf, buf_size,
1413 buf, buf_size, 1453 base::Bind(&URLRequestHttpJob::OnReadCompleted,
1414 base::Bind(&URLRequestHttpJob::OnReadCompleted, base::Unretained(this))); 1454 weak_factory_.GetWeakPtr()));
1415 1455
1416 if (ShouldFixMismatchedContentLength(rv)) 1456 if (ShouldFixMismatchedContentLength(rv))
1417 rv = OK; 1457 rv = OK;
1418 1458
1419 if (rv == 0 || (rv < 0 && rv != ERR_IO_PENDING)) 1459 if (rv == 0 || (rv < 0 && rv != ERR_IO_PENDING))
1420 DoneWithRequest(FINISHED); 1460 DoneWithRequest(FINISHED);
1421 1461
1422 if (rv == ERR_IO_PENDING) 1462 if (rv == ERR_IO_PENDING)
1423 read_in_progress_ = true; 1463 read_in_progress_ = true;
1424 1464
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 1552
1513 base::Time now(base::Time::Now()); 1553 base::Time now(base::Time::Now());
1514 if (!bytes_observed_in_packets_) 1554 if (!bytes_observed_in_packets_)
1515 request_time_snapshot_ = now; 1555 request_time_snapshot_ = now;
1516 final_packet_time_ = now; 1556 final_packet_time_ = now;
1517 1557
1518 bytes_observed_in_packets_ = prefilter_bytes_read(); 1558 bytes_observed_in_packets_ = prefilter_bytes_read();
1519 } 1559 }
1520 1560
1521 void URLRequestHttpJob::RecordPacketStats( 1561 void URLRequestHttpJob::RecordPacketStats(
1522 FilterContext::StatisticSelector statistic) const { 1562 SdchPolicyDelegate::Context::StatisticSelector statistic) const {
1523 if (!packet_timing_enabled_ || (final_packet_time_ == base::Time())) 1563 if (!packet_timing_enabled_ || (final_packet_time_ == base::Time()))
1524 return; 1564 return;
1525 1565
1526 base::TimeDelta duration = final_packet_time_ - request_time_snapshot_; 1566 base::TimeDelta duration = final_packet_time_ - request_time_snapshot_;
1527 switch (statistic) { 1567 switch (statistic) {
1528 case FilterContext::SDCH_DECODE: { 1568 case SdchPolicyDelegate::Context::StatisticSelector::SDCH_DECODE: {
1529 UMA_HISTOGRAM_CUSTOM_COUNTS("Sdch3.Network_Decode_Bytes_Processed_b", 1569 UMA_HISTOGRAM_CUSTOM_COUNTS("Sdch3.Network_Decode_Bytes_Processed_b",
1530 static_cast<int>(bytes_observed_in_packets_), 500, 100000, 100); 1570 static_cast<int>(bytes_observed_in_packets_),
1571 500, 100000, 100);
1531 return; 1572 return;
1532 } 1573 }
1533 case FilterContext::SDCH_PASSTHROUGH: { 1574 case SdchPolicyDelegate::Context::StatisticSelector::SDCH_PASSTHROUGH: {
1534 // Despite advertising a dictionary, we handled non-sdch compressed 1575 // Despite advertising a dictionary, we handled non-sdch compressed
1535 // content. 1576 // content.
1536 return; 1577 return;
1537 } 1578 }
1538 1579
1539 case FilterContext::SDCH_EXPERIMENT_DECODE: { 1580 case SdchPolicyDelegate::Context::SDCH_EXPERIMENT_DECODE: {
1540 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment3_Decode", 1581 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment3_Decode", duration,
1541 duration, 1582 base::TimeDelta::FromMilliseconds(20),
1542 base::TimeDelta::FromMilliseconds(20), 1583 base::TimeDelta::FromMinutes(10), 100);
1543 base::TimeDelta::FromMinutes(10), 100);
1544 return; 1584 return;
1545 } 1585 }
1546 case FilterContext::SDCH_EXPERIMENT_HOLDBACK: { 1586 case SdchPolicyDelegate::Context::SDCH_EXPERIMENT_HOLDBACK: {
1547 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment3_Holdback", 1587 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment3_Holdback", duration,
1548 duration, 1588 base::TimeDelta::FromMilliseconds(20),
1549 base::TimeDelta::FromMilliseconds(20), 1589 base::TimeDelta::FromMinutes(10), 100);
1550 base::TimeDelta::FromMinutes(10), 100);
1551 return; 1590 return;
1552 } 1591 }
1553 default: 1592 default:
1554 NOTREACHED(); 1593 NOTREACHED();
1555 return; 1594 return;
1556 } 1595 }
1557 } 1596 }
1558 1597
1559 void URLRequestHttpJob::RecordPerfHistograms(CompletionCause reason) { 1598 void URLRequestHttpJob::RecordPerfHistograms(CompletionCause reason) {
1560 if (start_time_.is_null()) 1599 if (start_time_.is_null())
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 // Notify NetworkQualityEstimator. 1689 // Notify NetworkQualityEstimator.
1651 if (request()) { 1690 if (request()) {
1652 NetworkQualityEstimator* network_quality_estimator = 1691 NetworkQualityEstimator* network_quality_estimator =
1653 request()->context()->network_quality_estimator(); 1692 request()->context()->network_quality_estimator();
1654 if (network_quality_estimator) 1693 if (network_quality_estimator)
1655 network_quality_estimator->NotifyURLRequestDestroyed(*request()); 1694 network_quality_estimator->NotifyURLRequestDestroyed(*request());
1656 } 1695 }
1657 } 1696 }
1658 1697
1659 } // namespace net 1698 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698