-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add QueryScheduler and make CPUMeasurementMonitor private
The QueryScheduler class is now the sole owner of CPUMeasurementMonitor, allowing it to multiplex multiple queries to the same monitor. To replace the public uses of CPUMeasurementMonitor, adds a temporary ScopedCPUQuery class that will be replaced by the full resource attribution QueryBuilder when it's ready. Bug: 1471683 Change-Id: I915b5f94822d978956559b3e021ee9f939bd40ce Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4950877 Commit-Queue: Joe Mason <joenotcharles@google.com> Auto-Submit: Joe Mason <joenotcharles@google.com> Reviewed-by: Patrick Monette <pmonette@chromium.org> Cr-Commit-Position: refs/heads/main@{#1212573}
- Loading branch information
1 parent
aa80c93
commit e615ef1
Showing
20 changed files
with
397 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
components/performance_manager/public/resource_attribution/scoped_cpu_query.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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. | ||
|
||
#ifndef COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_RESOURCE_ATTRIBUTION_SCOPED_CPU_QUERY_H_ | ||
#define COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_RESOURCE_ATTRIBUTION_SCOPED_CPU_QUERY_H_ | ||
|
||
#include "base/memory/weak_ptr.h" | ||
#include "components/performance_manager/public/resource_attribution/query_results.h" | ||
|
||
namespace performance_manager { | ||
class Graph; | ||
} | ||
|
||
namespace performance_manager::resource_attribution { | ||
|
||
class QueryScheduler; | ||
|
||
// A temporary public interface to request CPU measurements. As soon as a | ||
// ScopedCPUQuery instance is created, CPUMeasurementMonitor will begin | ||
// monitoring CPU usage. When no more instances exist, it will stop. | ||
// | ||
// TODO(crbug.com/1471683): Replace this with the full Resource Attribution | ||
// query API described in bit.ly/resource-attribution-api. | ||
class ScopedCPUQuery { | ||
public: | ||
explicit ScopedCPUQuery(Graph* graph); | ||
~ScopedCPUQuery(); | ||
|
||
ScopedCPUQuery(const ScopedCPUQuery&) = delete; | ||
ScopedCPUQuery& operator=(const ScopedCPUQuery&) = delete; | ||
|
||
// Requests the current CPU measurements. | ||
QueryResultMap QueryOnce(); | ||
|
||
private: | ||
base::WeakPtr<QueryScheduler> scheduler_; | ||
}; | ||
|
||
} // namespace performance_manager::resource_attribution | ||
|
||
#endif // COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_RESOURCE_ATTRIBUTION_SCOPED_CPU_QUERY_H_ |
26 changes: 26 additions & 0 deletions
26
components/performance_manager/resource_attribution/cpu_measurement_delegate.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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/public/resource_attribution/cpu_measurement_delegate.h" | ||
|
||
#include <utility> | ||
|
||
#include "base/check.h" | ||
#include "components/performance_manager/resource_attribution/cpu_measurement_monitor.h" | ||
#include "components/performance_manager/resource_attribution/query_scheduler.h" | ||
|
||
namespace performance_manager::resource_attribution { | ||
|
||
void CPUMeasurementDelegate::SetDelegateFactoryForTesting( | ||
Graph* graph, | ||
FactoryCallback factory_callback) { | ||
auto* scheduler = QueryScheduler::GetFromGraph(graph); | ||
CHECK(scheduler); | ||
scheduler | ||
->GetCPUMonitorForTesting() // IN-TEST | ||
.SetCPUMeasurementDelegateFactoryForTesting( // IN-TEST | ||
std::move(factory_callback)); | ||
} | ||
|
||
} // namespace performance_manager::resource_attribution |
Oops, something went wrong.