#include "chrome/browser/resource_coordinator/session_restore_policy.h"
#include <math.h>
#include <algorithm>
#include <utility>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/no_destructor.h"
#include "base/not_fatal_until.h"
#include "base/sequence_checker.h"
#include "base/system/sys_info.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/resource_coordinator/tab_manager_features.h"
#include "chrome/common/url_constants.h"
#include "components/performance_manager/public/decorators/site_data_recorder.h"
#include "components/performance_manager/public/graph/graph.h"
#include "components/performance_manager/public/performance_manager.h"
#include "components/performance_manager/public/persistence/site_data/site_data_reader.h"
#include "components/site_engagement/content/site_engagement_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/permission_controller.h"
#include "content/public/browser/web_contents.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#endif
namespace resource_coordinator {
namespace {
bool IsApp(content::WebContents* contents) { … }
bool IsInternalPage(content::WebContents* contents) { … }
class SysInfoDelegate : public SessionRestorePolicy::Delegate { … };
}
#if !BUILDFLAG(IS_ANDROID)
class TabDataAccess { … };
void TabDataAccess::SetUsedInBgFromSiteDataDB(
base::WeakPtr<SessionRestorePolicy> policy,
TabData* tab_data,
content::WebContents* contents) { … }
void TabDataAccess::SetUsedInBgFromSiteData(
TabData* tab_data,
content::WebContents* contents,
TabData::SiteDataReaderData reader_data) { … }
void TabDataAccess::OnSiteDataAvailable(
base::WeakPtr<SessionRestorePolicy> policy,
content::WebContents* contents,
TabData::SiteDataReaderData reader_data) { … }
#endif
SessionRestorePolicy::SessionRestorePolicy()
: … { … }
SessionRestorePolicy::~SessionRestorePolicy() = default;
float SessionRestorePolicy::AddTabForScoring(content::WebContents* contents) { … }
void SessionRestorePolicy::RemoveTabForScoring(content::WebContents* contents) { … }
bool SessionRestorePolicy::ShouldLoad(content::WebContents* contents) const { … }
void SessionRestorePolicy::NotifyTabLoadStarted() { … }
SessionRestorePolicy::SessionRestorePolicy(bool policy_enabled,
const Delegate* delegate)
: … { … }
size_t SessionRestorePolicy::CalculateSimultaneousTabLoads(
size_t min_loads,
size_t max_loads,
size_t cores_per_load,
size_t num_cores) { … }
size_t SessionRestorePolicy::CalculateSimultaneousTabLoads() const { … }
void SessionRestorePolicy::DispatchNotifyAllTabsScoredIfNeeded() { … }
void SessionRestorePolicy::NotifyAllTabsScored() { … }
bool SessionRestorePolicy::RescoreTabAfterDataLoaded(
content::WebContents* contents ,
TabData* tab_data) { … }
bool SessionRestorePolicy::ScoreTab(TabData* tab_data) { … }
float SessionRestorePolicy::CalculateAgeScore(const TabData* tab_data) { … }
bool SessionRestorePolicy::HasFinalScore(const TabData* tab_data) { … }
void SessionRestorePolicy::SetTabLoadsStartedForTesting(
size_t tab_loads_started) { … }
void SessionRestorePolicy::UpdateSiteEngagementScoreForTesting(
content::WebContents* contents,
size_t score) { … }
SessionRestorePolicy::Delegate::Delegate() { … }
SessionRestorePolicy::Delegate::~Delegate() { … }
SessionRestorePolicy::TabData::TabData() = default;
SessionRestorePolicy::TabData::~TabData() { … }
bool SessionRestorePolicy::TabData::UsedInBg() const { … }
}