#include "net/nqe/throughput_analyzer.h"
#include <cmath>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/tick_clock.h"
#include "net/base/host_port_pair.h"
#include "net/base/network_activity_monitor.h"
#include "net/base/url_util.h"
#include "net/nqe/network_quality_estimator.h"
#include "net/nqe/network_quality_estimator_params.h"
#include "net/nqe/network_quality_estimator_util.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
namespace net {
class HostResolver;
namespace {
static const size_t kMaxRequestsSize = …;
bool ShouldDiscardRequest(const URLRequest& request) { … }
}
namespace nqe::internal {
constexpr int64_t kDefaultContentSizeBytes = …;
ThroughputAnalyzer::ThroughputAnalyzer(
const NetworkQualityEstimator* network_quality_estimator,
const NetworkQualityEstimatorParams* params,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
ThroughputObservationCallback throughput_observation_callback,
const base::TickClock* tick_clock,
const NetLogWithSource& net_log)
: … { … }
ThroughputAnalyzer::~ThroughputAnalyzer() { … }
void ThroughputAnalyzer::MaybeStartThroughputObservationWindow() { … }
void ThroughputAnalyzer::EndThroughputObservationWindow() { … }
bool ThroughputAnalyzer::IsCurrentlyTrackingThroughput() const { … }
void ThroughputAnalyzer::SetTickClockForTesting(
const base::TickClock* tick_clock) { … }
void ThroughputAnalyzer::UpdateResponseContentSize(const URLRequest* request,
int64_t response_size) { … }
void ThroughputAnalyzer::NotifyStartTransaction(const URLRequest& request) { … }
void ThroughputAnalyzer::NotifyBytesRead(const URLRequest& request) { … }
void ThroughputAnalyzer::NotifyRequestCompleted(const URLRequest& request) { … }
void ThroughputAnalyzer::NotifyExpectedResponseContentSize(
const URLRequest& request,
int64_t expected_content_size) { … }
bool ThroughputAnalyzer::IsHangingWindow(int64_t bits_received,
base::TimeDelta duration) const { … }
bool ThroughputAnalyzer::MaybeGetThroughputObservation(
int32_t* downstream_kbps) { … }
void ThroughputAnalyzer::OnConnectionTypeChanged() { … }
void ThroughputAnalyzer::SetUseLocalHostRequestsForTesting(
bool use_localhost_requests) { … }
int64_t ThroughputAnalyzer::GetBitsReceived() const { … }
size_t ThroughputAnalyzer::CountActiveInFlightRequests() const { … }
size_t ThroughputAnalyzer::CountTotalInFlightRequests() const { … }
int64_t ThroughputAnalyzer::CountTotalContentSizeBytes() const { … }
bool ThroughputAnalyzer::DegradesAccuracy(const URLRequest& request) const { … }
void ThroughputAnalyzer::BoundRequestsSize() { … }
void ThroughputAnalyzer::EraseHangingRequests(const URLRequest& request) { … }
}
}