// Copyright 2021 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_BROWSER_RENDERER_HOST_BROWSING_CONTEXT_STATE_H_ #define CONTENT_BROWSER_RENDERER_HOST_BROWSING_CONTEXT_STATE_H_ #include "base/feature_list.h" #include "base/memory/ref_counted.h" #include "base/memory/safe_ref.h" #include "base/unguessable_token.h" #include "content/browser/renderer_host/render_frame_proxy_host.h" #include "content/browser/security/coop/coop_related_group.h" #include "content/browser/site_instance_group.h" #include "content/public/browser/browsing_instance_id.h" #include "third_party/blink/public/mojom/frame/frame_replication_state.mojom-forward.h" #include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h" namespace features { // Currently there are two paths - legacy code, in which BrowsingContextState // will be 1:1 with FrameTreeNode, allowing us to move proxy storage to it as a // no-op, and a new path hidden behind a feature flag, which will create a new // BrowsingContextState for cross-BrowsingInstance navigations. CONTENT_EXPORT extern const base::Feature kNewBrowsingContextStateOnBrowsingContextGroupSwap; enum class BrowsingContextStateImplementationType { … }; CONTENT_EXPORT BrowsingContextStateImplementationType GetBrowsingContextMode(); } // namespace features namespace content { class RenderFrameHostImpl; // BrowsingContextState is intended to store all state associated with a given // browsing context (BrowsingInstance in the code, as defined in the HTML spec // (https://html.spec.whatwg.org/multipage/browsers.html#browsing-context), // in particular RenderFrameProxyHosts and FrameReplicationState. Each // RenderFrameHost will have an associated BrowsingContextState (which never // changes), but each BrowsingContextState can be shared between multiple // RenderFrameHosts for the same frame/FrameTreeNode. // BrowsingContextState is responsible for proxy storage and // RenderFrameHostManager is responsible for connecting different // BrowsingContextStates and creating proxies for appropriate SiteInstances. // A new BCS will be created when a new RenderFrameHost is created for a new // frame or a speculative RFH is created for a cross-BrowsingInstance (browsing // context group in the spec) navigation (speculative RFHs created in the same // BrowsingInstance will use the same BrowsingContextState as the old // RenderFrameHost). For pages stored in bfcache and used for prerendering // activations, BrowsingContextState will travel automatically together with the // RenderFrameHost. // Note: "browsing context" is an HTML spec term (close to a "frame") and it's // different from content::BrowserContext, which represents a "browser profile". // TODO(crbug.com/40205442): Currently it's under implementation and there are // two different modes, controlled by a flag: kLegacyOneToOneWithFrameTreeNode, // where BrowsingContextState is 1:1 with FrameTreeNode and exists for the // duration of the FrameTreeNode lifetime, and // kSwapForCrossBrowsingInstanceNavigations intended state with the behaviour // described above, tied to the lifetime of the RenderFrameHostImpl. // kLegacyOneToOneWithFrameTreeNode is currently enabled and will be removed // once the functionality gated behind kSwapForCrossBrowsingInstanceNavigations // is implemented. class CONTENT_EXPORT BrowsingContextState : public base::RefCounted<BrowsingContextState>, public SiteInstanceGroup::Observer { … }; } // namespace content #endif // CONTENT_BROWSER_RENDERER_HOST_BROWSING_CONTEXT_STATE_H_