chromium/chrome/browser/predictors/loading_predictor.cc

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

#include "chrome/browser/predictors/loading_predictor.h"

#include <algorithm>
#include <vector>

#include "base/metrics/histogram_functions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/after_startup_task_utils.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/predictors/lcp_critical_path_predictor/lcp_critical_path_predictor_util.h"
#include "chrome/browser/predictors/lcp_critical_path_predictor/prewarm_http_disk_cache_manager.h"
#include "chrome/browser/predictors/loading_data_collector.h"
#include "chrome/browser/predictors/loading_stats_collector.h"
#include "chrome/browser/predictors/predictors_features.h"
#include "chrome/browser/predictors/resource_prefetch_predictor.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/origin_util.h"
#include "net/base/network_anonymization_key.h"
#include "services/network/public/cpp/network_quality_tracker.h"
#include "services/network/public/cpp/request_destination.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "url/origin.h"

#if BUILDFLAG(IS_ANDROID)
#include "base/android/radio_utils.h"
#include "base/power_monitor/power_monitor.h"
#endif  // BUILDFLAG(IS_ANDROID)

namespace features {

// Don't preconnect on weak signal to save power.
BASE_FEATURE();
BASE_FEATURE();

// If enabled, suppresses LoadingPredictor (https://crbug.com/350519234)
BASE_FEATURE();

const base::FeatureParam<base::TimeDelta>
    kSuppressesLoadingPredictorOnSlowNetworkThreshold{};

}  // namespace features

namespace predictors {

namespace {

const base::TimeDelta kMinDelayBetweenPreresolveRequests =;
const base::TimeDelta kMinDelayBetweenPreconnectRequests =;

// Returns true iff |prediction| is not empty.
bool AddInitialUrlToPreconnectPrediction(const GURL& initial_url,
                                         PreconnectPrediction* prediction) {}

bool IsPreconnectExpensive() {}

void MaybeWarmUpServiceWorker(const GURL& url, Profile* profile) {}

}  // namespace

LoadingPredictor::LoadingPredictor(const LoadingPredictorConfig& config,
                                   Profile* profile)
    :{}

LoadingPredictor::~LoadingPredictor() {}

bool LoadingPredictor::PrepareForPageLoad(
    const std::optional<url::Origin>& initiator_origin,
    const GURL& url,
    HintOrigin origin,
    bool preconnectable,
    std::optional<PreconnectPrediction> preconnect_prediction) {}

void LoadingPredictor::CancelPageLoadHint(const GURL& url) {}

void LoadingPredictor::StartInitialization() {}

LoadingDataCollector* LoadingPredictor::loading_data_collector() {}

ResourcePrefetchPredictor* LoadingPredictor::resource_prefetch_predictor() {}

PreconnectManager* LoadingPredictor::preconnect_manager() {}

PrefetchManager* LoadingPredictor::prefetch_manager() {}

void LoadingPredictor::Shutdown() {}

bool LoadingPredictor::OnNavigationStarted(
    NavigationId navigation_id,
    ukm::SourceId ukm_source_id,
    const std::optional<url::Origin>& initiator_origin,
    const GURL& main_frame_url,
    base::TimeTicks creation_time) {}

void LoadingPredictor::OnNavigationFinished(NavigationId navigation_id,
                                            const GURL& old_main_frame_url,
                                            const GURL& new_main_frame_url,
                                            bool is_error_page) {}

std::map<GURL, base::TimeTicks>::iterator LoadingPredictor::CancelActiveHint(
    std::map<GURL, base::TimeTicks>::iterator hint_it) {}

void LoadingPredictor::CleanupAbandonedHintsAndNavigations(
    NavigationId navigation_id) {}

void LoadingPredictor::MaybeAddPreconnect(const GURL& url,
                                          PreconnectPrediction prediction) {}

void LoadingPredictor::MaybeRemovePreconnect(const GURL& url) {}

bool LoadingPredictor::HandleHintByOrigin(const GURL& url,
                                          bool preconnectable,
                                          bool only_allow_https,
                                          PreconnectData& preconnect_data) {}

void LoadingPredictor::PreconnectInitiated(const GURL& url,
                                           const GURL& preconnect_url) {}

void LoadingPredictor::PreconnectFinished(
    std::unique_ptr<PreconnectStats> stats) {}

void LoadingPredictor::PrefetchInitiated(const GURL& url,
                                         const GURL& prefetch_url) {}

void LoadingPredictor::PrefetchFinished(std::unique_ptr<PrefetchStats> stats) {}

void LoadingPredictor::PreconnectURLIfAllowed(
    const GURL& url,
    bool allow_credentials,
    const net::NetworkAnonymizationKey& network_anonymization_key) {}

void LoadingPredictor::MaybePrewarmResources(
    const std::optional<url::Origin>& initiator_origin,
    const GURL& top_frame_main_resource_url) {}

}  // namespace predictors