Revert "[SessionStorage] Renderer piping & browser stubs for mojofication."
This reverts commit ab3de2ef31b1bcf76140c6ba61fbc5514ebf7749.
Reason for revert: ODR violation - content::SessionStorageNamespace already exists.
Original change's description:
> [SessionStorage] Renderer piping & browser stubs for mojofication.
>
> This change adds a feature flag and the piping to hook up & run a mojo
> implementation of SessionStorage. Nothing is implemented yet and all
> calls trip a NOTREACHED - this is just the setup for the renderer side
> of the feature.
>
> Bug: 716490
> Change-Id: Id3ad5cf3fa1e27bf7e5ef9369818d94a1a5364d3
> Reviewed-on: https://chromium-review.googlesource.com/767287
> Reviewed-by: Oliver Chang <ochang@chromium.org>
> Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
> Commit-Queue: Daniel Murphy <dmurph@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#517619}
TBR=dmurph@chromium.org,jam@chromium.org,mek@chromium.org,ochang@chromium.org
Change-Id: I51f09c1bc483ec16e3ae038d9117523c788b9442
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 716490
Reviewed-on: https://chromium-review.googlesource.com/777411
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517718}
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
index d64f9b7..3f53c89e 100644
--- a/content/browser/BUILD.gn
+++ b/content/browser/BUILD.gn
@@ -662,8 +662,6 @@
"dom_storage/local_storage_context_mojo.h",
"dom_storage/local_storage_database_adapter.cc",
"dom_storage/local_storage_database_adapter.h",
- "dom_storage/session_storage_context_mojo.cc",
- "dom_storage/session_storage_context_mojo.h",
"dom_storage/session_storage_database.cc",
"dom_storage/session_storage_database.h",
"dom_storage/session_storage_database_adapter.cc",
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.cc b/content/browser/dom_storage/dom_storage_context_wrapper.cc
index 382ccddd..bb57d32 100644
--- a/content/browser/dom_storage/dom_storage_context_wrapper.cc
+++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc
@@ -25,7 +25,6 @@
#include "content/browser/dom_storage/dom_storage_context_impl.h"
#include "content/browser/dom_storage/dom_storage_task_runner.h"
#include "content/browser/dom_storage/local_storage_context_mojo.h"
-#include "content/browser/dom_storage/session_storage_context_mojo.h"
#include "content/browser/dom_storage/session_storage_namespace_impl.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/local_storage_usage_info.h"
@@ -136,15 +135,6 @@
storage_dir, special_storage_policy);
}
- if (base::FeatureList::IsEnabled(features::kMojoSessionStorage)) {
- base::FilePath session_storage_dir;
- if (!profile_path.empty())
- session_storage_dir =
- local_partition_path.AppendASCII(kSessionStorageDirectory);
- mojo_session_state_ = std::make_unique<SessionStorageContextMojo>(
- connector, session_storage_dir);
- }
-
if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this);
} else {
@@ -342,16 +332,6 @@
std::move(request)));
}
-void DOMStorageContextWrapper::OpenSessionStorage(
- int64_t namespace_id,
- const url::Origin& origin,
- mojom::LevelDBWrapperRequest request) {
- if (!mojo_session_state_)
- return;
- mojo_session_state_->OpenSessionStorage(namespace_id, origin,
- std::move(request));
-}
-
void DOMStorageContextWrapper::SetLocalStorageDatabaseForTesting(
leveldb::mojom::LevelDBDatabaseAssociatedPtr database) {
if (!mojo_state_)
@@ -366,12 +346,6 @@
base::Unretained(mojo_state_), std::move(database)));
}
-base::WeakPtr<SessionStorageContextMojo>
-DOMStorageContextWrapper::GetMojoSessionStateWeakPtr() {
- return mojo_session_state_ ? mojo_session_state_->AsWeakPtr()
- : base::WeakPtr<SessionStorageContextMojo>();
-}
-
void DOMStorageContextWrapper::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
DOMStorageContextImpl::PurgeOption purge_option =
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.h b/content/browser/dom_storage/dom_storage_context_wrapper.h
index ccc7d2f..ef74dc30 100644
--- a/content/browser/dom_storage/dom_storage_context_wrapper.h
+++ b/content/browser/dom_storage/dom_storage_context_wrapper.h
@@ -12,7 +12,6 @@
#include "base/memory/memory_coordinator_client.h"
#include "base/memory/memory_pressure_listener.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
#include "content/browser/dom_storage/dom_storage_context_impl.h"
#include "content/common/content_export.h"
#include "content/common/storage_partition_service.mojom.h"
@@ -35,7 +34,6 @@
class DOMStorageContextImpl;
class LocalStorageContextMojo;
-class SessionStorageContextMojo;
// This is owned by Storage Partition and encapsulates all its dom storage
// state.
@@ -78,9 +76,6 @@
// See mojom::StoragePartitionService interface.
void OpenLocalStorage(const url::Origin& origin,
mojom::LevelDBWrapperRequest request);
- void OpenSessionStorage(int64_t namespace_id,
- const url::Origin& origin,
- mojom::LevelDBWrapperRequest request);
void SetLocalStorageDatabaseForTesting(
leveldb::mojom::LevelDBDatabaseAssociatedPtr database);
@@ -93,10 +88,6 @@
~DOMStorageContextWrapper() override;
DOMStorageContextImpl* context() const { return context_.get(); }
- SessionStorageContextMojo* mojo_session_state() {
- return mojo_session_state_.get();
- }
- base::WeakPtr<SessionStorageContextMojo> GetMojoSessionStateWeakPtr();
// Called on UI thread when the system is under memory pressure.
void OnMemoryPressure(
@@ -112,7 +103,6 @@
// asynchronously on the |mojo_task_runner_|.
LocalStorageContextMojo* mojo_state_ = nullptr;
scoped_refptr<base::SingleThreadTaskRunner> mojo_task_runner_;
- std::unique_ptr<SessionStorageContextMojo> mojo_session_state_;
// To receive memory pressure signals.
std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
diff --git a/content/browser/dom_storage/dom_storage_session.cc b/content/browser/dom_storage/dom_storage_session.cc
index a8a4595..3cdaded 100644
--- a/content/browser/dom_storage/dom_storage_session.cc
+++ b/content/browser/dom_storage/dom_storage_session.cc
@@ -9,15 +9,11 @@
#include "base/logging.h"
#include "content/browser/dom_storage/dom_storage_context_impl.h"
#include "content/browser/dom_storage/dom_storage_task_runner.h"
-#include "content/browser/dom_storage/session_storage_context_mojo.h"
namespace content {
-DOMStorageSession::DOMStorageSession(
- DOMStorageContextImpl* context,
- base::WeakPtr<SessionStorageContextMojo> mojo_context)
+DOMStorageSession::DOMStorageSession(DOMStorageContextImpl* context)
: context_(context),
- mojo_context_(mojo_context),
namespace_id_(context->AllocateSessionId()),
persistent_namespace_id_(context->AllocatePersistentSessionId()),
should_persist_(false) {
@@ -25,17 +21,11 @@
FROM_HERE,
base::BindOnce(&DOMStorageContextImpl::CreateSessionNamespace, context_,
namespace_id_, persistent_namespace_id_));
- if (mojo_context_)
- mojo_context_->CreateSessionNamespace(namespace_id_,
- persistent_namespace_id_);
}
-DOMStorageSession::DOMStorageSession(
- DOMStorageContextImpl* context,
- base::WeakPtr<SessionStorageContextMojo> mojo_context,
- const std::string& persistent_namespace_id)
+DOMStorageSession::DOMStorageSession(DOMStorageContextImpl* context,
+ const std::string& persistent_namespace_id)
: context_(context),
- mojo_context_(mojo_context),
namespace_id_(context->AllocateSessionId()),
persistent_namespace_id_(persistent_namespace_id),
should_persist_(false) {
@@ -43,9 +33,6 @@
FROM_HERE,
base::BindOnce(&DOMStorageContextImpl::CreateSessionNamespace, context_,
namespace_id_, persistent_namespace_id_));
- if (mojo_context_)
- mojo_context_->CreateSessionNamespace(namespace_id_,
- persistent_namespace_id_);
}
void DOMStorageSession::SetShouldPersist(bool should_persist) {
@@ -61,34 +48,25 @@
}
DOMStorageSession* DOMStorageSession::Clone() {
- return CloneFrom(context_.get(), mojo_context_, namespace_id_);
+ return CloneFrom(context_.get(), namespace_id_);
}
// static
-DOMStorageSession* DOMStorageSession::CloneFrom(
- DOMStorageContextImpl* context,
- base::WeakPtr<SessionStorageContextMojo> mojo_context,
- int64_t namespace_id_to_clone) {
+DOMStorageSession* DOMStorageSession::CloneFrom(DOMStorageContextImpl* context,
+ int64_t namepace_id_to_clone) {
int64_t clone_id = context->AllocateSessionId();
std::string persistent_clone_id = context->AllocatePersistentSessionId();
context->task_runner()->PostTask(
FROM_HERE,
base::BindOnce(&DOMStorageContextImpl::CloneSessionNamespace, context,
- namespace_id_to_clone, clone_id, persistent_clone_id));
- if (mojo_context)
- mojo_context->CloneSessionNamespace(namespace_id_to_clone, clone_id,
- persistent_clone_id);
- return new DOMStorageSession(context, std::move(mojo_context), clone_id,
- persistent_clone_id);
+ namepace_id_to_clone, clone_id, persistent_clone_id));
+ return new DOMStorageSession(context, clone_id, persistent_clone_id);
}
-DOMStorageSession::DOMStorageSession(
- DOMStorageContextImpl* context,
- base::WeakPtr<SessionStorageContextMojo> mojo_context,
- int64_t namespace_id,
- const std::string& persistent_namespace_id)
+DOMStorageSession::DOMStorageSession(DOMStorageContextImpl* context,
+ int64_t namespace_id,
+ const std::string& persistent_namespace_id)
: context_(context),
- mojo_context_(mojo_context),
namespace_id_(namespace_id),
persistent_namespace_id_(persistent_namespace_id),
should_persist_(false) {
@@ -99,8 +77,6 @@
context_->task_runner()->PostTask(
FROM_HERE, base::BindOnce(&DOMStorageContextImpl::DeleteSessionNamespace,
context_, namespace_id_, should_persist_));
- if (mojo_context_)
- mojo_context_->DeleteSessionNamespace(namespace_id_, should_persist_);
}
} // namespace content
diff --git a/content/browser/dom_storage/dom_storage_session.h b/content/browser/dom_storage/dom_storage_session.h
index 352a41e..08e54f3 100644
--- a/content/browser/dom_storage/dom_storage_session.h
+++ b/content/browser/dom_storage/dom_storage_session.h
@@ -11,13 +11,11 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
namespace content {
class DOMStorageContextImpl;
-class SessionStorageContextMojo;
// This refcounted class determines the lifetime of a session
// storage namespace and provides an interface to Clone() an
@@ -27,14 +25,11 @@
: public base::RefCountedThreadSafe<DOMStorageSession> {
public:
// Constructs a |DOMStorageSession| and allocates new IDs for it.
- explicit DOMStorageSession(
- DOMStorageContextImpl* context,
- base::WeakPtr<SessionStorageContextMojo> mojo_context);
+ explicit DOMStorageSession(DOMStorageContextImpl* context);
// Constructs a |DOMStorageSession| and assigns |persistent_namespace_id|
// to it. Allocates a new non-persistent ID.
DOMStorageSession(DOMStorageContextImpl* context,
- base::WeakPtr<SessionStorageContextMojo> mojo_context,
const std::string& persistent_namespace_id);
int64_t namespace_id() const { return namespace_id_; }
@@ -48,22 +43,18 @@
// Constructs a |DOMStorageSession| by cloning
// |namespace_id_to_clone|. Allocates new IDs for it.
- static DOMStorageSession* CloneFrom(
- DOMStorageContextImpl* context,
- base::WeakPtr<SessionStorageContextMojo> mojo_context,
- int64_t namepace_id_to_clone);
+ static DOMStorageSession* CloneFrom(DOMStorageContextImpl* context,
+ int64_t namepace_id_to_clone);
private:
friend class base::RefCountedThreadSafe<DOMStorageSession>;
DOMStorageSession(DOMStorageContextImpl* context,
- base::WeakPtr<SessionStorageContextMojo> mojo_context,
int64_t namespace_id,
const std::string& persistent_namespace_id);
~DOMStorageSession();
scoped_refptr<DOMStorageContextImpl> context_;
- base::WeakPtr<SessionStorageContextMojo> mojo_context_;
int64_t namespace_id_;
std::string persistent_namespace_id_;
bool should_persist_;
diff --git a/content/browser/dom_storage/local_storage_context_mojo.h b/content/browser/dom_storage/local_storage_context_mojo.h
index e100572..0dda7b2 100644
--- a/content/browser/dom_storage/local_storage_context_mojo.h
+++ b/content/browser/dom_storage/local_storage_context_mojo.h
@@ -5,15 +5,9 @@
#ifndef CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_CONTEXT_MOJO_H_
#define CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_CONTEXT_MOJO_H_
-#include <stdint.h>
-#include <map>
#include <memory>
-#include <string>
-#include <vector>
-#include "base/callback_forward.h"
#include "base/files/file_path.h"
-#include "base/memory/ref_counted.h"
#include "base/trace_event/memory_dump_provider.h"
#include "content/common/content_export.h"
#include "content/common/leveldb_wrapper.mojom.h"
diff --git a/content/browser/dom_storage/session_storage_context_mojo.cc b/content/browser/dom_storage/session_storage_context_mojo.cc
deleted file mode 100644
index 7ed27d6..0000000
--- a/content/browser/dom_storage/session_storage_context_mojo.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/browser/dom_storage/session_storage_context_mojo.h"
-
-#include "content/browser/leveldb_wrapper_impl.h"
-#include "content/common/dom_storage/dom_storage_types.h"
-#include "content/public/common/content_features.h"
-#include "services/service_manager/public/cpp/connector.h"
-
-namespace content {
-
-SessionStorageContextMojo::SessionStorageContextMojo(
- service_manager::Connector* connector,
- base::FilePath subdirectory)
- : connector_(connector ? connector->Clone() : nullptr),
- subdirectory_(std::move(subdirectory)),
- weak_ptr_factory_(this) {
- DCHECK(base::FeatureList::IsEnabled(features::kMojoSessionStorage));
-}
-
-SessionStorageContextMojo::~SessionStorageContextMojo() {}
-
-void SessionStorageContextMojo::OpenSessionStorage(
- int64_t namespace_id,
- const url::Origin& origin,
- mojom::LevelDBWrapperRequest request) {
- NOTREACHED();
-}
-
-void SessionStorageContextMojo::CreateSessionNamespace(
- int64_t namespace_id,
- const std::string& persistent_namespace_id) {
- NOTREACHED();
-}
-
-void SessionStorageContextMojo::CloneSessionNamespace(
- int64_t namespace_id_to_clone,
- int64_t clone_namespace_id,
- const std::string& clone_persistent_namespace_id) {
- NOTREACHED();
-}
-
-void SessionStorageContextMojo::DeleteSessionNamespace(int64_t namespace_id,
- bool should_persist) {
- NOTREACHED();
-}
-
-void SessionStorageContextMojo::PurgeMemory() {
- NOTREACHED();
-}
-
-void SessionStorageContextMojo::PurgeUnusedWrappersIfNeeded() {
- NOTREACHED();
-}
-
-} // namespace content
diff --git a/content/browser/dom_storage/session_storage_context_mojo.h b/content/browser/dom_storage/session_storage_context_mojo.h
deleted file mode 100644
index 49465ccf7..0000000
--- a/content/browser/dom_storage/session_storage_context_mojo.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_CONTEXT_MOJO_H_
-#define CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_CONTEXT_MOJO_H_
-
-#include <stdint.h>
-#include <memory>
-#include <string>
-
-#include "base/files/file_path.h"
-#include "base/memory/weak_ptr.h"
-#include "content/common/content_export.h"
-#include "content/common/leveldb_wrapper.mojom.h"
-#include "url/origin.h"
-
-namespace service_manager {
-class Connector;
-} // namespace service_manager
-
-namespace content {
-
-// Used for mojo-based SessionStorage implementation.
-class CONTENT_EXPORT SessionStorageContextMojo {
- public:
- SessionStorageContextMojo(service_manager::Connector* connector,
- base::FilePath subdirectory);
- ~SessionStorageContextMojo();
-
- void OpenSessionStorage(int64_t namespace_id,
- const url::Origin& origin,
- mojom::LevelDBWrapperRequest request);
-
- void CreateSessionNamespace(int64_t namespace_id,
- const std::string& persistent_namespace_id);
- void CloneSessionNamespace(int64_t namespace_id_to_clone,
- int64_t clone_namespace_id,
- const std::string& clone_persistent_namespace_id);
- void DeleteSessionNamespace(int64_t namespace_id, bool should_persist);
-
- // Clears any caches, to free up as much memory as possible. Next access to
- // storage for a particular origin will reload the data from the database.
- void PurgeMemory();
-
- // Clears unused leveldb wrappers, when thresholds are reached.
- void PurgeUnusedWrappersIfNeeded();
-
- base::WeakPtr<SessionStorageContextMojo> AsWeakPtr() {
- return weak_ptr_factory_.GetWeakPtr();
- }
-
- private:
- std::unique_ptr<service_manager::Connector> connector_;
- const base::FilePath subdirectory_;
-
- base::WeakPtrFactory<SessionStorageContextMojo> weak_ptr_factory_;
-};
-
-} // namespace content
-
-#endif // CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_CONTEXT_MOJO_H_
diff --git a/content/browser/dom_storage/session_storage_namespace_impl.cc b/content/browser/dom_storage/session_storage_namespace_impl.cc
index b241ef791..0811fab4 100644
--- a/content/browser/dom_storage/session_storage_namespace_impl.cc
+++ b/content/browser/dom_storage/session_storage_namespace_impl.cc
@@ -6,29 +6,24 @@
#include "content/browser/dom_storage/dom_storage_context_wrapper.h"
#include "content/browser/dom_storage/dom_storage_session.h"
-#include "content/browser/dom_storage/session_storage_context_mojo.h"
namespace content {
SessionStorageNamespaceImpl::SessionStorageNamespaceImpl(
DOMStorageContextWrapper* context)
- : session_(new DOMStorageSession(context->context(),
- context->GetMojoSessionStateWeakPtr())) {}
+ : session_(new DOMStorageSession(context->context())) {
+}
SessionStorageNamespaceImpl::SessionStorageNamespaceImpl(
DOMStorageContextWrapper* context,
int64_t namepace_id_to_clone)
- : session_(
- DOMStorageSession::CloneFrom(context->context(),
- context->GetMojoSessionStateWeakPtr(),
- namepace_id_to_clone)) {}
+ : session_(DOMStorageSession::CloneFrom(context->context(),
+ namepace_id_to_clone)) {}
SessionStorageNamespaceImpl::SessionStorageNamespaceImpl(
- DOMStorageContextWrapper* context,
- const std::string& persistent_id)
- : session_(new DOMStorageSession(context->context(),
- context->GetMojoSessionStateWeakPtr(),
- persistent_id)) {}
+ DOMStorageContextWrapper* context, const std::string& persistent_id)
+ : session_(new DOMStorageSession(context->context(), persistent_id)) {
+}
int64_t SessionStorageNamespaceImpl::id() const {
return session_->namespace_id();
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
index 534b806..8bb3eaa 100644
--- a/content/browser/storage_partition_impl.cc
+++ b/content/browser/storage_partition_impl.cc
@@ -706,20 +706,6 @@
dom_storage_context_->OpenLocalStorage(origin, std::move(request));
}
-void StoragePartitionImpl::OpenSessionStorage(
- int64_t namespace_id,
- const url::Origin& origin,
- mojo::InterfaceRequest<mojom::LevelDBWrapper> request) {
- int process_id = bindings_.dispatch_context();
- if (!ChildProcessSecurityPolicy::GetInstance()->CanAccessDataForOrigin(
- process_id, origin.GetURL())) {
- bindings_.ReportBadMessage("Access denied for sessionStorage request");
- return;
- }
- dom_storage_context_->OpenSessionStorage(namespace_id, origin,
- std::move(request));
-}
-
void StoragePartitionImpl::ClearDataImpl(
uint32_t remove_mask,
uint32_t quota_storage_remove_mask,
diff --git a/content/browser/storage_partition_impl.h b/content/browser/storage_partition_impl.h
index 7fe4531..6e62286 100644
--- a/content/browser/storage_partition_impl.h
+++ b/content/browser/storage_partition_impl.h
@@ -130,10 +130,6 @@
void OpenLocalStorage(
const url::Origin& origin,
mojo::InterfaceRequest<mojom::LevelDBWrapper> request) override;
- void OpenSessionStorage(
- int64_t namespace_id,
- const url::Origin& origin,
- mojo::InterfaceRequest<mojom::LevelDBWrapper> request) override;
scoped_refptr<URLLoaderFactoryGetter> url_loader_factory_getter() {
return url_loader_factory_getter_;
diff --git a/content/common/storage_partition_service.mojom b/content/common/storage_partition_service.mojom
index 9e1816e..5aca10a 100644
--- a/content/common/storage_partition_service.mojom
+++ b/content/common/storage_partition_service.mojom
@@ -11,7 +11,4 @@
interface StoragePartitionService {
OpenLocalStorage(url.mojom.Origin origin,
LevelDBWrapper& database);
- OpenSessionStorage(int64 namespace_id,
- url.mojom.Origin origin,
- LevelDBWrapper& database);
};
diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc
index e8cd7523..56e583b1 100644
--- a/content/public/common/content_features.cc
+++ b/content/public/common/content_features.cc
@@ -168,10 +168,6 @@
const base::Feature kMojoInputMessages{"MojoInputMessages",
base::FEATURE_DISABLED_BY_DEFAULT};
-// Mojo-based Session Storage.
-const base::Feature kMojoSessionStorage{"MojoSessionStorage",
- base::FEATURE_DISABLED_BY_DEFAULT};
-
// Enables/disables hardware video encode acceleration using Mojo (falls back).
const base::Feature kMojoVideoEncodeAccelerator{
"MojoVideoEncodeAccelerator", base::FEATURE_ENABLED_BY_DEFAULT};
diff --git a/content/public/common/content_features.h b/content/public/common/content_features.h
index 55bab48..93f8abc 100644
--- a/content/public/common/content_features.h
+++ b/content/public/common/content_features.h
@@ -53,7 +53,6 @@
CONTENT_EXPORT extern const base::Feature kMainThreadBusyScrollIntervention;
CONTENT_EXPORT extern const base::Feature kMojoBlobs;
CONTENT_EXPORT extern const base::Feature kMojoInputMessages;
-CONTENT_EXPORT extern const base::Feature kMojoSessionStorage;
CONTENT_EXPORT extern const base::Feature kMojoVideoEncodeAccelerator;
CONTENT_EXPORT extern const base::Feature kModuleScriptsDynamicImport;
CONTENT_EXPORT extern const base::Feature kModuleScriptsImportMetaUrl;
diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn
index effb9ef..aab7b16 100644
--- a/content/renderer/BUILD.gn
+++ b/content/renderer/BUILD.gn
@@ -119,8 +119,6 @@
"dom_storage/local_storage_cached_areas.h",
"dom_storage/local_storage_namespace.cc",
"dom_storage/local_storage_namespace.h",
- "dom_storage/session_storage_namespace.cc",
- "dom_storage/session_storage_namespace.h",
"dom_storage/webstoragearea_impl.cc",
"dom_storage/webstoragearea_impl.h",
"dom_storage/webstoragenamespace_impl.cc",
diff --git a/content/renderer/dom_storage/local_storage_cached_area.cc b/content/renderer/dom_storage/local_storage_cached_area.cc
index c9179c0..ee84f52 100644
--- a/content/renderer/dom_storage/local_storage_cached_area.cc
+++ b/content/renderer/dom_storage/local_storage_cached_area.cc
@@ -67,32 +67,11 @@
}
LocalStorageCachedArea::LocalStorageCachedArea(
- int64_t namespace_id,
const url::Origin& origin,
mojom::StoragePartitionService* storage_partition_service,
LocalStorageCachedAreas* cached_areas)
- : namespace_id_(namespace_id),
- origin_(origin),
- binding_(this),
- cached_areas_(cached_areas),
- weak_factory_(this) {
- DCHECK_NE(namespace_id, kInvalidSessionStorageNamespaceId);
- storage_partition_service->OpenSessionStorage(namespace_id, origin_,
- mojo::MakeRequest(&leveldb_));
- mojom::LevelDBObserverAssociatedPtrInfo ptr_info;
- binding_.Bind(mojo::MakeRequest(&ptr_info));
- leveldb_->AddObserver(std::move(ptr_info));
-}
-
-LocalStorageCachedArea::LocalStorageCachedArea(
- const url::Origin& origin,
- mojom::StoragePartitionService* storage_partition_service,
- LocalStorageCachedAreas* cached_areas)
- : namespace_id_(kLocalStorageNamespaceId),
- origin_(origin),
- binding_(this),
- cached_areas_(cached_areas),
- weak_factory_(this) {
+ : origin_(origin), binding_(this),
+ cached_areas_(cached_areas), weak_factory_(this) {
storage_partition_service->OpenLocalStorage(origin_,
mojo::MakeRequest(&leveldb_));
mojom::LevelDBObserverAssociatedPtrInfo ptr_info;
diff --git a/content/renderer/dom_storage/local_storage_cached_area.h b/content/renderer/dom_storage/local_storage_cached_area.h
index 5008b85..0289e4a1 100644
--- a/content/renderer/dom_storage/local_storage_cached_area.h
+++ b/content/renderer/dom_storage/local_storage_cached_area.h
@@ -33,17 +33,11 @@
// callbacks.
// There is one LocalStorageCachedArea for potentially many LocalStorageArea
// objects.
-// TODO(dmurph): Rename to remove LocalStorage.
class CONTENT_EXPORT LocalStorageCachedArea
: public mojom::LevelDBObserver,
public base::RefCounted<LocalStorageCachedArea> {
public:
LocalStorageCachedArea(
- int64_t namespace_id,
- const url::Origin& origin,
- mojom::StoragePartitionService* storage_partition_service,
- LocalStorageCachedAreas* cached_areas);
- LocalStorageCachedArea(
const url::Origin& origin,
mojom::StoragePartitionService* storage_partition_service,
LocalStorageCachedAreas* cached_areas);
@@ -66,7 +60,6 @@
void AreaCreated(LocalStorageArea* area);
void AreaDestroyed(LocalStorageArea* area);
- int64_t namespace_id() { return namespace_id_; }
const url::Origin& origin() { return origin_; }
size_t memory_used() const { return map_ ? map_->memory_used() : 0; }
@@ -114,7 +107,6 @@
// Resets the object back to its newly constructed state.
void Reset();
- int64_t namespace_id_;
url::Origin origin_;
scoped_refptr<DOMStorageMap> map_;
std::map<base::string16, int> ignore_key_mutations_;
diff --git a/content/renderer/dom_storage/local_storage_cached_areas.cc b/content/renderer/dom_storage/local_storage_cached_areas.cc
index d0fc0728..8f0ef74 100644
--- a/content/renderer/dom_storage/local_storage_cached_areas.cc
+++ b/content/renderer/dom_storage/local_storage_cached_areas.cc
@@ -6,7 +6,6 @@
#include "base/metrics/histogram_macros.h"
#include "base/sys_info.h"
-#include "content/common/dom_storage/dom_storage_types.h"
#include "content/renderer/dom_storage/local_storage_cached_area.h"
namespace content {
@@ -26,14 +25,37 @@
scoped_refptr<LocalStorageCachedArea> LocalStorageCachedAreas::GetCachedArea(
const url::Origin& origin) {
- return GetCachedArea(kLocalStorageNamespaceId, origin);
-}
+ // These values are persisted to logs. Entries should not be renumbered and
+ // numeric values should never be reused.
+ enum class CacheMetrics {
+ kMiss = 0, // Area not in cache.
+ kHit = 1, // Area with refcount = 0 loaded from cache.
+ kUnused = 2, // Cache was not used. Area had refcount > 0.
+ kMaxValue
+ };
-scoped_refptr<LocalStorageCachedArea>
-LocalStorageCachedAreas::GetSessionStorageArea(int64_t namespace_id,
- const url::Origin& origin) {
- DCHECK_NE(kLocalStorageNamespaceId, kInvalidSessionStorageNamespaceId);
- return GetCachedArea(namespace_id, origin);
+ auto it = cached_areas_.find(origin);
+ if (it != cached_areas_.end()) {
+ if (it->second->HasOneRef()) {
+ UMA_HISTOGRAM_ENUMERATION("LocalStorage.RendererAreaCacheHit",
+ CacheMetrics::kHit, CacheMetrics::kMaxValue);
+ } else {
+ UMA_HISTOGRAM_ENUMERATION("LocalStorage.RendererAreaCacheHit",
+ CacheMetrics::kUnused, CacheMetrics::kMaxValue);
+ }
+ } else {
+ UMA_HISTOGRAM_ENUMERATION("LocalStorage.RendererAreaCacheHit",
+ CacheMetrics::kMiss, CacheMetrics::kMaxValue);
+ }
+
+ if (it == cached_areas_.end()) {
+ ClearAreasIfNeeded();
+ it = cached_areas_
+ .emplace(origin, new LocalStorageCachedArea(
+ origin, storage_partition_service_, this))
+ .first;
+ }
+ return it->second;
}
size_t LocalStorageCachedAreas::TotalCacheSize() const {
@@ -55,52 +77,4 @@
}
}
-scoped_refptr<LocalStorageCachedArea> LocalStorageCachedAreas::GetCachedArea(
- int64_t namespace_id,
- const url::Origin& origin) {
- AreaKey key(namespace_id, origin);
-
- // These values are persisted to logs. Entries should not be renumbered and
- // numeric values should never be reused.
- enum class CacheMetrics {
- kMiss = 0, // Area not in cache.
- kHit = 1, // Area with refcount = 0 loaded from cache.
- kUnused = 2, // Cache was not used. Area had refcount > 0.
- kMaxValue
- };
-
- auto it = cached_areas_.find(key);
- CacheMetrics metric;
- if (it != cached_areas_.end()) {
- if (it->second->HasOneRef()) {
- metric = CacheMetrics::kHit;
- } else {
- metric = CacheMetrics::kUnused;
- }
- } else {
- metric = CacheMetrics::kMiss;
- }
- if (namespace_id == kLocalStorageNamespaceId) {
- UMA_HISTOGRAM_ENUMERATION("LocalStorage.RendererAreaCacheHit", metric,
- CacheMetrics::kMaxValue);
- } else {
- LOCAL_HISTOGRAM_ENUMERATION("SessionStorage.RendererAreaCacheHit", metric,
- CacheMetrics::kMaxValue);
- }
-
- if (it == cached_areas_.end()) {
- ClearAreasIfNeeded();
- scoped_refptr<LocalStorageCachedArea> area;
- if (namespace_id == kLocalStorageNamespaceId) {
- area = base::MakeRefCounted<LocalStorageCachedArea>(
- origin, storage_partition_service_, this);
- } else {
- area = base::MakeRefCounted<LocalStorageCachedArea>(
- namespace_id, origin, storage_partition_service_, this);
- }
- it = cached_areas_.emplace(key, std::move(area)).first;
- }
- return it->second;
-}
-
} // namespace content
diff --git a/content/renderer/dom_storage/local_storage_cached_areas.h b/content/renderer/dom_storage/local_storage_cached_areas.h
index fb9fe8e..9bce97c6 100644
--- a/content/renderer/dom_storage/local_storage_cached_areas.h
+++ b/content/renderer/dom_storage/local_storage_cached_areas.h
@@ -23,7 +23,6 @@
// needed because we can have n LocalStorageArea objects for the same origin but
// we want just one LocalStorageCachedArea to service them (no point in having
// multiple caches of the same data in the same process).
-// TODO(dmurph): Rename to remove LocalStorage.
class CONTENT_EXPORT LocalStorageCachedAreas {
public:
explicit LocalStorageCachedAreas(
@@ -34,10 +33,6 @@
scoped_refptr<LocalStorageCachedArea>
GetCachedArea(const url::Origin& origin);
- scoped_refptr<LocalStorageCachedArea> GetSessionStorageArea(
- int64_t namespace_id,
- const url::Origin& origin);
-
size_t TotalCacheSize() const;
void set_cache_limit_for_testing(size_t limit) { total_cache_limit_ = limit; }
@@ -45,17 +40,11 @@
private:
void ClearAreasIfNeeded();
- scoped_refptr<LocalStorageCachedArea> GetCachedArea(
- int64_t namespace_id,
- const url::Origin& origin);
-
mojom::StoragePartitionService* const storage_partition_service_;
- // Maps from a namespace + origin to its LocalStorageCachedArea object. When
- // this map is the only reference to the object, it can be deleted by the
- // cache.
- using AreaKey = std::pair<int64_t, url::Origin>;
- std::map<AreaKey, scoped_refptr<LocalStorageCachedArea>> cached_areas_;
+ // Maps from an origin to its LocalStorageCachedArea object. When this map is
+ // the only reference to the object, it can be deleted by the cache.
+ std::map<url::Origin, scoped_refptr<LocalStorageCachedArea>> cached_areas_;
size_t total_cache_limit_;
DISALLOW_COPY_AND_ASSIGN(LocalStorageCachedAreas);
diff --git a/content/renderer/dom_storage/mock_leveldb_wrapper.cc b/content/renderer/dom_storage/mock_leveldb_wrapper.cc
index 8addc773..3e6b1a7 100644
--- a/content/renderer/dom_storage/mock_leveldb_wrapper.cc
+++ b/content/renderer/dom_storage/mock_leveldb_wrapper.cc
@@ -15,13 +15,6 @@
bindings_.AddBinding(this, std::move(database));
}
-void MockLevelDBWrapper::OpenSessionStorage(
- int64_t namespace_id,
- const url::Origin& origin,
- mojom::LevelDBWrapperRequest database) {
- bindings_.AddBinding(this, std::move(database));
-}
-
void MockLevelDBWrapper::AddObserver(
mojom::LevelDBObserverAssociatedPtrInfo observer) {}
diff --git a/content/renderer/dom_storage/mock_leveldb_wrapper.h b/content/renderer/dom_storage/mock_leveldb_wrapper.h
index 268da9a..25b28d92 100644
--- a/content/renderer/dom_storage/mock_leveldb_wrapper.h
+++ b/content/renderer/dom_storage/mock_leveldb_wrapper.h
@@ -22,9 +22,6 @@
// StoragePartitionService implementation:
void OpenLocalStorage(const url::Origin& origin,
mojom::LevelDBWrapperRequest database) override;
- void OpenSessionStorage(int64_t namespace_id,
- const url::Origin& origin,
- mojom::LevelDBWrapperRequest database) override;
// LevelDBWrapper implementation:
void AddObserver(mojom::LevelDBObserverAssociatedPtrInfo observer) override;
diff --git a/content/renderer/dom_storage/session_storage_namespace.cc b/content/renderer/dom_storage/session_storage_namespace.cc
deleted file mode 100644
index 5126f35a..0000000
--- a/content/renderer/dom_storage/session_storage_namespace.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/renderer/dom_storage/session_storage_namespace.h"
-
-#include "content/renderer/dom_storage/local_storage_area.h"
-#include "content/renderer/dom_storage/local_storage_cached_areas.h"
-#include "third_party/WebKit/public/platform/URLConversion.h"
-#include "third_party/WebKit/public/platform/WebURL.h"
-#include "url/gurl.h"
-#include "url/origin.h"
-
-using blink::WebStorageArea;
-using blink::WebStorageNamespace;
-
-namespace content {
-
-SessionStorageNamespace::SessionStorageNamespace(
- int64_t namespace_id,
- LocalStorageCachedAreas* local_storage_cached_areas)
- : namespace_id_(namespace_id),
- local_storage_cached_areas_(local_storage_cached_areas) {}
-
-SessionStorageNamespace::~SessionStorageNamespace() {}
-
-WebStorageArea* SessionStorageNamespace::CreateStorageArea(
- const blink::WebSecurityOrigin& origin) {
- return new LocalStorageArea(
- local_storage_cached_areas_->GetSessionStorageArea(namespace_id_,
- origin));
-}
-
-bool SessionStorageNamespace::IsSameNamespace(
- const WebStorageNamespace& other) const {
- const SessionStorageNamespace* other_impl =
- static_cast<const SessionStorageNamespace*>(&other);
- return namespace_id_ == other_impl->namespace_id_;
-}
-
-} // namespace content
diff --git a/content/renderer/dom_storage/session_storage_namespace.h b/content/renderer/dom_storage/session_storage_namespace.h
deleted file mode 100644
index 384d20aa..0000000
--- a/content/renderer/dom_storage/session_storage_namespace.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_RENDERER_DOM_STORAGE_SESSION_STORAGE_NAMESPACE_H_
-#define CONTENT_RENDERER_DOM_STORAGE_SESSION_STORAGE_NAMESPACE_H_
-
-#include "base/macros.h"
-#include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
-#include "third_party/WebKit/public/platform/WebStorageNamespace.h"
-
-namespace content {
-class LocalStorageCachedAreas;
-
-class SessionStorageNamespace : public blink::WebStorageNamespace {
- public:
- // |local_storage_cached_areas| is guaranteed to outlive this object.
- SessionStorageNamespace(int64_t namespace_id,
- LocalStorageCachedAreas* local_storage_cached_areas);
- ~SessionStorageNamespace() override;
-
- // blink::WebStorageNamespace:
- blink::WebStorageArea* CreateStorageArea(
- const blink::WebSecurityOrigin& origin) override;
- bool IsSameNamespace(const WebStorageNamespace&) const override;
-
- private:
- int64_t namespace_id_;
- LocalStorageCachedAreas* const local_storage_cached_areas_;
-
- DISALLOW_COPY_AND_ASSIGN(SessionStorageNamespace);
-};
-
-} // namespace content
-
-#endif // CONTENT_RENDERER_DOM_STORAGE_SESSION_STORAGE_NAMESPACE_H_
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index a5db6cdc..9f5a7b9 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -73,6 +73,7 @@
#include "content/renderer/appcache/web_application_cache_host_impl.h"
#include "content/renderer/browser_plugin/browser_plugin.h"
#include "content/renderer/browser_plugin/browser_plugin_manager.h"
+#include "content/renderer/dom_storage/webstoragenamespace_impl.h"
#include "content/renderer/drop_data_builder.h"
#include "content/renderer/gpu/render_widget_compositor.h"
#include "content/renderer/history_serialization.h"
@@ -236,6 +237,7 @@
using blink::WebSecurityPolicy;
using blink::WebSettings;
using blink::WebSize;
+using blink::WebStorageNamespace;
using blink::WebStorageQuotaCallbacks;
using blink::WebStorageQuotaError;
using blink::WebStorageQuotaType;
@@ -1447,9 +1449,9 @@
return widget->GetWebWidget();
}
-int64_t RenderViewImpl::GetSessionStorageNamespaceId() {
+WebStorageNamespace* RenderViewImpl::CreateSessionStorageNamespace() {
CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId);
- return session_storage_namespace_id_;
+ return new WebStorageNamespaceImpl(session_storage_namespace_id_);
}
void RenderViewImpl::PrintPage(WebLocalFrame* frame) {
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index 4558d8a..d6b96784c 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -72,6 +72,7 @@
class WebGestureEvent;
class WebMouseEvent;
class WebSpeechRecognizer;
+class WebStorageNamespace;
class WebTappedInfo;
class WebURLRequest;
struct WebDateTimeChooserParams;
@@ -280,7 +281,7 @@
bool suppress_opener,
blink::WebSandboxFlags sandbox_flags) override;
blink::WebWidget* CreatePopupMenu(blink::WebPopupType popup_type) override;
- int64_t GetSessionStorageNamespaceId() override;
+ blink::WebStorageNamespace* CreateSessionStorageNamespace() override;
void PrintPage(blink::WebLocalFrame* frame) override;
bool EnumerateChosenDirectory(
const blink::WebString& path,
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc
index e5eb7fb..5e1f72da 100644
--- a/content/renderer/renderer_blink_platform_impl.cc
+++ b/content/renderer/renderer_blink_platform_impl.cc
@@ -47,7 +47,6 @@
#include "content/renderer/device_sensors/device_orientation_event_pump.h"
#include "content/renderer/dom_storage/local_storage_cached_areas.h"
#include "content/renderer/dom_storage/local_storage_namespace.h"
-#include "content/renderer/dom_storage/session_storage_namespace.h"
#include "content/renderer/dom_storage/webstoragenamespace_impl.h"
#include "content/renderer/file_info_util.h"
#include "content/renderer/fileapi/webfilesystem_impl.h"
@@ -572,19 +571,6 @@
return std::make_unique<WebStorageNamespaceImpl>();
}
-std::unique_ptr<blink::WebStorageNamespace>
-RendererBlinkPlatformImpl::CreateSessionStorageNamespace(int64_t namespace_id) {
- if (base::FeatureList::IsEnabled(features::kMojoSessionStorage)) {
- if (!local_storage_cached_areas_) {
- local_storage_cached_areas_.reset(new LocalStorageCachedAreas(
- RenderThreadImpl::current()->GetStoragePartitionService()));
- }
- return std::make_unique<SessionStorageNamespace>(
- namespace_id, local_storage_cached_areas_.get());
- }
-
- return std::make_unique<WebStorageNamespaceImpl>(namespace_id);
-}
//------------------------------------------------------------------------------
diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h
index 7420067..f8badcc 100644
--- a/content/renderer/renderer_blink_platform_impl.h
+++ b/content/renderer/renderer_blink_platform_impl.h
@@ -112,8 +112,6 @@
blink::WebThread* CompositorThread() const override;
std::unique_ptr<blink::WebStorageNamespace> CreateLocalStorageNamespace()
override;
- std::unique_ptr<blink::WebStorageNamespace> CreateSessionStorageNamespace(
- int64_t namespace_id) override;
blink::Platform::FileHandle DatabaseOpenFile(
const blink::WebString& vfs_file_name,
int desired_flags) override;
diff --git a/third_party/WebKit/Source/modules/storage/StorageNamespaceController.cpp b/third_party/WebKit/Source/modules/storage/StorageNamespaceController.cpp
index d659efc..896f07c9 100644
--- a/third_party/WebKit/Source/modules/storage/StorageNamespaceController.cpp
+++ b/third_party/WebKit/Source/modules/storage/StorageNamespaceController.cpp
@@ -4,13 +4,10 @@
#include "modules/storage/StorageNamespaceController.h"
-#include <memory>
-
#include "core/frame/ContentSettingsClient.h"
#include "modules/storage/InspectorDOMStorageAgent.h"
#include "modules/storage/StorageNamespace.h"
#include "platform/wtf/PtrUtil.h"
-#include "public/platform/Platform.h"
#include "public/platform/WebStorageNamespace.h"
#include "public/web/WebViewClient.h"
@@ -57,9 +54,8 @@
if (!web_view_client_)
return nullptr;
- return std::make_unique<StorageNamespace>(
- Platform::Current()->CreateSessionStorageNamespace(
- web_view_client_->GetSessionStorageNamespaceId()));
+ return WTF::WrapUnique(new StorageNamespace(
+ WTF::WrapUnique(web_view_client_->CreateSessionStorageNamespace())));
}
bool StorageNamespaceController::CanAccessStorage(LocalFrame* frame,
diff --git a/third_party/WebKit/Source/platform/exported/Platform.cpp b/third_party/WebKit/Source/platform/exported/Platform.cpp
index f8bf06e..11bb6c0 100644
--- a/third_party/WebKit/Source/platform/exported/Platform.cpp
+++ b/third_party/WebKit/Source/platform/exported/Platform.cpp
@@ -210,11 +210,6 @@
return nullptr;
}
-std::unique_ptr<WebStorageNamespace> Platform::CreateSessionStorageNamespace(
- int64_t namespace_id) {
- return nullptr;
-}
-
std::unique_ptr<WebServiceWorkerCacheStorage> Platform::CreateCacheStorage(
const WebSecurityOrigin&) {
return nullptr;
diff --git a/third_party/WebKit/public/platform/Platform.h b/third_party/WebKit/public/platform/Platform.h
index aaa47b8..815cae9 100644
--- a/third_party/WebKit/public/platform/Platform.h
+++ b/third_party/WebKit/public/platform/Platform.h
@@ -262,10 +262,6 @@
// Return a LocalStorage namespace
virtual std::unique_ptr<WebStorageNamespace> CreateLocalStorageNamespace();
- // Return a SessionStorage namespace
- virtual std::unique_ptr<WebStorageNamespace> CreateSessionStorageNamespace(
- int64_t namespace_id);
-
// FileSystem ----------------------------------------------------------
// Must return non-null.
diff --git a/third_party/WebKit/public/web/WebViewClient.h b/third_party/WebKit/public/web/WebViewClient.h
index 5544343..4e8cbf1 100644
--- a/third_party/WebKit/public/web/WebViewClient.h
+++ b/third_party/WebKit/public/web/WebViewClient.h
@@ -45,6 +45,7 @@
class WebFileChooserCompletion;
class WebNode;
class WebSpeechRecognizer;
+class WebStorageNamespace;
class WebURL;
class WebURLRequest;
class WebView;
@@ -83,8 +84,8 @@
// Create a new popup WebWidget.
virtual WebWidget* CreatePopupMenu(WebPopupType) { return 0; }
- // Returns the session storage namespace id associated with this WebView.
- virtual int64_t GetSessionStorageNamespaceId() { return 0; }
+ // Create a session storage namespace object associated with this WebView.
+ virtual WebStorageNamespace* CreateSessionStorageNamespace() { return 0; }
// Misc ----------------------------------------------------------------