// Copyright 2018 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_SERVICES_STORAGE_DOM_STORAGE_SESSION_STORAGE_NAMESPACE_IMPL_H_ #define COMPONENTS_SERVICES_STORAGE_DOM_STORAGE_SESSION_STORAGE_NAMESPACE_IMPL_H_ #include <map> #include <memory> #include <vector> #include "base/containers/flat_set.h" #include "base/functional/callback.h" #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "components/services/storage/dom_storage/session_storage_area_impl.h" #include "components/services/storage/dom_storage/session_storage_data_map.h" #include "components/services/storage/dom_storage/session_storage_metadata.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "third_party/blink/public/common/storage_key/storage_key.h" #include "third_party/blink/public/mojom/dom_storage/session_storage_namespace.mojom.h" namespace storage { class AsyncDomStorageDatabase; // Implements the Blink SessionStorageNamespace interface. Stores data maps per // StorageKey, which are accessible using the StorageArea interface with the // |OpenArea| call. Supports cloning (shallow cloning with copy-on-write // behavior) from another SessionStorageNamespaceImpl. // // This class is populated & bound in the following patterns: // 1. The namespace is new or being populated from data on disk, and // |PopulateFromMetadata| is called. Afterwards |Bind| can be called. // 2. The namespace is being created as a clone from a |Clone| call on another // SessionStorageNamespaceImpl. PopulateFromMetadata is called with the // data from the other namespace, and then |Bind| can be called afterwards. // 3. The namespace is being created as a clone, but the |Clone| call from the // source namespace hasn't been called yet. // |set_pending_population_from_namespace| is called first, after which // |Bind| can be called. The actually binding doesn't happen until // |PopulateAsClone| is finally called with the source namespace data. // Note: The reason for cases 2 and 3 is because there are two ways the Session // Storage system knows about clones. First, it gets the |Clone| call on the // source namespace, coming from the renderer doing the navigation, and in the // correct order with any session storage modifications from that source // renderer. Second, the RenderViewHostImpl of the navigated-to-frame will // create the cloned namespace and expect to manage it's lifetime that way, and // this can happen before the first case, as they are on different task runners. class SessionStorageNamespaceImpl final : public blink::mojom::SessionStorageNamespace { … }; } // namespace storage #endif // COMPONENTS_SERVICES_STORAGE_DOM_STORAGE_SESSION_STORAGE_NAMESPACE_IMPL_H_