chromium/chrome/browser/performance_manager/policies/page_discarding_helper.cc

// Copyright 2020 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/performance_manager/policies/page_discarding_helper.h"

#include <memory>
#include <utility>

#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h"
#include "base/sequence_checker.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/performance_manager/mechanisms/page_discarder.h"
#include "chrome/browser/performance_manager/policies/policy_features.h"
#include "components/performance_manager/graph/page_node_impl.h"
#include "components/performance_manager/public/decorators/tab_page_decorator.h"
#include "components/performance_manager/public/graph/frame_node.h"
#include "components/performance_manager/public/graph/graph_operations.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/graph/node_data_describer_util.h"
#include "components/performance_manager/public/graph/page_node.h"
#include "components/performance_manager/public/graph/process_node.h"
#include "components/performance_manager/public/user_tuning/tab_revisit_tracker.h"
#include "components/url_matcher/url_matcher.h"
#include "components/url_matcher/url_util.h"
#include "third_party/abseil-cpp/absl/cleanup/cleanup.h"
#include "url/gurl.h"

PageDiscarder;

namespace performance_manager {
namespace policies {
namespace {

// NodeAttachedData used to indicate that there's already been an attempt to
// discard a PageNode.
// TODO(sebmarchand): The only reason for a discard attempt to fail is if we try
// to discard a prerenderer, remove this once we can detect if a PageNode is a
// prerenderer in CanDiscard().
class DiscardAttemptMarker
    : public ExternalNodeAttachedDataImpl<DiscardAttemptMarker> {};

const char kDescriberName[] =;

NodeRssMap;

// Returns the mapping from page_node to its RSS estimation.
NodeRssMap GetPageNodeRssEstimateKb(
    const std::vector<PageNodeSortProxy>& candidates) {}

void RecordDiscardedTabMetrics(const PageNodeSortProxy& candidate) {}

}  // namespace

PageDiscardingHelper::PageDiscardingHelper()
    :{}
PageDiscardingHelper::~PageDiscardingHelper() = default;

void PageDiscardingHelper::DiscardAPage(
    base::OnceCallback<void(bool)> post_discard_cb,
    DiscardReason discard_reason,
    base::TimeDelta minimum_time_in_background) {}

void PageDiscardingHelper::DiscardMultiplePages(
    std::optional<memory_pressure::ReclaimTarget> reclaim_target,
    bool discard_protected_tabs,
    base::OnceCallback<void(bool)> post_discard_cb,
    DiscardReason discard_reason,
    base::TimeDelta minimum_time_in_background) {}

void PageDiscardingHelper::ImmediatelyDiscardMultiplePages(
    const std::vector<const PageNode*>& page_nodes,
    DiscardReason discard_reason,
    base::OnceCallback<void(bool)> post_discard_cb) {}

void PageDiscardingHelper::SetNoDiscardPatternsForProfile(
    const std::string& browser_context_id,
    const std::vector<std::string>& patterns) {}

void PageDiscardingHelper::ClearNoDiscardPatternsForProfile(
    const std::string& browser_context_id) {}

void PageDiscardingHelper::SetMockDiscarderForTesting(
    std::unique_ptr<PageDiscarder> discarder) {}

// static
void PageDiscardingHelper::AddDiscardAttemptMarkerForTesting(
    PageNode* page_node) {}

// static
void PageDiscardingHelper::RemovesDiscardAttemptMarkerForTesting(
    PageNode* page_node) {}

void PageDiscardingHelper::OnPassedToGraph(Graph* graph) {}

void PageDiscardingHelper::OnTakenFromGraph(Graph* graph) {}

const PageLiveStateDecorator::Data*
PageDiscardingHelper::GetPageNodeLiveStateData(
    const PageNode* page_node) const {}

PageDiscardingHelper::CanDiscardResult PageDiscardingHelper::CanDiscard(
    const PageNode* page_node,
    DiscardReason discard_reason,
    base::TimeDelta minimum_time_in_background) const {}

bool PageDiscardingHelper::IsPageOptedOutOfDiscarding(
    const std::string& browser_context_id,
    const GURL& url) const {}

base::Value::Dict PageDiscardingHelper::DescribePageNodeData(
    const PageNode* node) const {}

void PageDiscardingHelper::PostDiscardAttemptCallback(
    std::optional<memory_pressure::ReclaimTarget> reclaim_target,
    bool discard_protected_tabs,
    base::OnceCallback<void(bool)> post_discard_cb,
    DiscardReason discard_reason,
    base::TimeDelta minimum_time_in_background,
    const std::vector<PageDiscarder::DiscardEvent>& discard_events) {}

}  // namespace policies
}  // namespace performance_manager