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

Unified Diff: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp

Issue 2116503004: Make Foreign Fetch an origin trial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
diff --git a/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp b/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
index 04373b108877195ad4484667ecf5e2979e8a6d90..4c1622ceac2716428f4506a2a9a4d1569b5f3f12 100644
--- a/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
+++ b/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
@@ -37,6 +37,7 @@
#include "core/dom/ExecutionContext.h"
#include "core/dom/MessagePort.h"
#include "core/inspector/ConsoleMessage.h"
+#include "core/origin_trials/OriginTrials.h"
#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerThread.h"
#include "modules/background_sync/SyncEvent.h"
@@ -154,6 +155,16 @@ void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int responseID, int event
void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int responseID, int eventFinishID, const WebServiceWorkerRequest& webRequest)
{
+ if (!OriginTrials::foreignFetchEnabled(workerGlobalScope())) {
+ // If origin trial tokens have expired, or are otherwise no longer valid
+ // no events should be dispatched.
+ // TODO(mek): Ideally the browser wouldn't even start the service worker
+ // if its tokens have expired.
+ ServiceWorkerGlobalScopeClient::from(workerGlobalScope())->respondToFetchEvent(responseID);
+ ServiceWorkerGlobalScopeClient::from(workerGlobalScope())->didHandleFetchEvent(eventFinishID, WebServiceWorkerEventResultCompleted);
+ return;
+ }
+
ScriptState::Scope scope(workerGlobalScope()->scriptController()->getScriptState());
RefPtr<SecurityOrigin> origin = SecurityOrigin::create(webRequest.referrerUrl());
WaitUntilObserver* waitUntilObserver = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Fetch, eventFinishID);
@@ -177,7 +188,7 @@ void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID)
{
WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Install, eventID);
Event* event;
- if (RuntimeEnabledFeatures::foreignFetchEnabled())
+ if (OriginTrials::foreignFetchEnabled(workerGlobalScope()))
event = InstallEvent::create(EventTypeNames::install, ExtendableEventInit(), observer);
else
event = ExtendableEvent::create(EventTypeNames::install, ExtendableEventInit(), observer);
« no previous file with comments | « third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698