| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 149 } |
| 150 NOTREACHED(); | 150 NOTREACHED(); |
| 151 return net::NETWORK_QUALITY_OBSERVATION_SOURCE_TCP; | 151 return net::NETWORK_QUALITY_OBSERVATION_SOURCE_TCP; |
| 152 } | 152 } |
| 153 | 153 |
| 154 // Returns true if the scheme of the |request| is either HTTP or HTTPS. | 154 // Returns true if the scheme of the |request| is either HTTP or HTTPS. |
| 155 bool RequestSchemeIsHTTPOrHTTPS(const net::URLRequest& request) { | 155 bool RequestSchemeIsHTTPOrHTTPS(const net::URLRequest& request) { |
| 156 return request.url().is_valid() && request.url().SchemeIsHTTPOrHTTPS(); | 156 return request.url().is_valid() && request.url().SchemeIsHTTPOrHTTPS(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // Returns the suffix of the histogram that should be used for recording the |
| 160 // accuracy when the observed RTT is |observed_rtt|. The width of the intervals |
| 161 // are in exponentially increasing order. |
| 162 std::string GetHistogramSuffixObservedRTT(const base::TimeDelta& observed_rtt) { |
| 163 const float rtt_milliseconds = observed_rtt.InMillisecondsF(); |
| 164 DCHECK_GE(rtt_milliseconds, 0); |
| 165 |
| 166 // The values here should remain synchronized with the suffixes specified in |
| 167 // histograms.xml. |
| 168 static const char* const kSuffixes[] = { |
| 169 "0_20", "20_60", "60_140", "140_300", "300_620", |
| 170 "620_1260", "1260_2540", "2540_5100", "5100_Infinity"}; |
| 171 for (size_t i = 0; i < arraysize(kSuffixes) - 1; ++i) { |
| 172 if (rtt_milliseconds <= static_cast<float>((20 * (2 << i) - 20))) |
| 173 return kSuffixes[i]; |
| 174 } |
| 175 return kSuffixes[arraysize(kSuffixes) - 1]; |
| 176 } |
| 177 |
| 159 } // namespace | 178 } // namespace |
| 160 | 179 |
| 161 namespace net { | 180 namespace net { |
| 162 | 181 |
| 163 NetworkQualityEstimator::NetworkQualityEstimator( | 182 NetworkQualityEstimator::NetworkQualityEstimator( |
| 164 std::unique_ptr<ExternalEstimateProvider> external_estimates_provider, | 183 std::unique_ptr<ExternalEstimateProvider> external_estimates_provider, |
| 165 const std::map<std::string, std::string>& variation_params) | 184 const std::map<std::string, std::string>& variation_params) |
| 166 : NetworkQualityEstimator(std::move(external_estimates_provider), | 185 : NetworkQualityEstimator(std::move(external_estimates_provider), |
| 167 variation_params, | 186 variation_params, |
| 168 false, | 187 false, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 throughput_analyzer_.reset(new nqe::internal::ThroughputAnalyzer( | 234 throughput_analyzer_.reset(new nqe::internal::ThroughputAnalyzer( |
| 216 base::ThreadTaskRunnerHandle::Get(), | 235 base::ThreadTaskRunnerHandle::Get(), |
| 217 base::Bind(&NetworkQualityEstimator::OnNewThroughputObservationAvailable, | 236 base::Bind(&NetworkQualityEstimator::OnNewThroughputObservationAvailable, |
| 218 base::Unretained(this)), | 237 base::Unretained(this)), |
| 219 use_localhost_requests_, use_smaller_responses_for_tests)); | 238 use_localhost_requests_, use_smaller_responses_for_tests)); |
| 220 | 239 |
| 221 watcher_factory_.reset(new nqe::internal::SocketWatcherFactory( | 240 watcher_factory_.reset(new nqe::internal::SocketWatcherFactory( |
| 222 base::ThreadTaskRunnerHandle::Get(), | 241 base::ThreadTaskRunnerHandle::Get(), |
| 223 base::Bind(&NetworkQualityEstimator::OnUpdatedRTTAvailable, | 242 base::Bind(&NetworkQualityEstimator::OnUpdatedRTTAvailable, |
| 224 base::Unretained(this)))); | 243 base::Unretained(this)))); |
| 244 |
| 245 // Record accuracy at 3 different intervals. The values used here must remain |
| 246 // in sync with the suffixes specified in |
| 247 // tools/metrics/histograms/histograms.xml. |
| 248 accuracy_recording_intervals_.push_back(base::TimeDelta::FromSeconds(15)); |
| 249 accuracy_recording_intervals_.push_back(base::TimeDelta::FromSeconds(30)); |
| 250 accuracy_recording_intervals_.push_back(base::TimeDelta::FromSeconds(60)); |
| 225 } | 251 } |
| 226 | 252 |
| 227 void NetworkQualityEstimator::ObtainOperatingParams( | 253 void NetworkQualityEstimator::ObtainOperatingParams( |
| 228 const std::map<std::string, std::string>& variation_params) { | 254 const std::map<std::string, std::string>& variation_params) { |
| 229 DCHECK(thread_checker_.CalledOnValidThread()); | 255 DCHECK(thread_checker_.CalledOnValidThread()); |
| 230 | 256 |
| 231 for (size_t i = 0; i <= NetworkChangeNotifier::CONNECTION_LAST; ++i) { | 257 for (size_t i = 0; i <= NetworkChangeNotifier::CONNECTION_LAST; ++i) { |
| 232 NetworkChangeNotifier::ConnectionType type = | 258 NetworkChangeNotifier::ConnectionType type = |
| 233 static_cast<NetworkChangeNotifier::ConnectionType>(i); | 259 static_cast<NetworkChangeNotifier::ConnectionType>(i); |
| 234 DCHECK_EQ(nqe::internal::InvalidRTT(), default_observations_[i].http_rtt()); | 260 DCHECK_EQ(nqe::internal::InvalidRTT(), default_observations_[i].http_rtt()); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 throughput_observation); | 376 throughput_observation); |
| 351 NotifyObserversOfThroughput(throughput_observation); | 377 NotifyObserversOfThroughput(throughput_observation); |
| 352 } | 378 } |
| 353 } | 379 } |
| 354 | 380 |
| 355 NetworkQualityEstimator::~NetworkQualityEstimator() { | 381 NetworkQualityEstimator::~NetworkQualityEstimator() { |
| 356 DCHECK(thread_checker_.CalledOnValidThread()); | 382 DCHECK(thread_checker_.CalledOnValidThread()); |
| 357 NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 383 NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
| 358 } | 384 } |
| 359 | 385 |
| 386 const std::vector<base::TimeDelta>& |
| 387 NetworkQualityEstimator::GetAccuracyRecordingIntervals() const { |
| 388 DCHECK(thread_checker_.CalledOnValidThread()); |
| 389 return accuracy_recording_intervals_; |
| 390 } |
| 391 |
| 360 void NetworkQualityEstimator::NotifyStartTransaction( | 392 void NetworkQualityEstimator::NotifyStartTransaction( |
| 361 const URLRequest& request) { | 393 const URLRequest& request) { |
| 362 DCHECK(thread_checker_.CalledOnValidThread()); | 394 DCHECK(thread_checker_.CalledOnValidThread()); |
| 363 | 395 |
| 364 if (!RequestSchemeIsHTTPOrHTTPS(request)) | 396 if (!RequestSchemeIsHTTPOrHTTPS(request)) |
| 365 return; | 397 return; |
| 366 | 398 |
| 367 throughput_analyzer_->NotifyStartTransaction(request); | 399 throughput_analyzer_->NotifyStartTransaction(request); |
| 368 } | 400 } |
| 369 | 401 |
| 370 void NetworkQualityEstimator::NotifyHeadersReceived(const URLRequest& request) { | 402 void NetworkQualityEstimator::NotifyHeadersReceived(const URLRequest& request) { |
| 371 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 403 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
| 372 "NetworkQualityEstimator::NotifyHeadersReceived"); | 404 "NetworkQualityEstimator::NotifyHeadersReceived"); |
| 373 DCHECK(thread_checker_.CalledOnValidThread()); | 405 DCHECK(thread_checker_.CalledOnValidThread()); |
| 374 | 406 |
| 375 if (!RequestSchemeIsHTTPOrHTTPS(request) || | 407 if (!RequestSchemeIsHTTPOrHTTPS(request) || |
| 376 !RequestProvidesRTTObservation(request)) { | 408 !RequestProvidesRTTObservation(request)) { |
| 377 return; | 409 return; |
| 378 } | 410 } |
| 379 | 411 |
| 380 // Update |estimated_median_network_quality_| if this is a main frame request. | 412 const base::TimeTicks now = tick_clock_->NowTicks(); |
| 413 |
| 414 // Update |estimated_quality_at_last_main_frame_| if this is a main frame |
| 415 // request. |
| 381 if (request.load_flags() & LOAD_MAIN_FRAME) { | 416 if (request.load_flags() & LOAD_MAIN_FRAME) { |
| 417 last_main_frame_request_ = now; |
| 382 base::TimeDelta estimated_http_rtt; | 418 base::TimeDelta estimated_http_rtt; |
| 383 if (!GetHttpRTTEstimate(&estimated_http_rtt)) | 419 if (!GetHttpRTTEstimate(&estimated_http_rtt)) |
| 384 estimated_http_rtt = nqe::internal::InvalidRTT(); | 420 estimated_http_rtt = nqe::internal::InvalidRTT(); |
| 385 | 421 |
| 422 base::TimeDelta estimated_transport_rtt; |
| 423 if (!GetTransportRTTEstimate(&estimated_transport_rtt)) |
| 424 estimated_transport_rtt = nqe::internal::InvalidRTT(); |
| 425 |
| 386 int32_t downstream_throughput_kbps; | 426 int32_t downstream_throughput_kbps; |
| 387 if (!GetDownlinkThroughputKbpsEstimate(&downstream_throughput_kbps)) | 427 if (!GetDownlinkThroughputKbpsEstimate(&downstream_throughput_kbps)) |
| 388 downstream_throughput_kbps = nqe::internal::kInvalidThroughput; | 428 downstream_throughput_kbps = nqe::internal::kInvalidThroughput; |
| 389 | 429 |
| 390 estimated_median_network_quality_ = nqe::internal::NetworkQuality( | 430 estimated_quality_at_last_main_frame_ = nqe::internal::NetworkQuality( |
| 391 estimated_http_rtt, nqe::internal::InvalidRTT(), | 431 estimated_http_rtt, estimated_transport_rtt, |
| 392 downstream_throughput_kbps); | 432 downstream_throughput_kbps); |
| 393 | 433 |
| 394 RecordMetricsOnMainFrameRequest(); | 434 RecordMetricsOnMainFrameRequest(); |
| 435 |
| 436 // Post the tasks which will run in the future and record the estimation |
| 437 // accuracy based on the observations received between now and the time of |
| 438 // task execution. Posting the task at different intervals makes it |
| 439 // possible to measure the accuracy by comparing the estimate with the |
| 440 // observations received over intervals of varying durations. |
| 441 for (const base::TimeDelta& measuring_delay : |
| 442 GetAccuracyRecordingIntervals()) { |
| 443 base::MessageLoop::current()->task_runner()->PostDelayedTask( |
| 444 FROM_HERE, |
| 445 base::Bind(&NetworkQualityEstimator::RecordAccuracyAfterMainFrame, |
| 446 weak_ptr_factory_.GetWeakPtr(), measuring_delay), |
| 447 measuring_delay); |
| 448 } |
| 395 } | 449 } |
| 396 | 450 |
| 397 const base::TimeTicks now = tick_clock_->NowTicks(); | |
| 398 LoadTimingInfo load_timing_info; | 451 LoadTimingInfo load_timing_info; |
| 399 request.GetLoadTimingInfo(&load_timing_info); | 452 request.GetLoadTimingInfo(&load_timing_info); |
| 400 | 453 |
| 401 // If the load timing info is unavailable, it probably means that the request | 454 // If the load timing info is unavailable, it probably means that the request |
| 402 // did not go over the network. | 455 // did not go over the network. |
| 403 if (load_timing_info.send_start.is_null() || | 456 if (load_timing_info.send_start.is_null() || |
| 404 load_timing_info.receive_headers_end.is_null()) { | 457 load_timing_info.receive_headers_end.is_null()) { |
| 405 return; | 458 return; |
| 406 } | 459 } |
| 407 | 460 |
| 408 // Duration between when the resource was requested and when the response | 461 // Duration between when the resource was requested and when the response |
| 409 // headers were received. | 462 // headers were received. |
| 410 base::TimeDelta observed_http_rtt = | 463 base::TimeDelta observed_http_rtt = |
| 411 load_timing_info.receive_headers_end - load_timing_info.send_start; | 464 load_timing_info.receive_headers_end - load_timing_info.send_start; |
| 412 DCHECK_GE(observed_http_rtt, base::TimeDelta()); | 465 DCHECK_GE(observed_http_rtt, base::TimeDelta()); |
| 413 if (observed_http_rtt < peak_network_quality_.http_rtt()) { | 466 if (observed_http_rtt < peak_network_quality_.http_rtt()) { |
| 414 peak_network_quality_ = nqe::internal::NetworkQuality( | 467 peak_network_quality_ = nqe::internal::NetworkQuality( |
| 415 observed_http_rtt, peak_network_quality_.transport_rtt(), | 468 observed_http_rtt, peak_network_quality_.transport_rtt(), |
| 416 peak_network_quality_.downstream_throughput_kbps()); | 469 peak_network_quality_.downstream_throughput_kbps()); |
| 417 } | 470 } |
| 418 | 471 |
| 419 RttObservation http_rtt_observation( | 472 RttObservation http_rtt_observation( |
| 420 observed_http_rtt, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST); | 473 observed_http_rtt, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST); |
| 421 rtt_observations_.AddObservation(http_rtt_observation); | 474 rtt_observations_.AddObservation(http_rtt_observation); |
| 422 NotifyObserversOfRTT(http_rtt_observation); | 475 NotifyObserversOfRTT(http_rtt_observation); |
| 423 | 476 |
| 424 // Compare the RTT observation with the estimated value and record it. | 477 // Compare the RTT observation with the estimated value and record it. |
| 425 if (estimated_median_network_quality_.http_rtt() != | 478 if (estimated_quality_at_last_main_frame_.http_rtt() != |
| 426 nqe::internal::InvalidRTT()) { | 479 nqe::internal::InvalidRTT()) { |
| 427 RecordHttpRTTUMA( | 480 RecordHttpRTTUMA( |
| 428 estimated_median_network_quality_.http_rtt().InMilliseconds(), | 481 estimated_quality_at_last_main_frame_.http_rtt().InMilliseconds(), |
| 429 observed_http_rtt.InMilliseconds()); | 482 observed_http_rtt.InMilliseconds()); |
| 430 } | 483 } |
| 431 } | 484 } |
| 432 | 485 |
| 486 void NetworkQualityEstimator::RecordAccuracyAfterMainFrame( |
| 487 base::TimeDelta measuring_duration) const { |
| 488 DCHECK(thread_checker_.CalledOnValidThread()); |
| 489 DCHECK_EQ(0, measuring_duration.InMilliseconds() % 1000); |
| 490 DCHECK(ContainsValue(GetAccuracyRecordingIntervals(), measuring_duration)); |
| 491 |
| 492 const base::TimeTicks now = tick_clock_->NowTicks(); |
| 493 |
| 494 // Return if the time since |last_main_frame_request_| is less than |
| 495 // |measuring_duration|. This may happen if another main frame request started |
| 496 // during last |measuring_duration|. Returning here ensures that we do not |
| 497 // take inaccurate readings. |
| 498 if (now - last_main_frame_request_ < measuring_duration) |
| 499 return; |
| 500 |
| 501 // Return if the time since |last_main_frame_request_| is off by a factor of |
| 502 // 2. This can happen if the task is executed much later than its scheduled |
| 503 // time. Returning here ensures that we do not take inaccurate readings. |
| 504 if (now - last_main_frame_request_ > 2 * measuring_duration) |
| 505 return; |
| 506 |
| 507 base::TimeDelta recent_http_rtt; |
| 508 if (estimated_quality_at_last_main_frame_.http_rtt() != |
| 509 nqe::internal::InvalidRTT() && |
| 510 GetRecentHttpRTTMedian(last_main_frame_request_, &recent_http_rtt)) { |
| 511 const int estimated_observed_diff_milliseconds = |
| 512 estimated_quality_at_last_main_frame_.http_rtt().InMilliseconds() - |
| 513 recent_http_rtt.InMilliseconds(); |
| 514 |
| 515 const std::string sign_suffix = |
| 516 estimated_observed_diff_milliseconds >= 0 ? "Positive." : "Negative."; |
| 517 |
| 518 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
| 519 "NQE.Accuracy.HttpRTT.EstimatedObservedDiff." + sign_suffix + |
| 520 base::IntToString(measuring_duration.InSeconds()) + "." + |
| 521 GetHistogramSuffixObservedRTT(recent_http_rtt), |
| 522 1, 10 * 1000 /* 10 seconds */, 50 /* Number of buckets */, |
| 523 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 524 histogram->Add(std::abs(estimated_observed_diff_milliseconds)); |
| 525 } |
| 526 |
| 527 base::TimeDelta recent_transport_rtt; |
| 528 if (estimated_quality_at_last_main_frame_.transport_rtt() != |
| 529 nqe::internal::InvalidRTT() && |
| 530 GetRecentTransportRTTMedian(last_main_frame_request_, |
| 531 &recent_transport_rtt)) { |
| 532 const int estimated_observed_diff_milliseconds = |
| 533 estimated_quality_at_last_main_frame_.transport_rtt().InMilliseconds() - |
| 534 recent_transport_rtt.InMilliseconds(); |
| 535 |
| 536 const std::string sign_suffix = |
| 537 estimated_observed_diff_milliseconds >= 0 ? "Positive." : "Negative."; |
| 538 |
| 539 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
| 540 "NQE.Accuracy.TransportRTT.EstimatedObservedDiff." + sign_suffix + |
| 541 base::IntToString(measuring_duration.InSeconds()) + "." + |
| 542 GetHistogramSuffixObservedRTT(recent_transport_rtt), |
| 543 1, 10 * 1000 /* 10 seconds */, 50 /* Number of buckets */, |
| 544 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 545 histogram->Add(std::abs(estimated_observed_diff_milliseconds)); |
| 546 } |
| 547 |
| 548 // TODO(tbansal): Add histogram for downstream throughput and effective |
| 549 // connection type. |
| 550 } |
| 551 |
| 433 void NetworkQualityEstimator::NotifyRequestCompleted( | 552 void NetworkQualityEstimator::NotifyRequestCompleted( |
| 434 const URLRequest& request) { | 553 const URLRequest& request) { |
| 435 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 554 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
| 436 "NetworkQualityEstimator::NotifyRequestCompleted"); | 555 "NetworkQualityEstimator::NotifyRequestCompleted"); |
| 437 DCHECK(thread_checker_.CalledOnValidThread()); | 556 DCHECK(thread_checker_.CalledOnValidThread()); |
| 438 | 557 |
| 439 if (!RequestSchemeIsHTTPOrHTTPS(request)) | 558 if (!RequestSchemeIsHTTPOrHTTPS(request)) |
| 440 return; | 559 return; |
| 441 | 560 |
| 442 throughput_analyzer_->NotifyRequestCompleted(request); | 561 throughput_analyzer_->NotifyRequestCompleted(request); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 current_network_id_.type != NetworkChangeNotifier::CONNECTION_BLUETOOTH) { | 677 current_network_id_.type != NetworkChangeNotifier::CONNECTION_BLUETOOTH) { |
| 559 RecordExternalEstimateProviderMetrics( | 678 RecordExternalEstimateProviderMetrics( |
| 560 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED); | 679 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED); |
| 561 external_estimate_provider_->Update(); | 680 external_estimate_provider_->Update(); |
| 562 } | 681 } |
| 563 | 682 |
| 564 // Read any cached estimates for the new network. If cached estimates are | 683 // Read any cached estimates for the new network. If cached estimates are |
| 565 // unavailable, add the default estimates. | 684 // unavailable, add the default estimates. |
| 566 if (!ReadCachedNetworkQualityEstimate()) | 685 if (!ReadCachedNetworkQualityEstimate()) |
| 567 AddDefaultEstimates(); | 686 AddDefaultEstimates(); |
| 568 estimated_median_network_quality_ = nqe::internal::NetworkQuality(); | 687 estimated_quality_at_last_main_frame_ = nqe::internal::NetworkQuality(); |
| 569 throughput_analyzer_->OnConnectionTypeChanged(); | 688 throughput_analyzer_->OnConnectionTypeChanged(); |
| 570 MaybeRecomputeEffectiveConnectionType(); | 689 MaybeRecomputeEffectiveConnectionType(); |
| 571 } | 690 } |
| 572 | 691 |
| 573 void NetworkQualityEstimator::RecordMetricsOnConnectionTypeChanged() const { | 692 void NetworkQualityEstimator::RecordMetricsOnConnectionTypeChanged() const { |
| 574 DCHECK(thread_checker_.CalledOnValidThread()); | 693 DCHECK(thread_checker_.CalledOnValidThread()); |
| 575 if (peak_network_quality_.http_rtt() != nqe::internal::InvalidRTT()) { | 694 if (peak_network_quality_.http_rtt() != nqe::internal::InvalidRTT()) { |
| 576 base::HistogramBase* rtt_histogram = | 695 base::HistogramBase* rtt_histogram = |
| 577 GetHistogram("FastestRTT.", current_network_id_.type, 10 * 1000); | 696 GetHistogram("FastestRTT.", current_network_id_.type, 10 * 1000); |
| 578 rtt_histogram->Add(peak_network_quality_.http_rtt().InMilliseconds()); | 697 rtt_histogram->Add(peak_network_quality_.http_rtt().InMilliseconds()); |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 DCHECK(external_estimate_provider_); | 1047 DCHECK(external_estimate_provider_); |
| 929 | 1048 |
| 930 RecordExternalEstimateProviderMetrics( | 1049 RecordExternalEstimateProviderMetrics( |
| 931 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK); | 1050 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK); |
| 932 | 1051 |
| 933 if (rtt > base::TimeDelta()) { | 1052 if (rtt > base::TimeDelta()) { |
| 934 RecordExternalEstimateProviderMetrics( | 1053 RecordExternalEstimateProviderMetrics( |
| 935 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE); | 1054 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE); |
| 936 UMA_HISTOGRAM_TIMES("NQE.ExternalEstimateProvider.RTT", rtt); | 1055 UMA_HISTOGRAM_TIMES("NQE.ExternalEstimateProvider.RTT", rtt); |
| 937 rtt_observations_.AddObservation( | 1056 rtt_observations_.AddObservation( |
| 938 RttObservation(rtt, base::TimeTicks::Now(), | 1057 RttObservation(rtt, tick_clock_->NowTicks(), |
| 939 NETWORK_QUALITY_OBSERVATION_SOURCE_EXTERNAL_ESTIMATE)); | 1058 NETWORK_QUALITY_OBSERVATION_SOURCE_EXTERNAL_ESTIMATE)); |
| 940 } | 1059 } |
| 941 | 1060 |
| 942 if (downstream_throughput_kbps > 0) { | 1061 if (downstream_throughput_kbps > 0) { |
| 943 RecordExternalEstimateProviderMetrics( | 1062 RecordExternalEstimateProviderMetrics( |
| 944 EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE); | 1063 EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE); |
| 945 UMA_HISTOGRAM_COUNTS("NQE.ExternalEstimateProvider.DownlinkBandwidth", | 1064 UMA_HISTOGRAM_COUNTS("NQE.ExternalEstimateProvider.DownlinkBandwidth", |
| 946 downstream_throughput_kbps); | 1065 downstream_throughput_kbps); |
| 947 downstream_throughput_kbps_observations_.AddObservation( | 1066 downstream_throughput_kbps_observations_.AddObservation( |
| 948 ThroughputObservation( | 1067 ThroughputObservation( |
| 949 downstream_throughput_kbps, base::TimeTicks::Now(), | 1068 downstream_throughput_kbps, tick_clock_->NowTicks(), |
| 950 NETWORK_QUALITY_OBSERVATION_SOURCE_EXTERNAL_ESTIMATE)); | 1069 NETWORK_QUALITY_OBSERVATION_SOURCE_EXTERNAL_ESTIMATE)); |
| 951 } | 1070 } |
| 952 } | 1071 } |
| 953 | 1072 |
| 954 const char* NetworkQualityEstimator::GetNameForEffectiveConnectionType( | 1073 const char* NetworkQualityEstimator::GetNameForEffectiveConnectionType( |
| 955 EffectiveConnectionType type) const { | 1074 EffectiveConnectionType type) const { |
| 956 switch (type) { | 1075 switch (type) { |
| 957 case EFFECTIVE_CONNECTION_TYPE_UNKNOWN: | 1076 case EFFECTIVE_CONNECTION_TYPE_UNKNOWN: |
| 958 return "Unknown"; | 1077 return "Unknown"; |
| 959 case EFFECTIVE_CONNECTION_TYPE_OFFLINE: | 1078 case EFFECTIVE_CONNECTION_TYPE_OFFLINE: |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 NotifyObserversOfEffectiveConnectionTypeChanged() { | 1235 NotifyObserversOfEffectiveConnectionTypeChanged() { |
| 1117 DCHECK(thread_checker_.CalledOnValidThread()); | 1236 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1118 | 1237 |
| 1119 // TODO(tbansal): Add hysteresis in the notification. | 1238 // TODO(tbansal): Add hysteresis in the notification. |
| 1120 FOR_EACH_OBSERVER( | 1239 FOR_EACH_OBSERVER( |
| 1121 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, | 1240 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, |
| 1122 OnEffectiveConnectionTypeChanged(effective_connection_type_)); | 1241 OnEffectiveConnectionTypeChanged(effective_connection_type_)); |
| 1123 } | 1242 } |
| 1124 | 1243 |
| 1125 } // namespace net | 1244 } // namespace net |
| OLD | NEW |