chromium/chrome/browser/performance_manager/test_support/site_data_utils.h

// 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.

#ifndef CHROME_BROWSER_PERFORMANCE_MANAGER_TEST_SUPPORT_SITE_DATA_UTILS_H_
#define CHROME_BROWSER_PERFORMANCE_MANAGER_TEST_SUPPORT_SITE_DATA_UTILS_H_

#include <memory>

#include "base/auto_reset.h"
#include "base/functional/callback_helpers.h"
#include "components/performance_manager/test_support/test_harness_helper.h"

class Profile;

namespace content {
class WebContents;
}

namespace performance_manager {

namespace internal {
class SiteDataImpl;
}

class PageNode;

// A test harness that initializes all the components required to use the
// SiteData database in unit_tests. This doesn't support tests that use multiple
// profiles. See comment in the PerformanceManagerTestHarnessHelper class for
// directions on how this should be used in tests.
class SiteDataTestHarness : public PerformanceManagerTestHarnessHelper {};

// Return the SiteDataImpl instance backing a PageNode, this might be null if
// this PageNode isn't loaded with a valid URL.
//
// This function can only be called from the graph's sequence.
internal::SiteDataImpl* GetSiteDataImplForPageNode(PageNode* page_node);

// Pretend that this WebContents has been loaded and is in background.
void MarkWebContentsAsLoadedInBackgroundInSiteDataDb(
    content::WebContents* web_contents);

// Pretend that this WebContents has been unloaded and is in background.
void MarkWebContentsAsUnloadedInBackgroundInSiteDataDb(
    content::WebContents* web_contents);

// Expire all the Site Data Database observation windows for a given
// WebContents.
void ExpireSiteDataObservationWindowsForWebContents(
    content::WebContents* web_contents);

}  // namespace performance_manager

#endif  // CHROME_BROWSER_PERFORMANCE_MANAGER_TEST_SUPPORT_SITE_DATA_UTILS_H_