// 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_DECORATORS_TAB_PAGE_DECORATOR_H_ #define COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_DECORATORS_TAB_PAGE_DECORATOR_H_ #include "base/memory/raw_ptr.h" #include "base/observer_list.h" #include "base/observer_list_types.h" #include "base/sequence_checker.h" #include "components/performance_manager/public/graph/graph.h" #include "components/performance_manager/public/graph/graph_registered.h" #include "components/performance_manager/public/graph/page_node.h" namespace performance_manager { class TabPageObserver; // A decorator that adorns `PageNode`s with some data that allows it to provide // a stable handle to a tab, even though the underlying `PageNode` associated // with that tab might change due to tab discarding. Registering as an observer // or using the `FromPageNode` function allows callers to obtain a pointer to a // `TabHandle` object whose `page_node()` function always points to the // `PageNode` associated with the tab. class TabPageDecorator : public PageNode::ObserverDefaultImpl, public GraphOwnedAndRegistered<TabPageDecorator> { … }; // A stable handle to a tab. Objects of this class are created when a `PageNode` // becomes a tab, and are only destroyed when that tab is closed. During tab // discarding, the `PageNode` returned by `page_node()` will change. Callers may // store pointers to `TabHandle` objects until // `TabPageObserver::OnBeforeTabRemoved` is called for said `TabHandle` object, // and they are guaranteed that `page_node()` will return the `PageNode` // associated with the tab. class TabPageDecorator::TabHandle { … }; class TabPageObserver : public base::CheckedObserver { … }; class TabPageObserverDefaultImpl : public TabPageObserver { … }; } // namespace performance_manager #endif // COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_DECORATORS_TAB_PAGE_DECORATOR_H_