#include "services/network/resource_scheduler/resource_scheduler.h"
#include <stdint.h>
#include <string>
#include <utility>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/histogram_macros_local.h"
#include "base/strings/string_number_conversions.h"
#include "base/supports_user_data.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/default_tick_clock.h"
#include "base/time/tick_clock.h"
#include "base/trace_event/trace_event.h"
#include "base/unguessable_token.h"
#include "components/miracle_parameter/common/public/miracle_parameter.h"
#include "net/base/isolation_info.h"
#include "net/base/load_flags.h"
#include "net/base/request_priority.h"
#include "net/base/tracing.h"
#include "net/http/http_server_properties.h"
#include "net/log/net_log.h"
#include "net/nqe/effective_connection_type_observer.h"
#include "net/nqe/network_quality_estimator.h"
#include "net/nqe/peer_to_peer_connections_count_observer.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "url/scheme_host_port.h"
namespace network {
namespace {
enum StartMode { … };
RequestAttributes;
const RequestAttributes kAttributeNone = …;
const RequestAttributes kAttributeInFlight = …;
const RequestAttributes kAttributeDelayable = …;
enum class RequestStartTrigger { … };
const char* RequestStartTriggerString(RequestStartTrigger trigger) { … }
uint64_t CalculateTrackId(ResourceScheduler* scheduler) { … }
BASE_FEATURE(…);
BASE_FEATURE(…);
constexpr base::FeatureParam<net::RequestPriority>::Option
kRequestPriorities[] = …;
}
MIRACLE_PARAMETER_FOR_INT(GetMaxNumDelayableRequestsPerHostPerClient,
kMaxNumDelayableRequestsPerHostPerClientFeature,
"MaxNumDelayableRequestsPerHostPerClient",
6)
MIRACLE_PARAMETER_FOR_ENUM(…)
base::TimeDelta GetQueuedRequestsDispatchPeriodicity() { … }
ResourceScheduler::ClientId ResourceScheduler::ClientId::Create(
const std::optional<base::UnguessableToken>& token) { … }
struct ResourceScheduler::RequestPriorityParams { … };
class ResourceScheduler::RequestQueue { … };
ResourceScheduler::ScheduledResourceRequest::ScheduledResourceRequest() { … }
ResourceScheduler::ScheduledResourceRequest::~ScheduledResourceRequest() { … }
void ResourceScheduler::ScheduledResourceRequest::RunResumeCallback() { … }
class ResourceScheduler::ScheduledResourceRequestImpl
: public ScheduledResourceRequest { … };
const void* const
ResourceScheduler::ScheduledResourceRequestImpl::kUserDataKey = …;
bool ResourceScheduler::ScheduledResourceSorter::operator()(
const ScheduledResourceRequestImpl* a,
const ScheduledResourceRequestImpl* b) const { … }
void ResourceScheduler::RequestQueue::Insert(
ScheduledResourceRequestImpl* request) { … }
void ResourceScheduler::RequestQueue::Erase(
ScheduledResourceRequestImpl* request) { … }
class ResourceScheduler::Client
: public net::EffectiveConnectionTypeObserver,
public net::PeerToPeerConnectionsCountObserver { … };
ResourceScheduler::ResourceScheduler(const base::TickClock* tick_clock)
: … { … }
ResourceScheduler::~ResourceScheduler() { … }
std::unique_ptr<ResourceScheduler::ScheduledResourceRequest>
ResourceScheduler::ScheduleRequest(ClientId client_id,
bool is_async,
net::URLRequest* url_request) { … }
void ResourceScheduler::RemoveRequest(ScheduledResourceRequestImpl* request) { … }
void ResourceScheduler::OnClientCreated(
ClientId client_id,
IsBrowserInitiated is_browser_initiated,
net::NetworkQualityEstimator* network_quality_estimator) { … }
void ResourceScheduler::OnClientDeleted(ClientId client_id) { … }
void ResourceScheduler::OnClientVisibilityChanged(
const base::UnguessableToken& client_token,
bool visible) { … }
ResourceScheduler::Client* ResourceScheduler::GetClient(ClientId client_id) { … }
void ResourceScheduler::StartLongQueuedRequestsDispatchTimerIfNeeded() { … }
void ResourceScheduler::OnLongQueuedRequestsDispatchTimerFired() { … }
void ResourceScheduler::ReprioritizeRequest(net::URLRequest* request,
net::RequestPriority new_priority,
int new_intra_priority_value) { … }
bool ResourceScheduler::IsLongQueuedRequestsDispatchTimerRunning() const { … }
base::SequencedTaskRunner* ResourceScheduler::task_runner() { … }
void ResourceScheduler::SetResourceSchedulerParamsManagerForTests(
const ResourceSchedulerParamsManager& resource_scheduler_params_manager) { … }
void ResourceScheduler::DispatchLongQueuedRequestsForTesting() { … }
}