#include "services/network/resource_scheduler/resource_scheduler.h"
#include <map>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/task_environment.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "net/base/features.h"
#include "net/base/host_port_pair.h"
#include "net/base/isolation_info.h"
#include "net/base/load_timing_info.h"
#include "net/base/request_priority.h"
#include "net/nqe/network_quality_estimator_test_util.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_test_util.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "services/network/resource_scheduler/resource_scheduler_params_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/scheme_host_port.h"
string;
namespace network {
namespace {
class TestRequestFactory;
ClientId;
const ClientId kClientId1 = …;
const ClientId kClientId2 = …;
const ClientId kTrustedClientId = …;
const ClientId kBackgroundClientId = …;
const size_t kMaxNumDelayableRequestsPerHostPerClient = …;
class TestRequest { … };
class CancelingTestRequest : public TestRequest { … };
class ResourceSchedulerTest : public testing::Test { … };
TEST_F(ResourceSchedulerTest, OneIsolatedLowRequest) { … }
TEST_F(ResourceSchedulerTest, OneLowLoadsUntilCriticalComplete) { … }
TEST_F(ResourceSchedulerTest, MaxRequestsPerHostForSpdyWhenNotDelayable) { … }
TEST_F(ResourceSchedulerTest,
MaxRequestsPerHostForSpdyWhenNotDelayableWithIsolationInfo) { … }
TEST_F(ResourceSchedulerTest, BackgroundRequestStartsImmediately) { … }
TEST_F(ResourceSchedulerTest, CancelOtherRequestsWhileResuming) { … }
TEST_F(ResourceSchedulerTest, LimitedNumberOfDelayableRequestsInFlight) { … }
TEST_F(ResourceSchedulerTest, RaisePriorityAndStart) { … }
TEST_F(ResourceSchedulerTest, RaisePriorityInQueue) { … }
TEST_F(ResourceSchedulerTest, LowerPriority) { … }
TEST_F(ResourceSchedulerTest, LowerPriorityBrowserRequestsNotThrottled) { … }
TEST_F(ResourceSchedulerTest,
LowerPriorityBrowserRequestsThrottleP2PConnections) { … }
TEST_F(ResourceSchedulerTest, P2PConnectionWentAway) { … }
TEST_F(ResourceSchedulerTest,
RequestThrottleOnlyOnSlowConnectionsWithP2PRequests) { … }
TEST_F(ResourceSchedulerTest, ReprioritizedRequestGoesToBackOfQueue) { … }
TEST_F(ResourceSchedulerTest, HigherIntraPriorityGoesToFrontOfQueue) { … }
TEST_F(ResourceSchedulerTest, NonHTTPSchedulesImmediately) { … }
TEST_F(ResourceSchedulerTest, SpdyProxySchedulesImmediately) { … }
TEST_F(ResourceSchedulerTest, NewSpdyHostInDelayableRequests) { … }
TEST_F(ResourceSchedulerTest,
NewDelayableSpdyHostInDelayableRequestsSlowConnection) { … }
TEST_F(ResourceSchedulerTest, RequestStartedAfterClientDeleted) { … }
TEST_F(ResourceSchedulerTest, RequestStartedAfterClientDeletedManyDelayable) { … }
TEST_F(ResourceSchedulerTest, RequestLimitOverrideEnabled) { … }
TEST_F(ResourceSchedulerTest, RequestLimitOverrideDisabled) { … }
TEST_F(ResourceSchedulerTest, RequestLimitOverrideOutsideECTRange) { … }
TEST_F(ResourceSchedulerTest, RequestLimitOverrideNotFixedForPageLoad) { … }
TEST_F(ResourceSchedulerTest, RequestLimitReducedAcrossPageLoads) { … }
TEST_F(ResourceSchedulerTest, ThrottleDelayableDisabled) { … }
TEST_F(ResourceSchedulerTest, NonDelayableThrottlesDelayableOutsideECT) { … }
TEST_F(ResourceSchedulerTest, NonDelayableThrottlesDelayableVaryNonDelayable) { … }
TEST_F(ResourceSchedulerTest, NonDelayableThrottlesDelayableWeight1) { … }
TEST_F(ResourceSchedulerTest, NonDelayableThrottlesDelayableWeight3) { … }
TEST_F(ResourceSchedulerTest, Simple) { … }
TEST_F(ResourceSchedulerTest, MultipleInstances_1) { … }
TEST_F(ResourceSchedulerTest, MultipleInstances_2) { … }
TEST_F(ResourceSchedulerTest,
MaxRequestsPerHostForSpdyWhenDelayableSlowConnections) { … }
TEST_F(ResourceSchedulerTest,
MaxRequestsPerHostForSpdyWhenDelayableSlowConnectionsWithIsolationInfo) { … }
TEST_F(ResourceSchedulerTest,
MaxRequestsPerHostForSpdyWhenDelayableFastConnections) { … }
TEST_F(ResourceSchedulerTest,
MaxRequestsPerHostForNonSpdyWhenDelayableSlowConnections) { … }
TEST_F(ResourceSchedulerTest,
DelayableRequestLimitSpdyDelayableSlowConnections) { … }
TEST_F(ResourceSchedulerTest, MaxQueuingDelaySet) { … }
TEST_F(ResourceSchedulerTest, MaxQueuingDelayNotSet) { … }
TEST_F(ResourceSchedulerTest, MaxQueuingDelayTimerFires) { … }
TEST_F(ResourceSchedulerTest, MaxQueuingDelayTimerNotFired) { … }
TEST_F(ResourceSchedulerTest, MaxQueuingDelayTimerRunsOnRequestSchedule) { … }
TEST_F(ResourceSchedulerTest, NonDelayableRequestArrivesAfterDelayableStarts) { … }
TEST_F(ResourceSchedulerTest, ProactiveThrottlingExperiment) { … }
TEST_F(ResourceSchedulerTest,
ProactiveThrottlingDoesNotThrottleHighPriorityRequests) { … }
TEST_F(ResourceSchedulerTest, ProactiveThrottling_UnthrottledOnTimerFired) { … }
class VisibilityAwareResourceSchedulerTest : public ResourceSchedulerTest { … };
TEST_F(VisibilityAwareResourceSchedulerTest, DeprioritizeBackgroundRequest) { … }
TEST_F(VisibilityAwareResourceSchedulerTest, BackgroundRequestIgnoreLimit) { … }
TEST_F(VisibilityAwareResourceSchedulerTest, ChangePriorityBasedOnVisibility) { … }
}
}