#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 {
class SchedulerTaskRunner { … };
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) { … }
}
QueryScheduler::QueryScheduler() = default;
QueryScheduler::~QueryScheduler() = default;
base::WeakPtr<QueryScheduler> QueryScheduler::GetWeakPtr() { … }
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) { … }
}