chromium/services/network/resource_scheduler/resource_scheduler.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {};

// Flags identifying various attributes of the request that are used
// when making scheduling decisions.
RequestAttributes;
const RequestAttributes kAttributeNone =;
const RequestAttributes kAttributeInFlight =;
const RequestAttributes kAttributeDelayable =;

// Reasons why pending requests may be started.  For logging only.
enum class RequestStartTrigger {};

const char* RequestStartTriggerString(RequestStartTrigger trigger) {}

uint64_t CalculateTrackId(ResourceScheduler* scheduler) {}

BASE_FEATURE();

BASE_FEATURE();

constexpr base::FeatureParam<net::RequestPriority>::Option
    kRequestPriorities[] =;

}  // namespace

// The maximum number of requests to allow be in-flight at any point in time per
// host. This limit does not apply to hosts that support request prioritization
// when |delay_requests_on_multiplexed_connections| is true.
MIRACLE_PARAMETER_FOR_INT(GetMaxNumDelayableRequestsPerHostPerClient,
                          kMaxNumDelayableRequestsPerHostPerClientFeature,
                          "MaxNumDelayableRequestsPerHostPerClient",
                          6)

// The priority level below which resources are considered to be delayable.
MIRACLE_PARAMETER_FOR_ENUM()

// Returns the duration after which the timer to dispatch queued requests should
// fire.
base::TimeDelta GetQueuedRequestsDispatchPeriodicity() {}

// static
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() {}

// This is the handle we return to the URLLoader so it can interact with the
// request.
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) {}

// Each client represents a tab.
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() {}

}  // namespace network