// Copyright 2020 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_EXECUTION_CONTEXT_EXECUTION_CONTEXT_H_ #define COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_EXECUTION_CONTEXT_EXECUTION_CONTEXT_H_ #include "base/observer_list_types.h" #include "components/performance_manager/public/execution_context_priority/execution_context_priority.h" #include "third_party/blink/public/common/tokens/tokens.h" class GURL; namespace performance_manager { class FrameNode; class Graph; class ProcessNode; class WorkerNode; PriorityAndReason; namespace execution_context { class ExecutionContextObserver; class ExecutionContextObserverDefaultImpl; // The types of ExecutionContexts that are defined. enum class ExecutionContextType { … }; // An ExecutionContext is a concept from Blink, which denotes a context in // which Javascript can be executed. Roughly speaking, both FrameNodes and // WorkerNodes correspond to ExecutionContexts in the PM world-view. This class // allows external observers to track ExecutionContexts abstractly, without // having to deal with multiple types at runtime, and duplicating lots of code. // // A decorator is responsible for augmenting each instance of a WorkerNode or a // FrameNode with an instance of ExecutionContext which wraps it, and provides // accessors for concepts that are common between these two node types. It also // provides an observer which adapts FrameNodeObserver and WorkerNodeObserver // behind the scenes, so you don't have to. // // Instances of this object are managed by the ExecutionContextRegistry. Their // lifetimes are the same as those of the underlying nodes they wrap. class ExecutionContext { … }; // An observer for ExecutionContexts. class ExecutionContextObserver : public base::CheckedObserver { … }; // A default implementation of ExecutionContextObserver with empty stubs for all // functions. class ExecutionContextObserverDefaultImpl : public ExecutionContextObserver { … }; } // namespace execution_context } // namespace performance_manager #endif // COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_EXECUTION_CONTEXT_EXECUTION_CONTEXT_H_