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

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

Issue 2702013002: NQE: Move recording of metrics to when the response headers are received (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // request. 408 // request.
409 // TODO(tbansal): Refactor this to a separate method. 409 // TODO(tbansal): Refactor this to a separate method.
410 if (request.load_flags() & LOAD_MAIN_FRAME_DEPRECATED) { 410 if (request.load_flags() & LOAD_MAIN_FRAME_DEPRECATED) {
411 base::TimeTicks now = tick_clock_->NowTicks(); 411 base::TimeTicks now = tick_clock_->NowTicks();
412 last_main_frame_request_ = now; 412 last_main_frame_request_ = now;
413 413
414 ComputeEffectiveConnectionType(); 414 ComputeEffectiveConnectionType();
415 effective_connection_type_at_last_main_frame_ = effective_connection_type_; 415 effective_connection_type_at_last_main_frame_ = effective_connection_type_;
416 estimated_quality_at_last_main_frame_ = network_quality_; 416 estimated_quality_at_last_main_frame_ = network_quality_;
417 417
418 RecordMetricsOnMainFrameRequest();
419
420 // Post the tasks which will run in the future and record the estimation 418 // Post the tasks which will run in the future and record the estimation
421 // accuracy based on the observations received between now and the time of 419 // accuracy based on the observations received between now and the time of
422 // task execution. Posting the task at different intervals makes it 420 // task execution. Posting the task at different intervals makes it
423 // possible to measure the accuracy by comparing the estimate with the 421 // possible to measure the accuracy by comparing the estimate with the
424 // observations received over intervals of varying durations. 422 // observations received over intervals of varying durations.
425 for (const base::TimeDelta& measuring_delay : 423 for (const base::TimeDelta& measuring_delay :
426 GetAccuracyRecordingIntervals()) { 424 GetAccuracyRecordingIntervals()) {
427 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 425 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
428 FROM_HERE, 426 FROM_HERE,
429 base::Bind(&NetworkQualityEstimator::RecordAccuracyAfterMainFrame, 427 base::Bind(&NetworkQualityEstimator::RecordAccuracyAfterMainFrame,
430 weak_ptr_factory_.GetWeakPtr(), measuring_delay), 428 weak_ptr_factory_.GetWeakPtr(), measuring_delay),
431 measuring_delay); 429 measuring_delay);
432 } 430 }
433 } 431 }
434 throughput_analyzer_->NotifyStartTransaction(request); 432 throughput_analyzer_->NotifyStartTransaction(request);
435 } 433 }
436 434
437 void NetworkQualityEstimator::NotifyHeadersReceived(const URLRequest& request) { 435 void NetworkQualityEstimator::NotifyHeadersReceived(const URLRequest& request) {
438 TRACE_EVENT0(kNetTracingCategory, 436 TRACE_EVENT0(kNetTracingCategory,
439 "NetworkQualityEstimator::NotifyHeadersReceived"); 437 "NetworkQualityEstimator::NotifyHeadersReceived");
440 DCHECK(thread_checker_.CalledOnValidThread()); 438 DCHECK(thread_checker_.CalledOnValidThread());
441 439
442 if (!RequestSchemeIsHTTPOrHTTPS(request) || 440 if (!RequestSchemeIsHTTPOrHTTPS(request) ||
443 !RequestProvidesRTTObservation(request)) { 441 !RequestProvidesRTTObservation(request)) {
444 return; 442 return;
445 } 443 }
446 444
447 if (request.load_flags() & LOAD_MAIN_FRAME_DEPRECATED) 445 if (request.load_flags() & LOAD_MAIN_FRAME_DEPRECATED) {
446 RecordMetricsOnMainFrameRequest();
448 MaybeQueryExternalEstimateProvider(); 447 MaybeQueryExternalEstimateProvider();
448 }
449 449
450 LoadTimingInfo load_timing_info; 450 LoadTimingInfo load_timing_info;
451 request.GetLoadTimingInfo(&load_timing_info); 451 request.GetLoadTimingInfo(&load_timing_info);
452 452
453 // If the load timing info is unavailable, it probably means that the request 453 // If the load timing info is unavailable, it probably means that the request
454 // did not go over the network. 454 // did not go over the network.
455 if (load_timing_info.send_start.is_null() || 455 if (load_timing_info.send_start.is_null() ||
456 load_timing_info.receive_headers_end.is_null()) { 456 load_timing_info.receive_headers_end.is_null()) {
457 return; 457 return;
458 } 458 }
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1749 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1750 downstream_throughput_kbps_observations_.AddObservation( 1750 downstream_throughput_kbps_observations_.AddObservation(
1751 throughput_observation); 1751 throughput_observation);
1752 NotifyObserversOfThroughput(throughput_observation); 1752 NotifyObserversOfThroughput(throughput_observation);
1753 } 1753 }
1754 1754
1755 ComputeEffectiveConnectionType(); 1755 ComputeEffectiveConnectionType();
1756 } 1756 }
1757 1757
1758 } // namespace net 1758 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698