// Copyright 2019 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_GRAPH_FRAME_NODE_H_ #define COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_GRAPH_FRAME_NODE_H_ #include <optional> #include "base/containers/flat_set.h" #include "base/observer_list_types.h" #include "base/types/strong_alias.h" #include "components/performance_manager/public/execution_context_priority/execution_context_priority.h" #include "components/performance_manager/public/graph/node.h" #include "components/performance_manager/public/graph/node_set_view.h" #include "components/performance_manager/public/mojom/coordination_unit.mojom.h" #include "components/performance_manager/public/mojom/lifecycle.mojom.h" #include "components/performance_manager/public/resource_attribution/frame_context.h" #include "components/performance_manager/public/viewport_intersection_state.h" #include "content/public/browser/browsing_instance_id.h" #include "content/public/browser/site_instance.h" #include "third_party/blink/public/common/tokens/tokens.h" #include "url/origin.h" class GURL; namespace performance_manager { class FrameNodeObserver; class PageNode; class ProcessNode; class RenderFrameHostProxy; class WorkerNode; PriorityAndReason; // Frame nodes form a tree structure, each FrameNode at most has one parent // that is a FrameNode. Conceptually, a FrameNode corresponds to a // content::RenderFrameHost (RFH) in the browser, and a // content::RenderFrameImpl / blink::LocalFrame in a renderer. // // TODO(crbug.com/40182881): The naming is misleading. In the browser, // FrameTreeNode tracks state about a frame and RenderFrameHost tracks state // about a document loaded into that frame, which can change over time. // (Although RFH doesn't exactly track documents 1:1 either - see // docs/render_document.md for more details.) The PM node types should be // cleaned up to more accurately reflect this. // // Each RFH is part of a frame tree made up of content::FrameTreeNodes (FTNs). // Note that a document in an FTN can be replaced with another, so it is // possible to have multiple "sibling" FrameNodes corresponding to RFHs in the // same FTN. Only one of these may contribute to the content being rendered, // and this node is designated the "current" node in content terminology. // // This can occur, for example, when an in-flight navigation creates a new RFH. // The new RFH will swap with the previously active RFH when the navigation // commits, but until then the two will coexist for the same FTN. // // A swap is effectively atomic but will take place in two steps in the graph: // the outgoing frame will first be marked as not current, and the incoming // frame will be marked as current. As such, the graph invariant is that there // will be 0 or 1 |is_current| FrameNode's for a given FTN. // // It is only valid to access this object on the sequence of the graph that owns // it. class FrameNode : public TypedNode<FrameNode> { … }; // Pure virtual observer interface. Derive from this if you want to be forced to // implement the entire interface. class FrameNodeObserver : public base::CheckedObserver { … }; // Default implementation of observer that provides dummy versions of each // function. Derive from this if you only need to implement a few of the // functions. class FrameNode::ObserverDefaultImpl : public FrameNodeObserver { … }; } // namespace performance_manager #endif // COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_GRAPH_FRAME_NODE_H_