#include "components/performance_manager/freezing/freezing_policy.h"
#include <vector>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "components/performance_manager/graph/page_node_impl.h"
#include "components/performance_manager/public/features.h"
#include "components/performance_manager/public/graph/node_attached_data.h"
#include "components/performance_manager/public/graph/node_data_describer_registry.h"
#include "components/performance_manager/public/resource_attribution/origin_in_browsing_instance_context.h"
#include "components/performance_manager/public/resource_attribution/resource_contexts.h"
#include "components/performance_manager/public/resource_attribution/resource_types.h"
namespace performance_manager {
namespace {
OriginInBrowsingInstanceContext;
constexpr base::TimeDelta kCPUMeasurementInterval = …;
struct PageFreezingState
: public ExternalNodeAttachedDataImpl<PageFreezingState> { … };
bool IsPageConnectedToUSBDevice(const PageNode* page_node) { … }
bool IsPageConnectedToBluetoothDevice(const PageNode* page_node) { … }
bool IsPageCapturingVideo(const PageNode* page_node) { … }
bool IsPageCapturingAudio(const PageNode* page_node) { … }
bool IsPageBeingMirrored(const PageNode* page_node) { … }
bool IsPageCapturingWindow(const PageNode* page_node) { … }
bool IsPageCapturingDisplay(const PageNode* page_node) { … }
}
FreezingPolicy::FreezingPolicy()
: … { … }
FreezingPolicy::~FreezingPolicy() = default;
void FreezingPolicy::ToggleFreezingOnBatterySaverMode(bool is_enabled) { … }
void FreezingPolicy::AddFreezeVote(PageNode* page_node) { … }
void FreezingPolicy::RemoveFreezeVote(PageNode* page_node) { … }
FreezingPolicy::BrowsingInstanceState::BrowsingInstanceState() = default;
FreezingPolicy::BrowsingInstanceState::~BrowsingInstanceState() = default;
base::flat_set<content::BrowsingInstanceId>
FreezingPolicy::GetBrowsingInstances(const PageNode* page) const { … }
void FreezingPolicy::UpdateFrozenState(
const PageNode* page,
base::flat_set<raw_ptr<const PageNode>>* connected_pages_out) { … }
void FreezingPolicy::OnCannotFreezeReasonChange(const PageNode* page_node,
bool add,
CannotFreezeReason reason) { … }
bool FreezingPolicy::HasCannotFreezeReason(
const BrowsingInstanceState& browsing_instance_state) { … }
void FreezingPolicy::OnPassedToGraph(Graph* graph) { … }
void FreezingPolicy::OnTakenFromGraph(Graph* graph) { … }
void FreezingPolicy::OnPageNodeAdded(const PageNode* page_node) { … }
void FreezingPolicy::OnBeforePageNodeRemoved(const PageNode* page_node) { … }
void FreezingPolicy::OnIsVisibleChanged(const PageNode* page_node) { … }
void FreezingPolicy::OnIsAudibleChanged(const PageNode* page_node) { … }
void FreezingPolicy::OnPageIsHoldingWebLockChanged(const PageNode* page_node) { … }
void FreezingPolicy::OnPageIsHoldingIndexedDBLockChanged(
const PageNode* page_node) { … }
void FreezingPolicy::OnLoadingStateChanged(
const PageNode* page_node,
PageNode::LoadingState previous_state) { … }
void FreezingPolicy::OnFrameNodeAdded(const FrameNode* frame_node) { … }
void FreezingPolicy::OnBeforeFrameNodeRemoved(const FrameNode* frame_node) { … }
void FreezingPolicy::OnIsAudibleChanged(const FrameNode* frame_node) { … }
void FreezingPolicy::OnIsConnectedToUSBDeviceChanged(
const PageNode* page_node) { … }
void FreezingPolicy::OnIsConnectedToBluetoothDeviceChanged(
const PageNode* page_node) { … }
void FreezingPolicy::OnIsCapturingVideoChanged(const PageNode* page_node) { … }
void FreezingPolicy::OnIsCapturingAudioChanged(const PageNode* page_node) { … }
void FreezingPolicy::OnIsBeingMirroredChanged(const PageNode* page_node) { … }
void FreezingPolicy::OnIsCapturingWindowChanged(const PageNode* page_node) { … }
void FreezingPolicy::OnIsCapturingDisplayChanged(const PageNode* page_node) { … }
base::Value::Dict FreezingPolicy::DescribePageNodeData(
const PageNode* node) const { … }
void FreezingPolicy::OnResourceUsageUpdated(
const resource_attribution::QueryResultMap& results) { … }
}