| OLD | NEW |
| 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 10 matching lines...) Expand all Loading... |
| 21 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 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/trace_constants.h" |
| 31 #include "net/base/url_util.h" | 32 #include "net/base/url_util.h" |
| 32 #include "net/http/http_response_headers.h" | 33 #include "net/http/http_response_headers.h" |
| 33 #include "net/http/http_response_info.h" | 34 #include "net/http/http_response_info.h" |
| 34 #include "net/http/http_status_code.h" | 35 #include "net/http/http_status_code.h" |
| 35 #include "net/nqe/network_quality_estimator_params.h" | 36 #include "net/nqe/network_quality_estimator_params.h" |
| 36 #include "net/nqe/socket_watcher_factory.h" | 37 #include "net/nqe/socket_watcher_factory.h" |
| 37 #include "net/nqe/throughput_analyzer.h" | 38 #include "net/nqe/throughput_analyzer.h" |
| 38 #include "net/url_request/url_request.h" | 39 #include "net/url_request/url_request.h" |
| 39 #include "net/url_request/url_request_status.h" | 40 #include "net/url_request/url_request_status.h" |
| 40 #include "url/gurl.h" | 41 #include "url/gurl.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 const URLRequest& request) { | 361 const URLRequest& request) { |
| 361 DCHECK(thread_checker_.CalledOnValidThread()); | 362 DCHECK(thread_checker_.CalledOnValidThread()); |
| 362 | 363 |
| 363 if (!RequestSchemeIsHTTPOrHTTPS(request)) | 364 if (!RequestSchemeIsHTTPOrHTTPS(request)) |
| 364 return; | 365 return; |
| 365 | 366 |
| 366 throughput_analyzer_->NotifyStartTransaction(request); | 367 throughput_analyzer_->NotifyStartTransaction(request); |
| 367 } | 368 } |
| 368 | 369 |
| 369 void NetworkQualityEstimator::NotifyHeadersReceived(const URLRequest& request) { | 370 void NetworkQualityEstimator::NotifyHeadersReceived(const URLRequest& request) { |
| 370 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 371 TRACE_EVENT0(kNetTracingCategory, |
| 371 "NetworkQualityEstimator::NotifyHeadersReceived"); | 372 "NetworkQualityEstimator::NotifyHeadersReceived"); |
| 372 DCHECK(thread_checker_.CalledOnValidThread()); | 373 DCHECK(thread_checker_.CalledOnValidThread()); |
| 373 | 374 |
| 374 if (!RequestSchemeIsHTTPOrHTTPS(request) || | 375 if (!RequestSchemeIsHTTPOrHTTPS(request) || |
| 375 !RequestProvidesRTTObservation(request)) { | 376 !RequestProvidesRTTObservation(request)) { |
| 376 return; | 377 return; |
| 377 } | 378 } |
| 378 | 379 |
| 379 const base::TimeTicks now = tick_clock_->NowTicks(); | 380 const base::TimeTicks now = tick_clock_->NowTicks(); |
| 380 | 381 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 recent_http_rtt.InMilliseconds(); | 528 recent_http_rtt.InMilliseconds(); |
| 528 | 529 |
| 529 RecordRTTAccuracy("NQE.ExternalEstimateProvider.RTT.Accuracy", | 530 RecordRTTAccuracy("NQE.ExternalEstimateProvider.RTT.Accuracy", |
| 530 estimated_observed_diff_milliseconds, measuring_duration, | 531 estimated_observed_diff_milliseconds, measuring_duration, |
| 531 recent_http_rtt); | 532 recent_http_rtt); |
| 532 } | 533 } |
| 533 } | 534 } |
| 534 | 535 |
| 535 void NetworkQualityEstimator::NotifyRequestCompleted(const URLRequest& request, | 536 void NetworkQualityEstimator::NotifyRequestCompleted(const URLRequest& request, |
| 536 int net_error) { | 537 int net_error) { |
| 537 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 538 TRACE_EVENT0(kNetTracingCategory, |
| 538 "NetworkQualityEstimator::NotifyRequestCompleted"); | 539 "NetworkQualityEstimator::NotifyRequestCompleted"); |
| 539 DCHECK(thread_checker_.CalledOnValidThread()); | 540 DCHECK(thread_checker_.CalledOnValidThread()); |
| 540 | 541 |
| 541 if (!RequestSchemeIsHTTPOrHTTPS(request)) | 542 if (!RequestSchemeIsHTTPOrHTTPS(request)) |
| 542 return; | 543 return; |
| 543 | 544 |
| 544 throughput_analyzer_->NotifyRequestCompleted(request); | 545 throughput_analyzer_->NotifyRequestCompleted(request); |
| 545 RecordCorrelationMetric(request, net_error); | 546 RecordCorrelationMetric(request, net_error); |
| 546 } | 547 } |
| 547 | 548 |
| (...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 void NetworkQualityEstimator::OnPrefsRead( | 1559 void NetworkQualityEstimator::OnPrefsRead( |
| 1559 const std::map<nqe::internal::NetworkID, | 1560 const std::map<nqe::internal::NetworkID, |
| 1560 nqe::internal::CachedNetworkQuality> read_prefs) { | 1561 nqe::internal::CachedNetworkQuality> read_prefs) { |
| 1561 DCHECK(thread_checker_.CalledOnValidThread()); | 1562 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1562 UMA_HISTOGRAM_COUNTS("NQE.Prefs.ReadSize", read_prefs.size()); | 1563 UMA_HISTOGRAM_COUNTS("NQE.Prefs.ReadSize", read_prefs.size()); |
| 1563 // TODO(tbansal): crbug.com/490870. Incorporate the network quality into the | 1564 // TODO(tbansal): crbug.com/490870. Incorporate the network quality into the |
| 1564 // current estimates. | 1565 // current estimates. |
| 1565 } | 1566 } |
| 1566 | 1567 |
| 1567 } // namespace net | 1568 } // namespace net |
| OLD | NEW |