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

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

Issue 2703103002: NQE: Move ECT computation to NotifyHeadersReceived (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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 if (!RequestSchemeIsHTTPOrHTTPS(request)) 404 if (!RequestSchemeIsHTTPOrHTTPS(request))
405 return; 405 return;
406 406
407 // Update |estimated_quality_at_last_main_frame_| if this is a main frame 407 // Update |estimated_quality_at_last_main_frame_| if this is a main frame
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 MaybeComputeEffectiveConnectionType();
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 // 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
419 // 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
420 // task execution. Posting the task at different intervals makes it 420 // task execution. Posting the task at different intervals makes it
421 // possible to measure the accuracy by comparing the estimate with the 421 // possible to measure the accuracy by comparing the estimate with the
422 // observations received over intervals of varying durations. 422 // observations received over intervals of varying durations.
423 for (const base::TimeDelta& measuring_delay : 423 for (const base::TimeDelta& measuring_delay :
424 GetAccuracyRecordingIntervals()) { 424 GetAccuracyRecordingIntervals()) {
(...skipping 11 matching lines...) Expand all
436 TRACE_EVENT0(kNetTracingCategory, 436 TRACE_EVENT0(kNetTracingCategory,
437 "NetworkQualityEstimator::NotifyHeadersReceived"); 437 "NetworkQualityEstimator::NotifyHeadersReceived");
438 DCHECK(thread_checker_.CalledOnValidThread()); 438 DCHECK(thread_checker_.CalledOnValidThread());
439 439
440 if (!RequestSchemeIsHTTPOrHTTPS(request) || 440 if (!RequestSchemeIsHTTPOrHTTPS(request) ||
441 !RequestProvidesRTTObservation(request)) { 441 !RequestProvidesRTTObservation(request)) {
442 return; 442 return;
443 } 443 }
444 444
445 if (request.load_flags() & LOAD_MAIN_FRAME_DEPRECATED) { 445 if (request.load_flags() & LOAD_MAIN_FRAME_DEPRECATED) {
446 ComputeEffectiveConnectionType();
446 RecordMetricsOnMainFrameRequest(); 447 RecordMetricsOnMainFrameRequest();
447 MaybeQueryExternalEstimateProvider(); 448 MaybeQueryExternalEstimateProvider();
448 } 449 }
449 450
450 LoadTimingInfo load_timing_info; 451 LoadTimingInfo load_timing_info;
451 request.GetLoadTimingInfo(&load_timing_info); 452 request.GetLoadTimingInfo(&load_timing_info);
452 453
453 // 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
454 // did not go over the network. 455 // did not go over the network.
455 if (load_timing_info.send_start.is_null() || 456 if (load_timing_info.send_start.is_null() ||
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1750 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1750 downstream_throughput_kbps_observations_.AddObservation( 1751 downstream_throughput_kbps_observations_.AddObservation(
1751 throughput_observation); 1752 throughput_observation);
1752 NotifyObserversOfThroughput(throughput_observation); 1753 NotifyObserversOfThroughput(throughput_observation);
1753 } 1754 }
1754 1755
1755 ComputeEffectiveConnectionType(); 1756 ComputeEffectiveConnectionType();
1756 } 1757 }
1757 1758
1758 } // namespace net 1759 } // 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