Commit e26261eb authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Move SessionStorageMetadata into Storage Service

This is a strictly mechanical move of SessionStorageMetadata out of
Content and into Storage Service. Also moves SessionStorageDatabase (a
test-only helper used by SessionStorageMetadata tests) into the
service's test_support library, renamed to
TestingLegacySessionStorageDatabase.

Bug: 1000959
Change-Id: Ie852fc1b2b8f94e116e92f8d513086328555a85d
Tbr: dcheng@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1958429
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723492}
parent 4177d2f1
...@@ -152,7 +152,6 @@ class RTCVideoDecoder; ...@@ -152,7 +152,6 @@ class RTCVideoDecoder;
class SandboxHostLinux; class SandboxHostLinux;
class ScopedAllowWaitForDebugURL; class ScopedAllowWaitForDebugURL;
class ServiceWorkerContextClient; class ServiceWorkerContextClient;
class SessionStorageDatabase;
class SoftwareOutputDeviceMus; class SoftwareOutputDeviceMus;
class SynchronousCompositor; class SynchronousCompositor;
class SynchronousCompositorHost; class SynchronousCompositorHost;
...@@ -421,7 +420,6 @@ class BASE_EXPORT ScopedAllowBaseSyncPrimitives { ...@@ -421,7 +420,6 @@ class BASE_EXPORT ScopedAllowBaseSyncPrimitives {
friend class content::BrowserMainLoop; friend class content::BrowserMainLoop;
friend class content::BrowserProcessSubThread; friend class content::BrowserProcessSubThread;
friend class content::ServiceWorkerContextClient; friend class content::ServiceWorkerContextClient;
friend class content::SessionStorageDatabase;
friend class functions::ExecScriptScopedAllowBaseSyncPrimitives; friend class functions::ExecScriptScopedAllowBaseSyncPrimitives;
friend class history_report::HistoryReportJniBridge; friend class history_report::HistoryReportJniBridge;
friend class internal::TaskTracker; friend class internal::TaskTracker;
......
...@@ -16,6 +16,8 @@ source_set("storage") { ...@@ -16,6 +16,8 @@ source_set("storage") {
"dom_storage/legacy_dom_storage_database.h", "dom_storage/legacy_dom_storage_database.h",
"dom_storage/local_storage_impl.cc", "dom_storage/local_storage_impl.cc",
"dom_storage/local_storage_impl.h", "dom_storage/local_storage_impl.h",
"dom_storage/session_storage_metadata.cc",
"dom_storage/session_storage_metadata.h",
"dom_storage/storage_area_impl.cc", "dom_storage/storage_area_impl.cc",
"dom_storage/storage_area_impl.h", "dom_storage/storage_area_impl.h",
"indexed_db/leveldb/leveldb_factory.cc", "indexed_db/leveldb/leveldb_factory.cc",
...@@ -68,6 +70,7 @@ source_set("storage") { ...@@ -68,6 +70,7 @@ source_set("storage") {
"//components/services/storage/public/mojom", "//components/services/storage/public/mojom",
"//mojo/public/cpp/bindings", "//mojo/public/cpp/bindings",
"//sql", "//sql",
"//third_party/blink/public/common",
"//third_party/leveldatabase", "//third_party/leveldatabase",
"//third_party/sqlite", "//third_party/sqlite",
"//url", "//url",
...@@ -86,6 +89,7 @@ source_set("tests") { ...@@ -86,6 +89,7 @@ source_set("tests") {
"dom_storage/dom_storage_database_unittest.cc", "dom_storage/dom_storage_database_unittest.cc",
"dom_storage/legacy_dom_storage_database_unittest.cc", "dom_storage/legacy_dom_storage_database_unittest.cc",
"dom_storage/local_storage_impl_unittest.cc", "dom_storage/local_storage_impl_unittest.cc",
"dom_storage/session_storage_metadata_unittest.cc",
"dom_storage/storage_area_impl_unittest.cc", "dom_storage/storage_area_impl_unittest.cc",
"indexed_db/scopes/disjoint_range_lock_manager_unittest.cc", "indexed_db/scopes/disjoint_range_lock_manager_unittest.cc",
"indexed_db/scopes/leveldb_scope_unittest.cc", "indexed_db/scopes/leveldb_scope_unittest.cc",
...@@ -122,6 +126,8 @@ source_set("test_support") { ...@@ -122,6 +126,8 @@ source_set("test_support") {
sources = [ sources = [
"dom_storage/storage_area_test_util.cc", "dom_storage/storage_area_test_util.cc",
"dom_storage/storage_area_test_util.h", "dom_storage/storage_area_test_util.h",
"dom_storage/testing_legacy_session_storage_database.cc",
"dom_storage/testing_legacy_session_storage_database.h",
"indexed_db/leveldb/fake_leveldb_factory.cc", "indexed_db/leveldb/fake_leveldb_factory.cc",
"indexed_db/leveldb/fake_leveldb_factory.h", "indexed_db/leveldb/fake_leveldb_factory.h",
"indexed_db/leveldb/mock_level_db.cc", "indexed_db/leveldb/mock_level_db.cc",
......
include_rules = [ include_rules = [
"+third_party/blink/public/common",
"+third_party/leveldatabase", "+third_party/leveldatabase",
] ]
// Copyright 2018 The Chromium Authors. All rights reserved. // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_METADATA_H_
#define CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_METADATA_H_ #ifndef COMPONENTS_SERVICES_STORAGE_DOM_STORAGE_SESSION_STORAGE_METADATA_H_
#define COMPONENTS_SERVICES_STORAGE_DOM_STORAGE_SESSION_STORAGE_METADATA_H_
#include <stdint.h> #include <stdint.h>
#include <map> #include <map>
...@@ -12,14 +13,13 @@ ...@@ -12,14 +13,13 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "components/services/storage/dom_storage/async_dom_storage_database.h" #include "components/services/storage/dom_storage/async_dom_storage_database.h"
#include "components/services/storage/dom_storage/dom_storage_database.h" #include "components/services/storage/dom_storage/dom_storage_database.h"
#include "content/common/content_export.h"
#include "url/origin.h" #include "url/origin.h"
namespace content { namespace storage {
// Holds the metadata information for a session storage database. This includes // Holds the metadata information for a session storage database. This includes
// logic for parsing and saving database content. // logic for parsing and saving database content.
class CONTENT_EXPORT SessionStorageMetadata { class SessionStorageMetadata {
public: public:
// Version 0 represents the old SessionStorageDatabase where we never stored a // Version 0 represents the old SessionStorageDatabase where we never stored a
// version. This class stores '0' as the version in this case. Version 1 // version. This class stores '0' as the version in this case. Version 1
...@@ -45,7 +45,7 @@ class CONTENT_EXPORT SessionStorageMetadata { ...@@ -45,7 +45,7 @@ class CONTENT_EXPORT SessionStorageMetadata {
// The |DeleteNamespace| and |DeleteArea| methods can destroy any MapData // The |DeleteNamespace| and |DeleteArea| methods can destroy any MapData
// objects who are no longer referenced by another namespace. // objects who are no longer referenced by another namespace.
// Maps (and thus MapData objects) can only be shared for the same origin. // Maps (and thus MapData objects) can only be shared for the same origin.
class CONTENT_EXPORT MapData : public base::RefCounted<MapData> { class MapData : public base::RefCounted<MapData> {
public: public:
explicit MapData(int64_t map_number, url::Origin origin); explicit MapData(int64_t map_number, url::Origin origin);
...@@ -87,8 +87,7 @@ class CONTENT_EXPORT SessionStorageMetadata { ...@@ -87,8 +87,7 @@ class CONTENT_EXPORT SessionStorageMetadata {
// For a new database, this saves the database version, clears the metadata, // For a new database, this saves the database version, clears the metadata,
// and returns the operations needed to save to disk. // and returns the operations needed to save to disk.
std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask> std::vector<AsyncDomStorageDatabase::BatchDatabaseTask> SetupNewDatabase();
SetupNewDatabase();
// This parses the database version from the bytes that were stored on // This parses the database version from the bytes that were stored on
// disk, or if there was no version saved then passes a base::nullopt. This // disk, or if there was no version saved then passes a base::nullopt. This
...@@ -100,8 +99,7 @@ class CONTENT_EXPORT SessionStorageMetadata { ...@@ -100,8 +99,7 @@ class CONTENT_EXPORT SessionStorageMetadata {
// Returns |true| if the parsing is correct and we support the version read. // Returns |true| if the parsing is correct and we support the version read.
bool ParseDatabaseVersion( bool ParseDatabaseVersion(
base::Optional<std::vector<uint8_t>> value, base::Optional<std::vector<uint8_t>> value,
std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask>* std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>* upgrade_tasks);
upgrade_tasks);
// Parses all namespaces and maps, and stores all metadata locally. This // Parses all namespaces and maps, and stores all metadata locally. This
// invalidates all NamespaceEntry and MapData objects. If there is a parsing // invalidates all NamespaceEntry and MapData objects. If there is a parsing
...@@ -110,9 +108,8 @@ class CONTENT_EXPORT SessionStorageMetadata { ...@@ -110,9 +108,8 @@ class CONTENT_EXPORT SessionStorageMetadata {
// will be populated in |upgrade_tasks|. This call is not necessary on new // will be populated in |upgrade_tasks|. This call is not necessary on new
// databases. // databases.
bool ParseNamespaces( bool ParseNamespaces(
std::vector<storage::DomStorageDatabase::KeyValuePair> values, std::vector<DomStorageDatabase::KeyValuePair> values,
std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask>* std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>* upgrade_tasks);
upgrade_tasks);
// Parses the next map id from the given bytes. If that fails, then it uses // Parses the next map id from the given bytes. If that fails, then it uses
// the next available id from parsing the namespaces. This call is not // the next available id from parsing the namespaces. This call is not
...@@ -129,8 +126,7 @@ class CONTENT_EXPORT SessionStorageMetadata { ...@@ -129,8 +126,7 @@ class CONTENT_EXPORT SessionStorageMetadata {
scoped_refptr<MapData> RegisterNewMap( scoped_refptr<MapData> RegisterNewMap(
NamespaceEntry namespace_entry, NamespaceEntry namespace_entry,
const url::Origin& origin, const url::Origin& origin,
std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask>* std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>* save_tasks);
save_tasks);
// Registers an origin-map in the |destination_namespace| from every // Registers an origin-map in the |destination_namespace| from every
// origin-map in the |source_namespace|. The |destination_namespace| must have // origin-map in the |source_namespace|. The |destination_namespace| must have
...@@ -140,8 +136,7 @@ class CONTENT_EXPORT SessionStorageMetadata { ...@@ -140,8 +136,7 @@ class CONTENT_EXPORT SessionStorageMetadata {
void RegisterShallowClonedNamespace( void RegisterShallowClonedNamespace(
NamespaceEntry source_namespace, NamespaceEntry source_namespace,
NamespaceEntry destination_namespace, NamespaceEntry destination_namespace,
std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask>* std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>* save_tasks);
save_tasks);
// Deletes the given namespace and any maps that no longer have any // Deletes the given namespace and any maps that no longer have any
// references. This will invalidate all NamespaceEntry objects for the // references. This will invalidate all NamespaceEntry objects for the
...@@ -150,8 +145,7 @@ class CONTENT_EXPORT SessionStorageMetadata { ...@@ -150,8 +145,7 @@ class CONTENT_EXPORT SessionStorageMetadata {
// deletions to disk if run. // deletions to disk if run.
void DeleteNamespace( void DeleteNamespace(
const std::string& namespace_id, const std::string& namespace_id,
std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask>* std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>* save_tasks);
save_tasks);
// This returns a BatchDatabaseTask to remove the metadata entry for this // This returns a BatchDatabaseTask to remove the metadata entry for this
// namespace-origin area. If the map at this entry isn't referenced by any // namespace-origin area. If the map at this entry isn't referenced by any
...@@ -160,8 +154,7 @@ class CONTENT_EXPORT SessionStorageMetadata { ...@@ -160,8 +154,7 @@ class CONTENT_EXPORT SessionStorageMetadata {
void DeleteArea( void DeleteArea(
const std::string& namespace_id, const std::string& namespace_id,
const url::Origin& origin, const url::Origin& origin,
std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask>* std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>* save_tasks);
save_tasks);
NamespaceEntry GetOrCreateNamespaceEntry(const std::string& namespace_id); NamespaceEntry GetOrCreateNamespaceEntry(const std::string& namespace_id);
...@@ -189,6 +182,6 @@ class CONTENT_EXPORT SessionStorageMetadata { ...@@ -189,6 +182,6 @@ class CONTENT_EXPORT SessionStorageMetadata {
NamespaceOriginMap namespace_origin_map_; NamespaceOriginMap namespace_origin_map_;
}; };
} // namespace content } // namespace storage
#endif // CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_METADATA_H_ #endif // COMPONENTS_SERVICES_STORAGE_DOM_STORAGE_SESSION_STORAGE_METADATA_H_
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ #ifndef COMPONENTS_SERVICES_STORAGE_DOM_STORAGE_TESTING_LEGACY_SESSION_STORAGE_DATABASE_H_
#define CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ #define COMPONENTS_SERVICES_STORAGE_DOM_STORAGE_TESTING_LEGACY_SESSION_STORAGE_DATABASE_H_
#include <stdint.h> #include <stdint.h>
...@@ -39,26 +39,30 @@ namespace base { ...@@ -39,26 +39,30 @@ namespace base {
namespace trace_event { namespace trace_event {
class ProcessMemoryDump; class ProcessMemoryDump;
} }
} } // namespace base
namespace content {
// SessionStorageDatabase holds the data from multiple namespaces and multiple namespace storage {
// origins. All DOMStorageAreas for session storage share the same
// SessionStorageDatabase.
// A legacy implementation of Session Storage used only in tests to provide
// coverage of session storage migration code.
//
// This class is not thread safe. Read-only methods (ReadAreaValues, // This class is not thread safe. Read-only methods (ReadAreaValues,
// ReadNamespacesAndOrigins, and OnMemoryDump) may be called on any thread. // ReadNamespacesAndOrigins, and OnMemoryDump) may be called on any thread.
// Methods that modify the database must be called on the same thread. // Methods that modify the database must be called on the same thread.
class SessionStorageDatabase class TestingLegacySessionStorageDatabase
: public base::RefCountedDeleteOnSequence<SessionStorageDatabase> { : public base::RefCountedDeleteOnSequence<
TestingLegacySessionStorageDatabase> {
public: public:
// |file_path| is the path to the directory where the database will be // |file_path| is the path to the directory where the database will be
// created. |commit_task_runner| is the runner on which methods which modify // created. |commit_task_runner| is the runner on which methods which modify
// the database must be run and where this object will be deleted. // the database must be run and where this object will be deleted.
SessionStorageDatabase( TestingLegacySessionStorageDatabase(
const base::FilePath& file_path, const base::FilePath& file_path,
scoped_refptr<base::SequencedTaskRunner> commit_task_runner); scoped_refptr<base::SequencedTaskRunner> commit_task_runner);
TestingLegacySessionStorageDatabase(
const TestingLegacySessionStorageDatabase&) = delete;
TestingLegacySessionStorageDatabase& operator=(
const TestingLegacySessionStorageDatabase&) = delete;
// Reads the (key, value) pairs for |namespace_id| and |origin|. |result| is // Reads the (key, value) pairs for |namespace_id| and |origin|. |result| is
// assumed to be empty and any duplicate keys will be overwritten. If the // assumed to be empty and any duplicate keys will be overwritten. If the
...@@ -68,7 +72,7 @@ class SessionStorageDatabase ...@@ -68,7 +72,7 @@ class SessionStorageDatabase
const std::string& namespace_id, const std::string& namespace_id,
const std::vector<std::string>& original_permanent_namespace_ids, const std::vector<std::string>& original_permanent_namespace_ids,
const url::Origin& origin, const url::Origin& origin,
storage::LegacyDomStorageValuesMap* result); LegacyDomStorageValuesMap* result);
// Updates the data for |namespace_id| and |origin|. Will remove all keys // Updates the data for |namespace_id| and |origin|. Will remove all keys
// before updating the database if |clear_all_first| is set. Then all entries // before updating the database if |clear_all_first| is set. Then all entries
...@@ -79,7 +83,7 @@ class SessionStorageDatabase ...@@ -79,7 +83,7 @@ class SessionStorageDatabase
bool CommitAreaChanges(const std::string& namespace_id, bool CommitAreaChanges(const std::string& namespace_id,
const url::Origin& origin, const url::Origin& origin,
bool clear_all_first, bool clear_all_first,
const storage::LegacyDomStorageValuesMap& changes); const LegacyDomStorageValuesMap& changes);
// Creates shallow copies of the areas for |namespace_id| and associates them // Creates shallow copies of the areas for |namespace_id| and associates them
// with |new_namespace_id|. // with |new_namespace_id|.
...@@ -107,13 +111,13 @@ class SessionStorageDatabase ...@@ -107,13 +111,13 @@ class SessionStorageDatabase
private: private:
class DBOperation; class DBOperation;
friend class SessionStorageDatabase::DBOperation; friend class TestingLegacySessionStorageDatabase::DBOperation;
friend class SessionStorageDatabaseTest; friend class base::RefCountedDeleteOnSequence<
friend class base::RefCountedDeleteOnSequence<SessionStorageDatabase>; TestingLegacySessionStorageDatabase>;
friend class base::DeleteHelper<SessionStorageDatabase>; friend class base::DeleteHelper<TestingLegacySessionStorageDatabase>;
FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaParamTest, ShallowCopyWithBacking); FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaParamTest, ShallowCopyWithBacking);
~SessionStorageDatabase(); ~TestingLegacySessionStorageDatabase();
// Opens the database at file_path_ if it exists already and creates it if // Opens the database at file_path_ if it exists already and creates it if
// |create_if_needed| is true. Returns true if the database was opened, false // |create_if_needed| is true. Returns true if the database was opened, false
...@@ -186,11 +190,11 @@ class SessionStorageDatabase ...@@ -186,11 +190,11 @@ class SessionStorageDatabase
// be empty. // be empty.
bool ReadMap(const std::string& map_id, bool ReadMap(const std::string& map_id,
const leveldb::ReadOptions& options, const leveldb::ReadOptions& options,
storage::LegacyDomStorageValuesMap* result, LegacyDomStorageValuesMap* result,
bool only_keys); bool only_keys);
// Writes |values| into the map |map_id|. // Writes |values| into the map |map_id|.
void WriteValuesToMap(const std::string& map_id, void WriteValuesToMap(const std::string& map_id,
const storage::LegacyDomStorageValuesMap& values, const LegacyDomStorageValuesMap& values,
leveldb::WriteBatch* batch); leveldb::WriteBatch* batch);
bool GetMapRefCount(const std::string& map_id, int64_t* ref_count); bool GetMapRefCount(const std::string& map_id, int64_t* ref_count);
...@@ -243,10 +247,8 @@ class SessionStorageDatabase ...@@ -243,10 +247,8 @@ class SessionStorageDatabase
// Used to check methods that run on the commit sequence. // Used to check methods that run on the commit sequence.
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase);
}; };
} // namespace content } // namespace storage
#endif // CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ #endif // COMPONENTS_SERVICES_STORAGE_DOM_STORAGE_TESTING_LEGACY_SESSION_STORAGE_DATABASE_H_
...@@ -791,8 +791,6 @@ jumbo_source_set("browser") { ...@@ -791,8 +791,6 @@ jumbo_source_set("browser") {
"dom_storage/session_storage_context_mojo.h", "dom_storage/session_storage_context_mojo.h",
"dom_storage/session_storage_data_map.cc", "dom_storage/session_storage_data_map.cc",
"dom_storage/session_storage_data_map.h", "dom_storage/session_storage_data_map.h",
"dom_storage/session_storage_metadata.cc",
"dom_storage/session_storage_metadata.h",
"dom_storage/session_storage_namespace_impl.cc", "dom_storage/session_storage_namespace_impl.cc",
"dom_storage/session_storage_namespace_impl.h", "dom_storage/session_storage_namespace_impl.h",
"dom_storage/session_storage_namespace_impl_mojo.cc", "dom_storage/session_storage_namespace_impl_mojo.cc",
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
namespace content { namespace content {
SessionStorageAreaImpl::SessionStorageAreaImpl( SessionStorageAreaImpl::SessionStorageAreaImpl(
SessionStorageMetadata::NamespaceEntry namespace_entry, storage::SessionStorageMetadata::NamespaceEntry namespace_entry,
url::Origin origin, url::Origin origin,
scoped_refptr<SessionStorageDataMap> data_map, scoped_refptr<SessionStorageDataMap> data_map,
RegisterNewAreaMap register_new_map_callback) RegisterNewAreaMap register_new_map_callback)
...@@ -42,7 +42,7 @@ void SessionStorageAreaImpl::Bind( ...@@ -42,7 +42,7 @@ void SessionStorageAreaImpl::Bind(
} }
std::unique_ptr<SessionStorageAreaImpl> SessionStorageAreaImpl::Clone( std::unique_ptr<SessionStorageAreaImpl> SessionStorageAreaImpl::Clone(
SessionStorageMetadata::NamespaceEntry namespace_entry) { storage::SessionStorageMetadata::NamespaceEntry namespace_entry) {
DCHECK(namespace_entry_ != namespace_entry); DCHECK(namespace_entry_ != namespace_entry);
return base::WrapUnique(new SessionStorageAreaImpl( return base::WrapUnique(new SessionStorageAreaImpl(
namespace_entry, origin_, shared_data_map_, register_new_map_callback_)); namespace_entry, origin_, shared_data_map_, register_new_map_callback_));
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/optional.h" #include "base/optional.h"
#include "content/browser/dom_storage/session_storage_metadata.h" #include "components/services/storage/dom_storage/session_storage_metadata.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "mojo/public/cpp/bindings/associated_receiver.h" #include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
...@@ -40,26 +40,28 @@ class SessionStorageDataMap; ...@@ -40,26 +40,28 @@ class SessionStorageDataMap;
// SessionStorageDataMap's StorageArea. // SessionStorageDataMap's StorageArea.
class CONTENT_EXPORT SessionStorageAreaImpl : public blink::mojom::StorageArea { class CONTENT_EXPORT SessionStorageAreaImpl : public blink::mojom::StorageArea {
public: public:
using RegisterNewAreaMap = using RegisterNewAreaMap = base::RepeatingCallback<
base::RepeatingCallback<scoped_refptr<SessionStorageMetadata::MapData>( scoped_refptr<storage::SessionStorageMetadata::MapData>(
SessionStorageMetadata::NamespaceEntry namespace_entry, storage::SessionStorageMetadata::NamespaceEntry namespace_entry,
const url::Origin& origin)>; const url::Origin& origin)>;
// Creates a area for the given |namespace_entry|-|origin| data area. All // Creates a area for the given |namespace_entry|-|origin| data area. All
// StorageArea calls are delegated to the |data_map|. The // StorageArea calls are delegated to the |data_map|. The
// |register_new_map_callback| is called when a shared |data_map| needs to be // |register_new_map_callback| is called when a shared |data_map| needs to be
// forked for the copy-on-write behavior and a new map needs to be registered. // forked for the copy-on-write behavior and a new map needs to be registered.
SessionStorageAreaImpl(SessionStorageMetadata::NamespaceEntry namespace_entry, SessionStorageAreaImpl(
url::Origin origin, storage::SessionStorageMetadata::NamespaceEntry namespace_entry,
scoped_refptr<SessionStorageDataMap> data_map, url::Origin origin,
RegisterNewAreaMap register_new_map_callback); scoped_refptr<SessionStorageDataMap> data_map,
RegisterNewAreaMap register_new_map_callback);
~SessionStorageAreaImpl() override; ~SessionStorageAreaImpl() override;
// Creates a shallow copy clone for the new namespace entry. // Creates a shallow copy clone for the new namespace entry.
// This doesn't change the refcount of the underlying map - that operation // This doesn't change the refcount of the underlying map - that operation
// must be done using SessionStorageMetadata::RegisterShallowClonedNamespace. // must be done using
// storage::SessionStorageMetadata::RegisterShallowClonedNamespace.
std::unique_ptr<SessionStorageAreaImpl> Clone( std::unique_ptr<SessionStorageAreaImpl> Clone(
SessionStorageMetadata::NamespaceEntry namespace_entry); storage::SessionStorageMetadata::NamespaceEntry namespace_entry);
void Bind( void Bind(
mojo::PendingAssociatedReceiver<blink::mojom::StorageArea> receiver); mojo::PendingAssociatedReceiver<blink::mojom::StorageArea> receiver);
...@@ -99,7 +101,7 @@ class CONTENT_EXPORT SessionStorageAreaImpl : public blink::mojom::StorageArea { ...@@ -99,7 +101,7 @@ class CONTENT_EXPORT SessionStorageAreaImpl : public blink::mojom::StorageArea {
void CreateNewMap(NewMapType map_type, void CreateNewMap(NewMapType map_type,
const base::Optional<std::string>& delete_all_source); const base::Optional<std::string>& delete_all_source);
SessionStorageMetadata::NamespaceEntry namespace_entry_; storage::SessionStorageMetadata::NamespaceEntry namespace_entry_;
url::Origin origin_; url::Origin origin_;
scoped_refptr<SessionStorageDataMap> shared_data_map_; scoped_refptr<SessionStorageDataMap> shared_data_map_;
RegisterNewAreaMap register_new_map_callback_; RegisterNewAreaMap register_new_map_callback_;
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "components/services/storage/dom_storage/async_dom_storage_database.h" #include "components/services/storage/dom_storage/async_dom_storage_database.h"
#include "components/services/storage/dom_storage/session_storage_metadata.h"
#include "components/services/storage/dom_storage/storage_area_test_util.h" #include "components/services/storage/dom_storage/storage_area_test_util.h"
#include "content/browser/dom_storage/session_storage_data_map.h" #include "content/browser/dom_storage/session_storage_data_map.h"
#include "content/browser/dom_storage/session_storage_metadata.h"
#include "content/test/gmock_util.h" #include "content/test/gmock_util.h"
#include "mojo/public/cpp/bindings/associated_receiver.h" #include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h" #include "mojo/public/cpp/bindings/associated_remote.h"
...@@ -78,8 +78,8 @@ class SessionStorageAreaImplTest : public testing::Test { ...@@ -78,8 +78,8 @@ class SessionStorageAreaImplTest : public testing::Test {
} }
~SessionStorageAreaImplTest() override = default; ~SessionStorageAreaImplTest() override = default;
scoped_refptr<SessionStorageMetadata::MapData> RegisterNewAreaMap( scoped_refptr<storage::SessionStorageMetadata::MapData> RegisterNewAreaMap(
SessionStorageMetadata::NamespaceEntry namespace_entry, storage::SessionStorageMetadata::NamespaceEntry namespace_entry,
const url::Origin& origin) { const url::Origin& origin) {
std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask> save_tasks; std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask> save_tasks;
auto map_data = auto map_data =
...@@ -101,7 +101,7 @@ class SessionStorageAreaImplTest : public testing::Test { ...@@ -101,7 +101,7 @@ class SessionStorageAreaImplTest : public testing::Test {
const url::Origin test_origin1_; const url::Origin test_origin1_;
const url::Origin test_origin2_; const url::Origin test_origin2_;
std::unique_ptr<storage::AsyncDomStorageDatabase> leveldb_database_; std::unique_ptr<storage::AsyncDomStorageDatabase> leveldb_database_;
SessionStorageMetadata metadata_; storage::SessionStorageMetadata metadata_;
testing::StrictMock<MockListener> listener_; testing::StrictMock<MockListener> listener_;
}; };
......
...@@ -286,7 +286,7 @@ void SessionStorageContextMojo::GetStorageUsage( ...@@ -286,7 +286,7 @@ void SessionStorageContextMojo::GetStorageUsage(
return; return;
} }
const SessionStorageMetadata::NamespaceOriginMap& all_namespaces = const storage::SessionStorageMetadata::NamespaceOriginMap& all_namespaces =
metadata_.namespace_origin_map(); metadata_.namespace_origin_map();
std::vector<SessionStorageUsageInfo> result; std::vector<SessionStorageUsageInfo> result;
...@@ -539,12 +539,12 @@ void SessionStorageContextMojo::SetDatabaseOpenCallbackForTesting( ...@@ -539,12 +539,12 @@ void SessionStorageContextMojo::SetDatabaseOpenCallbackForTesting(
RunWhenConnected(std::move(callback)); RunWhenConnected(std::move(callback));
} }
scoped_refptr<SessionStorageMetadata::MapData> scoped_refptr<storage::SessionStorageMetadata::MapData>
SessionStorageContextMojo::RegisterNewAreaMap( SessionStorageContextMojo::RegisterNewAreaMap(
SessionStorageMetadata::NamespaceEntry namespace_entry, storage::SessionStorageMetadata::NamespaceEntry namespace_entry,
const url::Origin& origin) { const url::Origin& origin) {
std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask> save_tasks; std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask> save_tasks;
scoped_refptr<SessionStorageMetadata::MapData> map_entry = scoped_refptr<storage::SessionStorageMetadata::MapData> map_entry =
metadata_.RegisterNewMap(namespace_entry, origin, &save_tasks); metadata_.RegisterNewMap(namespace_entry, origin, &save_tasks);
if (database_) { if (database_) {
...@@ -614,7 +614,7 @@ SessionStorageContextMojo::MaybeGetExistingDataMapForId( ...@@ -614,7 +614,7 @@ SessionStorageContextMojo::MaybeGetExistingDataMapForId(
} }
void SessionStorageContextMojo::RegisterShallowClonedNamespace( void SessionStorageContextMojo::RegisterShallowClonedNamespace(
SessionStorageMetadata::NamespaceEntry source_namespace_entry, storage::SessionStorageMetadata::NamespaceEntry source_namespace_entry,
const std::string& new_namespace_id, const std::string& new_namespace_id,
const SessionStorageNamespaceImplMojo::OriginAreas& clone_from_areas) { const SessionStorageNamespaceImplMojo::OriginAreas& clone_from_areas) {
std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask> save_tasks; std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask> save_tasks;
...@@ -787,18 +787,21 @@ void SessionStorageContextMojo::OnDatabaseOpened(leveldb::Status status) { ...@@ -787,18 +787,21 @@ void SessionStorageContextMojo::OnDatabaseOpened(leveldb::Status status) {
database_->RunDatabaseTask( database_->RunDatabaseTask(
base::BindOnce([](const storage::DomStorageDatabase& db) { base::BindOnce([](const storage::DomStorageDatabase& db) {
ValueAndStatus version; ValueAndStatus version;
version.status = db.Get( version.status =
base::make_span(SessionStorageMetadata::kDatabaseVersionBytes), db.Get(base::make_span(
&version.value); storage::SessionStorageMetadata::kDatabaseVersionBytes),
&version.value);
KeyValuePairsAndStatus namespaces; KeyValuePairsAndStatus namespaces;
namespaces.status = db.GetPrefixed( namespaces.status = db.GetPrefixed(
base::make_span(SessionStorageMetadata::kNamespacePrefixBytes), base::make_span(
storage::SessionStorageMetadata::kNamespacePrefixBytes),
&namespaces.key_value_pairs); &namespaces.key_value_pairs);
ValueAndStatus next_map_id; ValueAndStatus next_map_id;
next_map_id.status = next_map_id.status =
db.Get(base::make_span(SessionStorageMetadata::kNextMapIdKeyBytes), db.Get(base::make_span(
storage::SessionStorageMetadata::kNextMapIdKeyBytes),
&next_map_id.value); &next_map_id.value);
return std::make_tuple(std::move(version), std::move(namespaces), return std::make_tuple(std::move(version), std::move(namespaces),
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#include "base/trace_event/memory_dump_provider.h" #include "base/trace_event/memory_dump_provider.h"
#include "components/services/storage/dom_storage/async_dom_storage_database.h" #include "components/services/storage/dom_storage/async_dom_storage_database.h"
#include "components/services/storage/dom_storage/dom_storage_database.h" #include "components/services/storage/dom_storage/dom_storage_database.h"
#include "components/services/storage/dom_storage/session_storage_metadata.h"
#include "content/browser/dom_storage/session_storage_data_map.h" #include "content/browser/dom_storage/session_storage_data_map.h"
#include "content/browser/dom_storage/session_storage_metadata.h"
#include "content/browser/dom_storage/session_storage_namespace_impl_mojo.h" #include "content/browser/dom_storage/session_storage_namespace_impl_mojo.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/public/browser/session_storage_usage_info.h" #include "content/public/browser/session_storage_usage_info.h"
...@@ -175,8 +175,8 @@ class CONTENT_EXPORT SessionStorageContextMojo ...@@ -175,8 +175,8 @@ class CONTENT_EXPORT SessionStorageContextMojo
// Object deletion is done through |ShutdownAndDelete()|. // Object deletion is done through |ShutdownAndDelete()|.
~SessionStorageContextMojo() override; ~SessionStorageContextMojo() override;
scoped_refptr<SessionStorageMetadata::MapData> RegisterNewAreaMap( scoped_refptr<storage::SessionStorageMetadata::MapData> RegisterNewAreaMap(
SessionStorageMetadata::NamespaceEntry namespace_entry, storage::SessionStorageMetadata::NamespaceEntry namespace_entry,
const url::Origin& origin); const url::Origin& origin);
// SessionStorageAreaImpl::Listener implementation: // SessionStorageAreaImpl::Listener implementation:
...@@ -191,7 +191,7 @@ class CONTENT_EXPORT SessionStorageContextMojo ...@@ -191,7 +191,7 @@ class CONTENT_EXPORT SessionStorageContextMojo
scoped_refptr<SessionStorageDataMap> MaybeGetExistingDataMapForId( scoped_refptr<SessionStorageDataMap> MaybeGetExistingDataMapForId(
const std::vector<uint8_t>& map_number_as_bytes) override; const std::vector<uint8_t>& map_number_as_bytes) override;
void RegisterShallowClonedNamespace( void RegisterShallowClonedNamespace(
SessionStorageMetadata::NamespaceEntry source_namespace_entry, storage::SessionStorageMetadata::NamespaceEntry source_namespace_entry,
const std::string& new_namespace_id, const std::string& new_namespace_id,
const SessionStorageNamespaceImplMojo::OriginAreas& clone_from_areas) const SessionStorageNamespaceImplMojo::OriginAreas& clone_from_areas)
override; override;
...@@ -252,12 +252,11 @@ class CONTENT_EXPORT SessionStorageContextMojo ...@@ -252,12 +252,11 @@ class CONTENT_EXPORT SessionStorageContextMojo
void GetStatistics(size_t* total_cache_size, size_t* unused_areas_count); void GetStatistics(size_t* total_cache_size, size_t* unused_areas_count);
void LogDatabaseOpenResult(OpenResult result); void LogDatabaseOpenResult(OpenResult result);
// Since the session storage object hierarchy references iterators owned by // Since the session storage object hierarchy references iterators owned by
// the metadata, make sure it is destroyed last on destruction. // the metadata, make sure it is destroyed last on destruction.
SessionStorageMetadata metadata_; storage::SessionStorageMetadata metadata_;
BackingMode backing_mode_; BackingMode backing_mode_;
std::string leveldb_name_; std::string leveldb_name_;
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "components/services/storage/dom_storage/legacy_dom_storage_database.h" #include "components/services/storage/dom_storage/legacy_dom_storage_database.h"
#include "components/services/storage/dom_storage/storage_area_test_util.h" #include "components/services/storage/dom_storage/storage_area_test_util.h"
#include "components/services/storage/dom_storage/testing_legacy_session_storage_database.h"
#include "content/browser/child_process_security_policy_impl.h" #include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/dom_storage/session_storage_database.h"
#include "content/public/browser/session_storage_usage_info.h" #include "content/public/browser/session_storage_usage_info.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_context.h"
...@@ -210,8 +210,8 @@ TEST_F(SessionStorageContextMojoTest, MigrationV0ToV1) { ...@@ -210,8 +210,8 @@ TEST_F(SessionStorageContextMojoTest, MigrationV0ToV1) {
base::FilePath old_db_path = base::FilePath old_db_path =
temp_path().AppendASCII(kSessionStorageDirectory); temp_path().AppendASCII(kSessionStorageDirectory);
{ {
scoped_refptr<SessionStorageDatabase> db = auto db =
base::MakeRefCounted<SessionStorageDatabase>( base::MakeRefCounted<storage::TestingLegacySessionStorageDatabase>(
old_db_path, base::ThreadTaskRunnerHandle::Get().get()); old_db_path, base::ThreadTaskRunnerHandle::Get().get());
storage::LegacyDomStorageValuesMap data; storage::LegacyDomStorageValuesMap data;
data[key] = base::NullableString16(value, false); data[key] = base::NullableString16(value, false);
......
...@@ -14,7 +14,7 @@ namespace content { ...@@ -14,7 +14,7 @@ namespace content {
// static // static
scoped_refptr<SessionStorageDataMap> SessionStorageDataMap::CreateFromDisk( scoped_refptr<SessionStorageDataMap> SessionStorageDataMap::CreateFromDisk(
Listener* listener, Listener* listener,
scoped_refptr<SessionStorageMetadata::MapData> map_data, scoped_refptr<storage::SessionStorageMetadata::MapData> map_data,
storage::AsyncDomStorageDatabase* database) { storage::AsyncDomStorageDatabase* database) {
return base::WrapRefCounted(new SessionStorageDataMap( return base::WrapRefCounted(new SessionStorageDataMap(
listener, std::move(map_data), database, false)); listener, std::move(map_data), database, false));
...@@ -23,7 +23,7 @@ scoped_refptr<SessionStorageDataMap> SessionStorageDataMap::CreateFromDisk( ...@@ -23,7 +23,7 @@ scoped_refptr<SessionStorageDataMap> SessionStorageDataMap::CreateFromDisk(
// static // static
scoped_refptr<SessionStorageDataMap> SessionStorageDataMap::CreateEmpty( scoped_refptr<SessionStorageDataMap> SessionStorageDataMap::CreateEmpty(
Listener* listener, Listener* listener,
scoped_refptr<SessionStorageMetadata::MapData> map_data, scoped_refptr<storage::SessionStorageMetadata::MapData> map_data,
storage::AsyncDomStorageDatabase* database) { storage::AsyncDomStorageDatabase* database) {
return base::WrapRefCounted( return base::WrapRefCounted(
new SessionStorageDataMap(listener, std::move(map_data), database, true)); new SessionStorageDataMap(listener, std::move(map_data), database, true));
...@@ -32,7 +32,7 @@ scoped_refptr<SessionStorageDataMap> SessionStorageDataMap::CreateEmpty( ...@@ -32,7 +32,7 @@ scoped_refptr<SessionStorageDataMap> SessionStorageDataMap::CreateEmpty(
// static // static
scoped_refptr<SessionStorageDataMap> SessionStorageDataMap::CreateClone( scoped_refptr<SessionStorageDataMap> SessionStorageDataMap::CreateClone(
Listener* listener, Listener* listener,
scoped_refptr<SessionStorageMetadata::MapData> map_data, scoped_refptr<storage::SessionStorageMetadata::MapData> map_data,
scoped_refptr<SessionStorageDataMap> clone_from) { scoped_refptr<SessionStorageDataMap> clone_from) {
return base::WrapRefCounted(new SessionStorageDataMap( return base::WrapRefCounted(new SessionStorageDataMap(
listener, std::move(map_data), std::move(clone_from))); listener, std::move(map_data), std::move(clone_from)));
...@@ -44,7 +44,7 @@ void SessionStorageDataMap::DidCommit(leveldb::Status status) { ...@@ -44,7 +44,7 @@ void SessionStorageDataMap::DidCommit(leveldb::Status status) {
SessionStorageDataMap::SessionStorageDataMap( SessionStorageDataMap::SessionStorageDataMap(
Listener* listener, Listener* listener,
scoped_refptr<SessionStorageMetadata::MapData> map_data, scoped_refptr<storage::SessionStorageMetadata::MapData> map_data,
storage::AsyncDomStorageDatabase* database, storage::AsyncDomStorageDatabase* database,
bool is_empty) bool is_empty)
: listener_(listener), : listener_(listener),
...@@ -64,7 +64,7 @@ SessionStorageDataMap::SessionStorageDataMap( ...@@ -64,7 +64,7 @@ SessionStorageDataMap::SessionStorageDataMap(
SessionStorageDataMap::SessionStorageDataMap( SessionStorageDataMap::SessionStorageDataMap(
Listener* listener, Listener* listener,
scoped_refptr<SessionStorageMetadata::MapData> map_data, scoped_refptr<storage::SessionStorageMetadata::MapData> map_data,
scoped_refptr<SessionStorageDataMap> forking_from) scoped_refptr<SessionStorageDataMap> forking_from)
: listener_(listener), : listener_(listener),
clone_from_data_map_(std::move(forking_from)), clone_from_data_map_(std::move(forking_from)),
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/optional.h" #include "base/optional.h"
#include "components/services/storage/dom_storage/session_storage_metadata.h"
#include "components/services/storage/dom_storage/storage_area_impl.h" #include "components/services/storage/dom_storage/storage_area_impl.h"
#include "content/browser/dom_storage/session_storage_metadata.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_binding.h"
...@@ -26,7 +26,8 @@ namespace content { ...@@ -26,7 +26,8 @@ namespace content {
// namespace-origin area has a data map. To support shallow copying of the data // namespace-origin area has a data map. To support shallow copying of the data
// (copy-on-write), a single data map can be shared between multiple namespaces. // (copy-on-write), a single data map can be shared between multiple namespaces.
// Thus this class is refcounted. This class has a one-to-one relationship with // Thus this class is refcounted. This class has a one-to-one relationship with
// the SessionStorageMetadata::MapData object, accessible from |map_data()|. // the storage::SessionStorageMetadata::MapData object, accessible from
// |map_data()|.
// //
// Neither this data map nor the inner StorageArea is bound to, as it needs // Neither this data map nor the inner StorageArea is bound to, as it needs
// to be shared between multiple connections if it is shallow-copied. However, // to be shared between multiple connections if it is shallow-copied. However,
...@@ -47,24 +48,24 @@ class CONTENT_EXPORT SessionStorageDataMap final ...@@ -47,24 +48,24 @@ class CONTENT_EXPORT SessionStorageDataMap final
static scoped_refptr<SessionStorageDataMap> CreateFromDisk( static scoped_refptr<SessionStorageDataMap> CreateFromDisk(
Listener* listener, Listener* listener,
scoped_refptr<SessionStorageMetadata::MapData> map_data, scoped_refptr<storage::SessionStorageMetadata::MapData> map_data,
storage::AsyncDomStorageDatabase* database); storage::AsyncDomStorageDatabase* database);
static scoped_refptr<SessionStorageDataMap> CreateEmpty( static scoped_refptr<SessionStorageDataMap> CreateEmpty(
Listener* listener, Listener* listener,
scoped_refptr<SessionStorageMetadata::MapData> map_data, scoped_refptr<storage::SessionStorageMetadata::MapData> map_data,
storage::AsyncDomStorageDatabase* database); storage::AsyncDomStorageDatabase* database);
static scoped_refptr<SessionStorageDataMap> CreateClone( static scoped_refptr<SessionStorageDataMap> CreateClone(
Listener* listener, Listener* listener,
scoped_refptr<SessionStorageMetadata::MapData> map_data, scoped_refptr<storage::SessionStorageMetadata::MapData> map_data,
scoped_refptr<SessionStorageDataMap> clone_from); scoped_refptr<SessionStorageDataMap> clone_from);
Listener* listener() const { return listener_; } Listener* listener() const { return listener_; }
storage::StorageAreaImpl* storage_area() { return storage_area_ptr_; } storage::StorageAreaImpl* storage_area() { return storage_area_ptr_; }
scoped_refptr<SessionStorageMetadata::MapData> map_data() { scoped_refptr<storage::SessionStorageMetadata::MapData> map_data() {
return map_data_.get(); return map_data_.get();
} }
...@@ -84,12 +85,12 @@ class CONTENT_EXPORT SessionStorageDataMap final ...@@ -84,12 +85,12 @@ class CONTENT_EXPORT SessionStorageDataMap final
SessionStorageDataMap( SessionStorageDataMap(
Listener* listener, Listener* listener,
scoped_refptr<SessionStorageMetadata::MapData> map_entry, scoped_refptr<storage::SessionStorageMetadata::MapData> map_entry,
storage::AsyncDomStorageDatabase* database, storage::AsyncDomStorageDatabase* database,
bool is_empty); bool is_empty);
SessionStorageDataMap( SessionStorageDataMap(
Listener* listener, Listener* listener,
scoped_refptr<SessionStorageMetadata::MapData> map_entry, scoped_refptr<storage::SessionStorageMetadata::MapData> map_entry,
scoped_refptr<SessionStorageDataMap> forking_from); scoped_refptr<SessionStorageDataMap> forking_from);
~SessionStorageDataMap() override; ~SessionStorageDataMap() override;
...@@ -105,7 +106,7 @@ class CONTENT_EXPORT SessionStorageDataMap final ...@@ -105,7 +106,7 @@ class CONTENT_EXPORT SessionStorageDataMap final
// completes synchronously. // completes synchronously.
scoped_refptr<SessionStorageDataMap> clone_from_data_map_; scoped_refptr<SessionStorageDataMap> clone_from_data_map_;
scoped_refptr<SessionStorageMetadata::MapData> map_data_; scoped_refptr<storage::SessionStorageMetadata::MapData> map_data_;
std::unique_ptr<storage::StorageAreaImpl> storage_area_impl_; std::unique_ptr<storage::StorageAreaImpl> storage_area_impl_;
// Holds the same value as |storage_area_impl_|. The reason for this is that // Holds the same value as |storage_area_impl_|. The reason for this is that
// during destruction of the StorageAreaImpl instance we might still get // during destruction of the StorageAreaImpl instance we might still get
......
...@@ -156,8 +156,8 @@ TEST_F(SessionStorageDataMapTest, BasicEmptyCreation) { ...@@ -156,8 +156,8 @@ TEST_F(SessionStorageDataMapTest, BasicEmptyCreation) {
scoped_refptr<SessionStorageDataMap> map = scoped_refptr<SessionStorageDataMap> map =
SessionStorageDataMap::CreateFromDisk( SessionStorageDataMap::CreateFromDisk(
&listener_, &listener_,
base::MakeRefCounted<SessionStorageMetadata::MapData>(1, base::MakeRefCounted<storage::SessionStorageMetadata::MapData>(
test_origin_), 1, test_origin_),
database_.get()); database_.get());
bool success; bool success;
...@@ -189,7 +189,8 @@ TEST_F(SessionStorageDataMapTest, ExplicitlyEmpty) { ...@@ -189,7 +189,8 @@ TEST_F(SessionStorageDataMapTest, ExplicitlyEmpty) {
scoped_refptr<SessionStorageDataMap> map = SessionStorageDataMap::CreateEmpty( scoped_refptr<SessionStorageDataMap> map = SessionStorageDataMap::CreateEmpty(
&listener_, &listener_,
base::MakeRefCounted<SessionStorageMetadata::MapData>(1, test_origin_), base::MakeRefCounted<storage::SessionStorageMetadata::MapData>(
1, test_origin_),
database_.get()); database_.get());
bool success; bool success;
...@@ -220,8 +221,8 @@ TEST_F(SessionStorageDataMapTest, Clone) { ...@@ -220,8 +221,8 @@ TEST_F(SessionStorageDataMapTest, Clone) {
scoped_refptr<SessionStorageDataMap> map1 = scoped_refptr<SessionStorageDataMap> map1 =
SessionStorageDataMap::CreateFromDisk( SessionStorageDataMap::CreateFromDisk(
&listener_, &listener_,
base::MakeRefCounted<SessionStorageMetadata::MapData>(1, base::MakeRefCounted<storage::SessionStorageMetadata::MapData>(
test_origin_), 1, test_origin_),
database_.get()); database_.get());
EXPECT_CALL(listener_, EXPECT_CALL(listener_,
...@@ -233,8 +234,8 @@ TEST_F(SessionStorageDataMapTest, Clone) { ...@@ -233,8 +234,8 @@ TEST_F(SessionStorageDataMapTest, Clone) {
scoped_refptr<SessionStorageDataMap> map2 = scoped_refptr<SessionStorageDataMap> map2 =
SessionStorageDataMap::CreateClone( SessionStorageDataMap::CreateClone(
&listener_, &listener_,
base::MakeRefCounted<SessionStorageMetadata::MapData>(2, base::MakeRefCounted<storage::SessionStorageMetadata::MapData>(
test_origin_), 2, test_origin_),
map1); map1);
bool success; bool success;
......
...@@ -60,7 +60,7 @@ bool SessionStorageNamespaceImplMojo::HasAreaForOrigin( ...@@ -60,7 +60,7 @@ bool SessionStorageNamespaceImplMojo::HasAreaForOrigin(
void SessionStorageNamespaceImplMojo::PopulateFromMetadata( void SessionStorageNamespaceImplMojo::PopulateFromMetadata(
storage::AsyncDomStorageDatabase* database, storage::AsyncDomStorageDatabase* database,
SessionStorageMetadata::NamespaceEntry namespace_metadata) { storage::SessionStorageMetadata::NamespaceEntry namespace_metadata) {
DCHECK(!IsPopulated()); DCHECK(!IsPopulated());
database_ = database; database_ = database;
state_ = State::kPopulated; state_ = State::kPopulated;
...@@ -87,7 +87,7 @@ void SessionStorageNamespaceImplMojo::PopulateFromMetadata( ...@@ -87,7 +87,7 @@ void SessionStorageNamespaceImplMojo::PopulateFromMetadata(
void SessionStorageNamespaceImplMojo::PopulateAsClone( void SessionStorageNamespaceImplMojo::PopulateAsClone(
storage::AsyncDomStorageDatabase* database, storage::AsyncDomStorageDatabase* database,
SessionStorageMetadata::NamespaceEntry namespace_metadata, storage::SessionStorageMetadata::NamespaceEntry namespace_metadata,
const OriginAreas& areas_to_clone) { const OriginAreas& areas_to_clone) {
DCHECK(!IsPopulated()); DCHECK(!IsPopulated());
database_ = database; database_ = database;
...@@ -108,7 +108,7 @@ void SessionStorageNamespaceImplMojo::PopulateAsClone( ...@@ -108,7 +108,7 @@ void SessionStorageNamespaceImplMojo::PopulateAsClone(
} }
void SessionStorageNamespaceImplMojo::Reset() { void SessionStorageNamespaceImplMojo::Reset() {
namespace_entry_ = SessionStorageMetadata::NamespaceEntry(); namespace_entry_ = storage::SessionStorageMetadata::NamespaceEntry();
database_ = nullptr; database_ = nullptr;
pending_population_from_parent_namespace_.clear(); pending_population_from_parent_namespace_.clear();
bind_waiting_on_population_ = false; bind_waiting_on_population_ = false;
...@@ -195,7 +195,7 @@ void SessionStorageNamespaceImplMojo::OpenArea( ...@@ -195,7 +195,7 @@ void SessionStorageNamespaceImplMojo::OpenArea(
if (map_data_it != namespace_entry_->second.end()) { if (map_data_it != namespace_entry_->second.end()) {
// The map exists already, either on disk or being used by another // The map exists already, either on disk or being used by another
// namespace. // namespace.
scoped_refptr<SessionStorageMetadata::MapData> map_data = scoped_refptr<storage::SessionStorageMetadata::MapData> map_data =
map_data_it->second; map_data_it->second;
data_map = data_map =
delegate_->MaybeGetExistingDataMapForId(map_data->MapNumberAsBytes()); delegate_->MaybeGetExistingDataMapForId(map_data->MapNumberAsBytes());
...@@ -229,7 +229,7 @@ void SessionStorageNamespaceImplMojo::Clone( ...@@ -229,7 +229,7 @@ void SessionStorageNamespaceImplMojo::Clone(
void SessionStorageNamespaceImplMojo::CloneAllNamespacesWaitingForClone( void SessionStorageNamespaceImplMojo::CloneAllNamespacesWaitingForClone(
storage::AsyncDomStorageDatabase* database, storage::AsyncDomStorageDatabase* database,
SessionStorageMetadata* metadata, storage::SessionStorageMetadata* metadata,
const std::map<std::string, const std::map<std::string,
std::unique_ptr<SessionStorageNamespaceImplMojo>>& std::unique_ptr<SessionStorageNamespaceImplMojo>>&
namespaces_map) { namespaces_map) {
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
#include "base/containers/flat_set.h" #include "base/containers/flat_set.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "components/services/storage/dom_storage/session_storage_metadata.h"
#include "content/browser/dom_storage/session_storage_area_impl.h" #include "content/browser/dom_storage/session_storage_area_impl.h"
#include "content/browser/dom_storage/session_storage_data_map.h" #include "content/browser/dom_storage/session_storage_data_map.h"
#include "content/browser/dom_storage/session_storage_metadata.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/dom_storage/session_storage_namespace.mojom.h" #include "third_party/blink/public/mojom/dom_storage/session_storage_namespace.mojom.h"
...@@ -77,7 +77,7 @@ class CONTENT_EXPORT SessionStorageNamespaceImplMojo final ...@@ -77,7 +77,7 @@ class CONTENT_EXPORT SessionStorageNamespaceImplMojo final
// This is called when the |Clone()| method is called by mojo. // This is called when the |Clone()| method is called by mojo.
virtual void RegisterShallowClonedNamespace( virtual void RegisterShallowClonedNamespace(
SessionStorageMetadata::NamespaceEntry source_namespace, storage::SessionStorageMetadata::NamespaceEntry source_namespace,
const std::string& destination_namespace, const std::string& destination_namespace,
const OriginAreas& areas_to_clone) = 0; const OriginAreas& areas_to_clone) = 0;
...@@ -127,14 +127,14 @@ class CONTENT_EXPORT SessionStorageNamespaceImplMojo final ...@@ -127,14 +127,14 @@ class CONTENT_EXPORT SessionStorageNamespaceImplMojo final
// disk. Should be called before |Bind|. // disk. Should be called before |Bind|.
void PopulateFromMetadata( void PopulateFromMetadata(
storage::AsyncDomStorageDatabase* database, storage::AsyncDomStorageDatabase* database,
SessionStorageMetadata::NamespaceEntry namespace_metadata); storage::SessionStorageMetadata::NamespaceEntry namespace_metadata);
// Can either be called before |Bind|, or if the source namespace isn't // Can either be called before |Bind|, or if the source namespace isn't
// available yet, |SetWaitingForClonePopulation| can be called. Then |Bind| // available yet, |SetWaitingForClonePopulation| can be called. Then |Bind|
// will work, and hold onto the request until after this method is called. // will work, and hold onto the request until after this method is called.
void PopulateAsClone( void PopulateAsClone(
storage::AsyncDomStorageDatabase* database, storage::AsyncDomStorageDatabase* database,
SessionStorageMetadata::NamespaceEntry namespace_metadata, storage::SessionStorageMetadata::NamespaceEntry namespace_metadata,
const OriginAreas& areas_to_clone); const OriginAreas& areas_to_clone);
// Resets to a pre-populated and pre-bound state. Used when the owner needs to // Resets to a pre-populated and pre-bound state. Used when the owner needs to
...@@ -144,7 +144,7 @@ class CONTENT_EXPORT SessionStorageNamespaceImplMojo final ...@@ -144,7 +144,7 @@ class CONTENT_EXPORT SessionStorageNamespaceImplMojo final
// destruct the object instead of having this method. // destruct the object instead of having this method.
void Reset(); void Reset();
SessionStorageMetadata::NamespaceEntry namespace_entry() { storage::SessionStorageMetadata::NamespaceEntry namespace_entry() {
return namespace_entry_; return namespace_entry_;
} }
...@@ -189,7 +189,7 @@ class CONTENT_EXPORT SessionStorageNamespaceImplMojo final ...@@ -189,7 +189,7 @@ class CONTENT_EXPORT SessionStorageNamespaceImplMojo final
// * If the parent has a parent. // * If the parent has a parent.
void CloneAllNamespacesWaitingForClone( void CloneAllNamespacesWaitingForClone(
storage::AsyncDomStorageDatabase* database, storage::AsyncDomStorageDatabase* database,
SessionStorageMetadata* metadata, storage::SessionStorageMetadata* metadata,
const std::map<std::string, const std::map<std::string,
std::unique_ptr<SessionStorageNamespaceImplMojo>>& std::unique_ptr<SessionStorageNamespaceImplMojo>>&
namespaces_map); namespaces_map);
...@@ -203,7 +203,7 @@ class CONTENT_EXPORT SessionStorageNamespaceImplMojo final ...@@ -203,7 +203,7 @@ class CONTENT_EXPORT SessionStorageNamespaceImplMojo final
ReopenClonedAreaAfterPurge); ReopenClonedAreaAfterPurge);
const std::string namespace_id_; const std::string namespace_id_;
SessionStorageMetadata::NamespaceEntry namespace_entry_; storage::SessionStorageMetadata::NamespaceEntry namespace_entry_;
storage::AsyncDomStorageDatabase* database_ = nullptr; storage::AsyncDomStorageDatabase* database_ = nullptr;
SessionStorageDataMap::Listener* data_map_listener_; SessionStorageDataMap::Listener* data_map_listener_;
......
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "components/services/storage/dom_storage/async_dom_storage_database.h" #include "components/services/storage/dom_storage/async_dom_storage_database.h"
#include "components/services/storage/dom_storage/dom_storage_database.h" #include "components/services/storage/dom_storage/dom_storage_database.h"
#include "components/services/storage/dom_storage/session_storage_metadata.h"
#include "components/services/storage/dom_storage/storage_area_test_util.h" #include "components/services/storage/dom_storage/storage_area_test_util.h"
#include "content/browser/child_process_security_policy_impl.h" #include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/dom_storage/session_storage_data_map.h" #include "content/browser/dom_storage/session_storage_data_map.h"
#include "content/browser/dom_storage/session_storage_metadata.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_context.h"
#include "content/test/gmock_util.h" #include "content/test/gmock_util.h"
...@@ -32,7 +32,7 @@ namespace content { ...@@ -32,7 +32,7 @@ namespace content {
namespace { namespace {
using NamespaceEntry = SessionStorageMetadata::NamespaceEntry; using NamespaceEntry = storage::SessionStorageMetadata::NamespaceEntry;
constexpr const int kTestProcessIdOrigin1 = 11; constexpr const int kTestProcessIdOrigin1 = 11;
constexpr const int kTestProcessIdAllOrigins = 12; constexpr const int kTestProcessIdAllOrigins = 12;
...@@ -154,7 +154,7 @@ class SessionStorageNamespaceImplMojoTest ...@@ -154,7 +154,7 @@ class SessionStorageNamespaceImplMojoTest
return namespace_impl_ptr; return namespace_impl_ptr;
} }
scoped_refptr<SessionStorageMetadata::MapData> RegisterNewAreaMap( scoped_refptr<storage::SessionStorageMetadata::MapData> RegisterNewAreaMap(
NamespaceEntry namespace_entry, NamespaceEntry namespace_entry,
const url::Origin& origin) { const url::Origin& origin) {
std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask> save_tasks; std::vector<storage::AsyncDomStorageDatabase::BatchDatabaseTask> save_tasks;
...@@ -204,7 +204,7 @@ class SessionStorageNamespaceImplMojoTest ...@@ -204,7 +204,7 @@ class SessionStorageNamespaceImplMojoTest
const url::Origin test_origin1_; const url::Origin test_origin1_;
const url::Origin test_origin2_; const url::Origin test_origin2_;
const url::Origin test_origin3_; const url::Origin test_origin3_;
SessionStorageMetadata metadata_; storage::SessionStorageMetadata metadata_;
bool bad_message_called_ = false; bool bad_message_called_ = false;
std::map<std::string, std::unique_ptr<SessionStorageNamespaceImplMojo>> std::map<std::string, std::unique_ptr<SessionStorageNamespaceImplMojo>>
......
...@@ -1559,9 +1559,6 @@ test("content_unittests") { ...@@ -1559,9 +1559,6 @@ test("content_unittests") {
"../browser/dom_storage/session_storage_area_impl_unittest.cc", "../browser/dom_storage/session_storage_area_impl_unittest.cc",
"../browser/dom_storage/session_storage_context_mojo_unittest.cc", "../browser/dom_storage/session_storage_context_mojo_unittest.cc",
"../browser/dom_storage/session_storage_data_map_unittest.cc", "../browser/dom_storage/session_storage_data_map_unittest.cc",
"../browser/dom_storage/session_storage_database.cc",
"../browser/dom_storage/session_storage_database.h",
"../browser/dom_storage/session_storage_metadata_unittest.cc",
"../browser/dom_storage/session_storage_namespace_impl_mojo_unittest.cc", "../browser/dom_storage/session_storage_namespace_impl_mojo_unittest.cc",
"../browser/download/download_manager_impl_unittest.cc", "../browser/download/download_manager_impl_unittest.cc",
"../browser/download/save_package_unittest.cc", "../browser/download/save_package_unittest.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment