chromium/components/performance_manager/resource_attribution/query_scheduler.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/performance_manager/resource_attribution/query_scheduler.h"

#include <optional>
#include <set>
#include <utility>
#include <vector>

#include "base/barrier_callback.h"
#include "base/check_op.h"
#include "base/containers/enum_set.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/no_destructor.h"
#include "base/notreached.h"
#include "base/synchronization/lock.h"
#include "base/task/sequenced_task_runner.h"
#include "base/types/optional_util.h"
#include "base/types/pass_key.h"
#include "base/types/variant_util.h"
#include "components/performance_manager/public/graph/graph.h"
#include "components/performance_manager/public/graph/node_data_describer_registry.h"
#include "components/performance_manager/public/performance_manager.h"
#include "components/performance_manager/public/resource_attribution/resource_types.h"
#include "components/performance_manager/resource_attribution/context_collection.h"
#include "components/performance_manager/resource_attribution/performance_manager_aliases.h"
#include "components/performance_manager/resource_attribution/query_params.h"

namespace resource_attribution::internal {

namespace {

// A global singleton that holds the TaskRunner the QueryScheduler runs on. In
// production this is the PM graph sequence, but in unit tests it can be the
// main thread. The TaskRunner is set when the QueryScheduler is passed to the
// PM graph, so it will be reset between tests and can be null during graph
// teardown.
//
// This is used instead of CallOnGraph because there are many
// resource attribution tests that use GraphTestHarness and mock graphs instead
// of PerformanceManagerTestHarness, that don't use any PerformanceManager hooks
// except for the QueryScheduler.
class SchedulerTaskRunner {};

// static
SchedulerTaskRunner* SchedulerTaskRunner::GetInstance() {}

void SchedulerTaskRunner::OnSchedulerPassedToGraph(Graph* graph) {}

void SchedulerTaskRunner::OnSchedulerTakenFromGraph(Graph* graph) {}

scoped_refptr<base::SequencedTaskRunner> SchedulerTaskRunner::GetTaskRunner() {}

void SchedulerTaskRunner::CallWithScheduler(
    base::OnceCallback<void(QueryScheduler*)> callback) {}

}  // namespace

QueryScheduler::QueryScheduler() = default;

QueryScheduler::~QueryScheduler() = default;

base::WeakPtr<QueryScheduler> QueryScheduler::GetWeakPtr() {}

// static
void QueryScheduler::CallWithScheduler(
    base::OnceCallback<void(QueryScheduler*)> callback,
    const base::Location& location) {}

void QueryScheduler::AddScopedQuery(QueryParams* query_params) {}

void QueryScheduler::RemoveScopedQuery(
    std::unique_ptr<QueryParams> query_params) {}

void QueryScheduler::StartRepeatingQuery(QueryParams* query_params) {}

void QueryScheduler::RequestResults(
    const QueryParams& query_params,
    base::OnceCallback<void(const QueryResultMap&)> callback) {}

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

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

CPUMeasurementMonitor& QueryScheduler::GetCPUMonitorForTesting() {}

MemoryMeasurementProvider& QueryScheduler::GetMemoryProviderForTesting() {}

uint32_t QueryScheduler::GetQueryCountForTesting(
    ResourceType resource_type) const {}

void QueryScheduler::RecordMemoryMetrics() {}

void QueryScheduler::AddCPUQuery() {}

void QueryScheduler::RemoveCPUQuery() {}

void QueryScheduler::AddMemoryQuery() {}

void QueryScheduler::RemoveMemoryQuery() {}

void QueryScheduler::OnResultsReceived(
    const ContextCollection& contexts,
    base::OnceCallback<void(const QueryResultMap&)> callback,
    std::vector<QueryResultMap> all_results) {}

}  // namespace resource_attribution::internal