cef/patch/patches/storage_partition_1973.patch

474 lines
20 KiB
Diff

diff --git components/browsing_data/content/BUILD.gn components/browsing_data/content/BUILD.gn
index 6229e1b..176f897 100644
--- components/browsing_data/content/BUILD.gn
+++ components/browsing_data/content/BUILD.gn
@@ -15,6 +15,7 @@ static_library("content") {
deps = [
"//base",
"//content/public/browser",
+ "//content/public/common",
"//net",
]
}
diff --git content/browser/appcache/appcache_internals_ui.cc content/browser/appcache/appcache_internals_ui.cc
index 41f74ae..daca31a7 100644
--- content/browser/appcache/appcache_internals_ui.cc
+++ content/browser/appcache/appcache_internals_ui.cc
@@ -369,8 +369,8 @@ void AppCacheInternalsUI::CreateProxyForPartition(
StoragePartition* storage_partition) {
scoped_refptr<Proxy> proxy =
new Proxy(weak_ptr_factory_.GetWeakPtr(), storage_partition->GetPath());
- proxy->Initialize(static_cast<StoragePartitionImpl*>(storage_partition)
- ->GetAppCacheService());
+ proxy->Initialize(static_cast<ChromeAppCacheService*>(
+ storage_partition->GetAppCacheService()));
appcache_proxies_.push_back(proxy);
}
diff --git content/browser/blob_storage/chrome_blob_storage_context.cc content/browser/blob_storage/chrome_blob_storage_context.cc
index 533d3f1..f0fc700 100644
--- content/browser/blob_storage/chrome_blob_storage_context.cc
+++ content/browser/blob_storage/chrome_blob_storage_context.cc
@@ -41,6 +41,11 @@ class BlobHandleImpl : public BlobHandle {
ChromeBlobStorageContext::ChromeBlobStorageContext() {}
+// static
+const void* ChromeBlobStorageContext::GetUserDataKey() {
+ return kBlobStorageContextKeyName;
+}
+
ChromeBlobStorageContext* ChromeBlobStorageContext::GetFor(
BrowserContext* context) {
if (!context->GetUserData(kBlobStorageContextKeyName)) {
diff --git content/browser/blob_storage/chrome_blob_storage_context.h content/browser/blob_storage/chrome_blob_storage_context.h
index bd02cb1..074e77f 100644
--- content/browser/blob_storage/chrome_blob_storage_context.h
+++ content/browser/blob_storage/chrome_blob_storage_context.h
@@ -41,6 +41,7 @@ class CONTENT_EXPORT ChromeBlobStorageContext
public:
ChromeBlobStorageContext();
+ static const void* GetUserDataKey();
static ChromeBlobStorageContext* GetFor(
BrowserContext* browser_context);
diff --git content/browser/browser_context.cc content/browser/browser_context.cc
index 5b7ba41..82d8fb1 100644
--- content/browser/browser_context.cc
+++ content/browser/browser_context.cc
@@ -115,7 +115,14 @@ StoragePartition* GetStoragePartitionFromConfig(
if (browser_context->IsOffTheRecord())
in_memory = true;
- return partition_map->Get(partition_domain, partition_name, in_memory);
+ StoragePartitionImpl* partition_impl =
+ partition_map->Get(partition_domain, partition_name, in_memory);
+ if (partition_impl->browser_context() == browser_context)
+ return partition_impl;
+
+ // |browser_context| is a CefBrowserContextProxy object.
+ return partition_impl->browser_context()->
+ GetStoragePartitionProxy(browser_context, partition_impl);
}
void SaveSessionStateOnIOThread(
@@ -506,6 +513,11 @@ ServiceManagerConnection* BrowserContext::GetServiceManagerConnectionFor(
: nullptr;
}
+// static
+const void* BrowserContext::GetStoragePartitionMapUserDataKey() {
+ return kStoragePartitionMapKeyName;
+}
+
BrowserContext::~BrowserContext() {
CHECK(GetUserData(kMojoWasInitialized))
<< "Attempting to destroy a BrowserContext that never called "
diff --git content/browser/devtools/protocol/service_worker_handler.cc content/browser/devtools/protocol/service_worker_handler.cc
index c34d15a1..429c0e8 100644
--- content/browser/devtools/protocol/service_worker_handler.cc
+++ content/browser/devtools/protocol/service_worker_handler.cc
@@ -384,10 +384,9 @@ Response ServiceWorkerHandler::DispatchSyncEvent(
if (!base::StringToInt64(registration_id, &id))
return CreateInvalidVersionIdErrorResponse();
- StoragePartitionImpl* partition =
- static_cast<StoragePartitionImpl*>(BrowserContext::GetStoragePartition(
+ StoragePartition* partition = BrowserContext::GetStoragePartition(
render_frame_host_->GetProcess()->GetBrowserContext(),
- render_frame_host_->GetSiteInstance()));
+ render_frame_host_->GetSiteInstance());
BackgroundSyncContext* sync_context = partition->GetBackgroundSyncContext();
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
diff --git content/browser/renderer_host/render_process_host_impl.cc content/browser/renderer_host/render_process_host_impl.cc
index f952adc..e9998f3 100644
--- content/browser/renderer_host/render_process_host_impl.cc
+++ content/browser/renderer_host/render_process_host_impl.cc
@@ -675,7 +675,7 @@ void RenderProcessHostImpl::EarlyZygoteLaunch() {
RenderProcessHostImpl::RenderProcessHostImpl(
BrowserContext* browser_context,
- StoragePartitionImpl* storage_partition_impl,
+ StoragePartition* storage_partition_impl,
bool is_for_guests_only)
: fast_shutdown_started_(false),
deleting_soon_(false),
@@ -1024,6 +1024,22 @@ std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy() {
void RenderProcessHostImpl::CreateMessageFilters() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ // Cast to the derived type from StoragePartitionImpl.
+ auto app_cache_service = static_cast<ChromeAppCacheService*>(
+ storage_partition_impl_->GetAppCacheService());
+ auto dom_storage_context = static_cast<DOMStorageContextWrapper*>(
+ storage_partition_impl_->GetDOMStorageContext());
+ auto indexed_db_context = static_cast<IndexedDBContextImpl*>(
+ storage_partition_impl_->GetIndexedDBContext());
+ auto cache_storage_context = static_cast<CacheStorageContextImpl*>(
+ storage_partition_impl_->GetCacheStorageContext());
+ auto service_worker_context = static_cast<ServiceWorkerContextWrapper*>(
+ storage_partition_impl_->GetServiceWorkerContext());
+ auto platform_notification_context =
+ static_cast<PlatformNotificationContextImpl*>(
+ storage_partition_impl_->GetPlatformNotificationContext());
+
AddFilter(new ResourceSchedulerFilter(GetID()));
MediaInternals* media_internals = MediaInternals::GetInstance();
// Add BrowserPluginMessageFilter to ensure it gets the first stab at messages
@@ -1038,8 +1054,8 @@ void RenderProcessHostImpl::CreateMessageFilters() {
new RenderMessageFilter(
GetID(), GetBrowserContext(), request_context.get(),
widget_helper_.get(), media_internals,
- storage_partition_impl_->GetDOMStorageContext(),
- storage_partition_impl_->GetCacheStorageContext()));
+ dom_storage_context,
+ cache_storage_context));
AddFilter(render_message_filter.get());
render_frame_message_filter_ = new RenderFrameMessageFilter(
@@ -1070,9 +1086,9 @@ void RenderProcessHostImpl::CreateMessageFilters() {
resource_message_filter_ = new ResourceMessageFilter(
GetID(), PROCESS_TYPE_RENDERER,
- storage_partition_impl_->GetAppCacheService(), blob_storage_context.get(),
+ app_cache_service, blob_storage_context.get(),
storage_partition_impl_->GetFileSystemContext(),
- storage_partition_impl_->GetServiceWorkerContext(),
+ service_worker_context,
storage_partition_impl_->GetHostZoomLevelContext(),
get_contexts_callback);
@@ -1097,14 +1113,12 @@ void RenderProcessHostImpl::CreateMessageFilters() {
AddFilter(
new MidiHost(GetID(), BrowserMainLoop::GetInstance()->midi_manager()));
AddFilter(new VideoCaptureHost(media_stream_manager));
- AddFilter(new AppCacheDispatcherHost(
- storage_partition_impl_->GetAppCacheService(), GetID()));
+ AddFilter(new AppCacheDispatcherHost(app_cache_service, GetID()));
AddFilter(new ClipboardMessageFilter(blob_storage_context));
- AddFilter(new DOMStorageMessageFilter(
- storage_partition_impl_->GetDOMStorageContext()));
+ AddFilter(new DOMStorageMessageFilter(dom_storage_context));
AddFilter(new IndexedDBDispatcherHost(
GetID(), storage_partition_impl_->GetURLRequestContext(),
- storage_partition_impl_->GetIndexedDBContext(),
+ indexed_db_context,
blob_storage_context.get()));
#if defined(ENABLE_WEBRTC)
@@ -1150,14 +1164,13 @@ void RenderProcessHostImpl::CreateMessageFilters() {
scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter =
new CacheStorageDispatcherHost();
- cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext());
+ cache_storage_filter->Init(cache_storage_context);
AddFilter(cache_storage_filter.get());
scoped_refptr<ServiceWorkerDispatcherHost> service_worker_filter =
new ServiceWorkerDispatcherHost(
GetID(), message_port_message_filter_.get(), resource_context);
- service_worker_filter->Init(
- storage_partition_impl_->GetServiceWorkerContext());
+ service_worker_filter->Init(service_worker_context);
AddFilter(service_worker_filter.get());
AddFilter(new SharedWorkerMessageFilter(
@@ -1165,12 +1178,12 @@ void RenderProcessHostImpl::CreateMessageFilters() {
WorkerStoragePartition(
storage_partition_impl_->GetURLRequestContext(),
storage_partition_impl_->GetMediaURLRequestContext(),
- storage_partition_impl_->GetAppCacheService(),
+ app_cache_service,
storage_partition_impl_->GetQuotaManager(),
storage_partition_impl_->GetFileSystemContext(),
storage_partition_impl_->GetDatabaseTracker(),
- storage_partition_impl_->GetIndexedDBContext(),
- storage_partition_impl_->GetServiceWorkerContext()),
+ indexed_db_context,
+ service_worker_context),
message_port_message_filter_.get()));
#if defined(ENABLE_WEBRTC)
@@ -1185,11 +1198,8 @@ void RenderProcessHostImpl::CreateMessageFilters() {
GetID(), storage_partition_impl_->GetQuotaManager(),
GetContentClient()->browser()->CreateQuotaPermissionContext()));
- scoped_refptr<ServiceWorkerContextWrapper> service_worker_context(
- static_cast<ServiceWorkerContextWrapper*>(
- storage_partition_impl_->GetServiceWorkerContext()));
notification_message_filter_ = new NotificationMessageFilter(
- GetID(), storage_partition_impl_->GetPlatformNotificationContext(),
+ GetID(), platform_notification_context,
resource_context, service_worker_context, browser_context);
AddFilter(notification_message_filter_.get());
@@ -1198,7 +1208,7 @@ void RenderProcessHostImpl::CreateMessageFilters() {
AddFilter(new HistogramMessageFilter());
AddFilter(new MemoryMessageFilter(this));
AddFilter(new PushMessagingMessageFilter(
- GetID(), storage_partition_impl_->GetServiceWorkerContext()));
+ GetID(), service_worker_context));
#if defined(OS_ANDROID)
AddFilter(new ScreenOrientationMessageFilterAndroid());
#endif
@@ -1208,6 +1218,11 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() {
std::unique_ptr<shell::InterfaceRegistry> registry(
new shell::InterfaceRegistry);
+ // Cast to the derived type from StoragePartitionImpl.
+ auto platform_notification_context =
+ static_cast<PlatformNotificationContextImpl*>(
+ storage_partition_impl_->GetPlatformNotificationContext());
+
channel_->AddAssociatedInterface(
base::Bind(&RenderProcessHostImpl::OnRouteProviderRequest,
base::Unretained(this)));
@@ -1239,8 +1254,7 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() {
AddUIThreadInterface(
registry.get(),
base::Bind(&PlatformNotificationContextImpl::CreateService,
- base::Unretained(
- storage_partition_impl_->GetPlatformNotificationContext()),
+ base::Unretained(platform_notification_context),
GetID()));
AddUIThreadInterface(
registry.get(),
@@ -1395,6 +1409,7 @@ void RenderProcessHostImpl::ForceReleaseWorkerRefCounts() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!is_worker_ref_count_disabled_);
is_worker_ref_count_disabled_ = true;
+ browser_context_ = nullptr;
if (!worker_ref_count())
return;
service_worker_ref_count_ = 0;
diff --git content/browser/renderer_host/render_process_host_impl.h content/browser/renderer_host/render_process_host_impl.h
index f07c487e..aae8a3e 100644
--- content/browser/renderer_host/render_process_host_impl.h
+++ content/browser/renderer_host/render_process_host_impl.h
@@ -73,7 +73,6 @@ class RenderWidgetHostImpl;
class RenderWidgetHostViewFrameSubscriber;
class ResourceMessageFilter;
class StoragePartition;
-class StoragePartitionImpl;
namespace mojom {
class StoragePartitionService;
@@ -109,7 +108,7 @@ class CONTENT_EXPORT RenderProcessHostImpl
public NON_EXPORTED_BASE(mojom::AssociatedInterfaceProvider) {
public:
RenderProcessHostImpl(BrowserContext* browser_context,
- StoragePartitionImpl* storage_partition_impl,
+ StoragePartition* storage_partition_impl,
bool is_for_guests_only);
~RenderProcessHostImpl() override;
@@ -484,7 +483,7 @@ class CONTENT_EXPORT RenderProcessHostImpl
BrowserContext* browser_context_;
// Owned by |browser_context_|.
- StoragePartitionImpl* storage_partition_impl_;
+ StoragePartition* storage_partition_impl_;
// The observers watching our lifetime.
base::ObserverList<RenderProcessHostObserver> observers_;
diff --git content/browser/site_instance_impl.cc content/browser/site_instance_impl.cc
index a55d786..9e0de6a 100644
--- content/browser/site_instance_impl.cc
+++ content/browser/site_instance_impl.cc
@@ -116,9 +116,8 @@ RenderProcessHost* SiteInstanceImpl::GetProcess() {
process_ = g_render_process_host_factory_->CreateRenderProcessHost(
browser_context, this);
} else {
- StoragePartitionImpl* partition =
- static_cast<StoragePartitionImpl*>(
- BrowserContext::GetStoragePartition(browser_context, this));
+ StoragePartition* partition =
+ BrowserContext::GetStoragePartition(browser_context, this);
process_ = new RenderProcessHostImpl(browser_context,
partition,
site_.SchemeIs(kGuestScheme));
diff --git content/browser/storage_partition_impl.h content/browser/storage_partition_impl.h
index 584f2db..551e350 100644
--- content/browser/storage_partition_impl.h
+++ content/browser/storage_partition_impl.h
@@ -24,9 +24,7 @@
#include "content/browser/notifications/platform_notification_context_impl.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/common/content_export.h"
-#include "content/common/storage_partition_service.mojom.h"
#include "content/public/browser/storage_partition.h"
-#include "mojo/public/cpp/bindings/binding_set.h"
#include "net/cookies/cookie_store.h"
#include "storage/browser/quota/special_storage_policy.h"
@@ -72,9 +70,8 @@ class CONTENT_EXPORT StoragePartitionImpl
HostZoomLevelContext* GetHostZoomLevelContext() override;
ZoomLevelDelegate* GetZoomLevelDelegate() override;
PlatformNotificationContextImpl* GetPlatformNotificationContext() override;
-
- BackgroundSyncContext* GetBackgroundSyncContext();
- BroadcastChannelProvider* GetBroadcastChannelProvider();
+ BackgroundSyncContext* GetBackgroundSyncContext() override;
+ BroadcastChannelProvider* GetBroadcastChannelProvider() override;
// mojom::StoragePartitionService interface.
void OpenLocalStorage(
@@ -109,7 +106,8 @@ class CONTENT_EXPORT StoragePartitionImpl
BrowserContext* browser_context() const;
// Called by each renderer process once.
- void Bind(mojo::InterfaceRequest<mojom::StoragePartitionService> request);
+ void Bind(mojo::InterfaceRequest<mojom::StoragePartitionService> request)
+ override;
struct DataDeletionHelper;
struct QuotaManagedDataDeletionHelper;
diff --git content/browser/streams/stream_context.cc content/browser/streams/stream_context.cc
index 3782205..d3b4f07 100644
--- content/browser/streams/stream_context.cc
+++ content/browser/streams/stream_context.cc
@@ -21,6 +21,11 @@ namespace content {
StreamContext::StreamContext() {}
+// static
+const void* StreamContext::GetUserDataKey() {
+ return kStreamContextKeyName;
+}
+
StreamContext* StreamContext::GetFor(BrowserContext* context) {
if (!context->GetUserData(kStreamContextKeyName)) {
scoped_refptr<StreamContext> stream = new StreamContext();
diff --git content/browser/streams/stream_context.h content/browser/streams/stream_context.h
index 075ae3e..57fb5fd 100644
--- content/browser/streams/stream_context.h
+++ content/browser/streams/stream_context.h
@@ -29,6 +29,7 @@ class StreamContext
public:
StreamContext();
+ CONTENT_EXPORT static const void* GetUserDataKey();
CONTENT_EXPORT static StreamContext* GetFor(BrowserContext* browser_context);
void InitializeOnIOThread();
diff --git content/public/browser/browser_context.h content/public/browser/browser_context.h
index aaa5e23..2309a2a 100644
--- content/public/browser/browser_context.h
+++ content/public/browser/browser_context.h
@@ -170,6 +170,8 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
static ServiceManagerConnection* GetServiceManagerConnectionFor(
BrowserContext* browser_context);
+ static const void* GetStoragePartitionMapUserDataKey();
+
~BrowserContext() override;
// Shuts down the storage partitions associated to this browser context.
@@ -244,6 +246,14 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
CreateMediaRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory) = 0;
+
+ // CEF returns a proxy object that forwards method calls to |partition_impl|.
+ virtual content::StoragePartition* GetStoragePartitionProxy(
+ BrowserContext* browser_context,
+ content::StoragePartition* partition_impl) {
+ NOTREACHED();
+ return nullptr;
+ }
};
} // namespace content
diff --git content/public/browser/storage_partition.h content/public/browser/storage_partition.h
index 909b370..8c6f09d 100644
--- content/public/browser/storage_partition.h
+++ content/public/browser/storage_partition.h
@@ -13,6 +13,8 @@
#include "base/files/file_path.h"
#include "base/time/time.h"
#include "content/common/content_export.h"
+#include "content/common/storage_partition_service.mojom.h"
+#include "mojo/public/cpp/bindings/binding_set.h"
#include "net/cookies/cookie_store.h"
class GURL;
@@ -41,6 +43,8 @@ class DatabaseTracker;
namespace content {
class AppCacheService;
+class BackgroundSyncContext;
+class BroadcastChannelProvider;
class BrowserContext;
class CacheStorageContext;
class DOMStorageContext;
@@ -74,6 +78,8 @@ class CONTENT_EXPORT StoragePartition {
virtual HostZoomLevelContext* GetHostZoomLevelContext() = 0;
virtual ZoomLevelDelegate* GetZoomLevelDelegate() = 0;
virtual PlatformNotificationContext* GetPlatformNotificationContext() = 0;
+ virtual BackgroundSyncContext* GetBackgroundSyncContext() = 0;
+ virtual BroadcastChannelProvider* GetBroadcastChannelProvider() = 0;
enum : uint32_t {
REMOVE_DATA_MASK_APPCACHE = 1 << 0,
@@ -166,6 +172,10 @@ class CONTENT_EXPORT StoragePartition {
// unwritten data has been written out to the filesystem.
virtual void Flush() = 0;
+ // Called by each renderer process once.
+ virtual void Bind(
+ mojo::InterfaceRequest<mojom::StoragePartitionService> request) = 0;
+
protected:
virtual ~StoragePartition() {}
};
diff --git extensions/browser/guest_view/web_view/web_ui/BUILD.gn extensions/browser/guest_view/web_view/web_ui/BUILD.gn
index 9b26c41..e9f4a0c 100644
--- extensions/browser/guest_view/web_view/web_ui/BUILD.gn
+++ extensions/browser/guest_view/web_view/web_ui/BUILD.gn
@@ -3,6 +3,10 @@
# found in the LICENSE file.
source_set("web_ui") {
+ deps = [
+ "//content/public/common",
+ ]
+
sources = [
"web_ui_url_fetcher.cc",
"web_ui_url_fetcher.h",
diff --git extensions/common/api/BUILD.gn extensions/common/api/BUILD.gn
index 010da6d..a13ba7a 100644
--- extensions/common/api/BUILD.gn
+++ extensions/common/api/BUILD.gn
@@ -99,6 +99,7 @@ group("api") {
public_deps = [
":generated_api",
":mojom",
+ "//content/public/common",
]
}