chromium/chrome/browser/performance_manager/mechanisms/page_discarder.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/mechanisms/page_discarder.h"

#include <utility>
#include <vector>

#include "base/functional/bind.h"
#include "base/memory/weak_ptr.h"
#include "base/task/task_traits.h"
#include "build/build_config.h"
#include "chrome/browser/performance_manager/public/user_tuning/user_tuning_utils.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "components/performance_manager/public/graph/page_node.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"

namespace performance_manager {
namespace mechanism {
namespace {

bool disabled_for_testing =;

WebContentsAndPmf;

// Discards pages on the UI thread. Returns true if at least 1 page is
// discarded.
// TODO(crbug.com/40194498): Returns the remaining reclaim target so
// UrgentlyDiscardMultiplePages can keep reclaiming until the reclaim target is
// met or there is no discardable page.
std::vector<PageDiscarder::DiscardEvent> DiscardPagesOnUIThread(
    const std::vector<WebContentsAndPmf>& web_contents_and_pmf,
    resource_coordinator::LifecycleUnitDiscardReason discard_reason) {}

}  // namespace

// static
void PageDiscarder::DisableForTesting() {}

void PageDiscarder::DiscardPageNodes(
    const std::vector<const PageNode*>& page_nodes,
    resource_coordinator::LifecycleUnitDiscardReason discard_reason,
    base::OnceCallback<void(const std::vector<DiscardEvent>&)>
        post_discard_cb) {}

}  // namespace mechanism
}  // namespace performance_manager