[PM] Create V8ContextTracker helpers.
This defines types and utility functions that will be used by the
V8ContextTracker implementation.
BUG=1085129
Change-Id: I6dec02d26191a60aa3545133bbe826998693a538
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427849
Commit-Queue: Chris Hamilton <[email protected]>
Auto-Submit: Chris Hamilton <[email protected]>
Reviewed-by: Joe Mason <[email protected]>
Cr-Commit-Position: refs/heads/master@{#812102}
diff --git a/components/performance_manager/public/graph/graph.h b/components/performance_manager/public/graph/graph.h
index 4e45c4e1..b48e1a47 100644
--- a/components/performance_manager/public/graph/graph.h
+++ b/components/performance_manager/public/graph/graph.h
@@ -67,10 +67,19 @@
// For convenience, allows you to pass ownership of an object to the graph.
// Useful for attaching observers that will live with the graph until it dies.
// If you can name the object you can also take it back via "TakeFromGraph".
- virtual void PassToGraph(std::unique_ptr<GraphOwned> graph_owned) = 0;
+ virtual void PassToGraphImpl(std::unique_ptr<GraphOwned> graph_owned) = 0;
virtual std::unique_ptr<GraphOwned> TakeFromGraph(
GraphOwned* graph_owned) = 0;
+ // Templated PassToGraph helper that also returns a pointer to the object,
+ // which makes it easy to use PassToGraph in constructors.
+ template <typename DerivedType>
+ DerivedType* PassToGraph(std::unique_ptr<DerivedType> graph_owned) {
+ DerivedType* object = graph_owned.get();
+ PassToGraphImpl(std::move(graph_owned));
+ return object;
+ }
+
// A TakeFromGraph helper for taking back the ownership of a GraphOwned
// subclass.
template <typename DerivedType>