Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Unified Diff: content/child/service_worker/service_worker_network_provider.cc

Issue 1191293002: Don't create ServiceWorkerProviderHost for sandboxed frames without allow-same-origin flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated kinuko's comment Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/child/service_worker/service_worker_network_provider.cc
diff --git a/content/child/service_worker/service_worker_network_provider.cc b/content/child/service_worker/service_worker_network_provider.cc
index 7a077c9b1d2c6a8fb12ac859fec8ada8d96a7376..bd521b844840a88aafba94bd15e409986a85adae 100644
--- a/content/child/service_worker/service_worker_network_provider.cc
+++ b/content/child/service_worker/service_worker_network_provider.cc
@@ -21,6 +21,15 @@ int GetNextProviderId() {
return sequence.GetNext(); // We start at zero.
}
+// When the provider is for a sandboxed iframe we use
+// kInvalidServiceWorkerProviderId as the provider type and we don't create
+// ServiceWorkerProviderContext and ServiceWorkerProviderHost.
+int GenerateProviderIdForType(const ServiceWorkerProviderType provider_type) {
+ if (provider_type == SERVICE_WORKER_PROVIDER_FOR_SANDBOXED_FRAME)
+ return kInvalidServiceWorkerProviderId;
+ return GetNextProviderId();
+}
+
} // namespace
void ServiceWorkerNetworkProvider::AttachToDocumentState(
@@ -38,8 +47,10 @@ ServiceWorkerNetworkProvider* ServiceWorkerNetworkProvider::FromDocumentState(
ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider(
int route_id,
ServiceWorkerProviderType provider_type)
- : provider_id_(GetNextProviderId()),
- context_(new ServiceWorkerProviderContext(provider_id_)) {
+ : provider_id_(GenerateProviderIdForType(provider_type)) {
+ if (provider_id_ == kInvalidServiceWorkerProviderId)
+ return;
+ context_ = new ServiceWorkerProviderContext(provider_id_);
if (!ChildThreadImpl::current())
return; // May be null in some tests.
ChildThreadImpl::current()->Send(new ServiceWorkerHostMsg_ProviderCreated(
@@ -47,6 +58,8 @@ ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider(
}
ServiceWorkerNetworkProvider::~ServiceWorkerNetworkProvider() {
+ if (provider_id_ == kInvalidServiceWorkerProviderId)
+ return;
if (!ChildThreadImpl::current())
return; // May be null in some tests.
ChildThreadImpl::current()->Send(
@@ -55,6 +68,7 @@ ServiceWorkerNetworkProvider::~ServiceWorkerNetworkProvider() {
void ServiceWorkerNetworkProvider::SetServiceWorkerVersionId(
int64 version_id) {
+ DCHECK_NE(kInvalidServiceWorkerProviderId, provider_id_);
if (!ChildThreadImpl::current())
return; // May be null in some tests.
ChildThreadImpl::current()->Send(

Powered by Google App Engine
This is Rietveld 408576698