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

Side by Side Diff: net/nqe/network_quality_estimator.cc

Issue 2486033002: NQE: Use ResponseHeaders to get the HTTP status code (Closed)
Patch Set: cleanup Created 4 years, 1 month 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
« no previous file with comments | « no previous file | net/nqe/network_quality_estimator_test_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/nqe/network_quality_estimator.h" 5 #include "net/nqe/network_quality_estimator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
(...skipping 11 matching lines...) Expand all
22 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "base/threading/thread_task_runner_handle.h" 24 #include "base/threading/thread_task_runner_handle.h"
25 #include "base/time/default_tick_clock.h" 25 #include "base/time/default_tick_clock.h"
26 #include "base/trace_event/trace_event.h" 26 #include "base/trace_event/trace_event.h"
27 #include "build/build_config.h" 27 #include "build/build_config.h"
28 #include "net/base/load_flags.h" 28 #include "net/base/load_flags.h"
29 #include "net/base/load_timing_info.h" 29 #include "net/base/load_timing_info.h"
30 #include "net/base/network_interfaces.h" 30 #include "net/base/network_interfaces.h"
31 #include "net/base/url_util.h" 31 #include "net/base/url_util.h"
32 #include "net/http/http_response_headers.h"
33 #include "net/http/http_response_info.h"
32 #include "net/http/http_status_code.h" 34 #include "net/http/http_status_code.h"
33 #include "net/nqe/network_quality_estimator_params.h" 35 #include "net/nqe/network_quality_estimator_params.h"
34 #include "net/nqe/socket_watcher_factory.h" 36 #include "net/nqe/socket_watcher_factory.h"
35 #include "net/nqe/throughput_analyzer.h" 37 #include "net/nqe/throughput_analyzer.h"
36 #include "net/url_request/url_request.h" 38 #include "net/url_request/url_request.h"
37 #include "net/url_request/url_request_status.h" 39 #include "net/url_request/url_request_status.h"
38 #include "url/gurl.h" 40 #include "url/gurl.h"
39 41
40 #if defined(OS_ANDROID) 42 #if defined(OS_ANDROID)
41 #include "net/android/cellular_signal_strength.h" 43 #include "net/android/cellular_signal_strength.h"
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 // If the load timing info is unavailable, it probably means that the request 565 // If the load timing info is unavailable, it probably means that the request
564 // did not go over the network. 566 // did not go over the network.
565 if (load_timing_info.send_start.is_null() || 567 if (load_timing_info.send_start.is_null() ||
566 load_timing_info.receive_headers_end.is_null()) { 568 load_timing_info.receive_headers_end.is_null()) {
567 return; 569 return;
568 } 570 }
569 571
570 // Record UMA only for successful requests that have completed. 572 // Record UMA only for successful requests that have completed.
571 if (net_error != OK) 573 if (net_error != OK)
572 return; 574 return;
573 if (request.GetResponseCode() != HTTP_OK) 575 if (!request.response_info().headers.get() ||
576 request.response_info().headers->response_code() != HTTP_OK) {
574 return; 577 return;
578 }
575 if (load_timing_info.receive_headers_end < last_main_frame_request_) 579 if (load_timing_info.receive_headers_end < last_main_frame_request_)
576 return; 580 return;
577 581
578 const base::TimeTicks now = tick_clock_->NowTicks(); 582 const base::TimeTicks now = tick_clock_->NowTicks();
579 // Record UMA only for requests that started recently. 583 // Record UMA only for requests that started recently.
580 if (now - last_main_frame_request_ > base::TimeDelta::FromSeconds(15)) 584 if (now - last_main_frame_request_ > base::TimeDelta::FromSeconds(15))
581 return; 585 return;
582 586
583 DCHECK_GE(now, load_timing_info.send_start); 587 DCHECK_GE(now, load_timing_info.send_start);
584 588
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 void NetworkQualityEstimator::OnPrefsRead( 1518 void NetworkQualityEstimator::OnPrefsRead(
1515 const std::map<nqe::internal::NetworkID, 1519 const std::map<nqe::internal::NetworkID,
1516 nqe::internal::CachedNetworkQuality> read_prefs) { 1520 nqe::internal::CachedNetworkQuality> read_prefs) {
1517 DCHECK(thread_checker_.CalledOnValidThread()); 1521 DCHECK(thread_checker_.CalledOnValidThread());
1518 UMA_HISTOGRAM_COUNTS("NQE.Prefs.ReadSize", read_prefs.size()); 1522 UMA_HISTOGRAM_COUNTS("NQE.Prefs.ReadSize", read_prefs.size());
1519 // TODO(tbansal): crbug.com/490870. Incorporate the network quality into the 1523 // TODO(tbansal): crbug.com/490870. Incorporate the network quality into the
1520 // current estimates. 1524 // current estimates.
1521 } 1525 }
1522 1526
1523 } // namespace net 1527 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/nqe/network_quality_estimator_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698