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

Unified Diff: third_party/WebKit/Source/modules/serviceworkers/ForeignFetchRespondWithObserver.cpp

Issue 1845463002: Start implementing ForeignFetchEvent for foreign fetch events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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: third_party/WebKit/Source/modules/serviceworkers/ForeignFetchRespondWithObserver.cpp
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ForeignFetchRespondWithObserver.cpp b/third_party/WebKit/Source/modules/serviceworkers/ForeignFetchRespondWithObserver.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a707f7165010cdc194065fac50be487dee8002c9
--- /dev/null
+++ b/third_party/WebKit/Source/modules/serviceworkers/ForeignFetchRespondWithObserver.cpp
@@ -0,0 +1,36 @@
+// Copyright 2016 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 "modules/serviceworkers/ForeignFetchRespondWithObserver.h"
+
+#include "modules/serviceworkers/ForeignFetchResponse.h"
+
+namespace blink {
+
+ForeignFetchRespondWithObserver* ForeignFetchRespondWithObserver::create(ExecutionContext* context, int eventID, const KURL& requestURL, WebURLRequest::FetchRequestMode requestMode, WebURLRequest::FrameType frameType, WebURLRequest::RequestContext requestContext)
+{
+ return new ForeignFetchRespondWithObserver(context, eventID, requestURL, requestMode, frameType, requestContext);
+}
+
+void ForeignFetchRespondWithObserver::responseWasFulfilled(const ScriptValue& value)
+{
+ ASSERT(getExecutionContext());
+ TrackExceptionState exceptionState;
+ ForeignFetchResponse foreignFetchResponse = ScriptValue::to<ForeignFetchResponse>(toIsolate(getExecutionContext()), value, exceptionState);
+ if (exceptionState.hadException()) {
+ responseWasRejected(WebServiceWorkerResponseErrorNoForeignFetchResponse);
+ return;
+ }
+
+ // TODO(mek): Handle foreign fetch specific response parameters.
+ Response* response = foreignFetchResponse.response();
+ RespondWithObserver::responseWasFulfilled(ScriptValue::from(value.getScriptState(), response));
+}
+
+ForeignFetchRespondWithObserver::ForeignFetchRespondWithObserver(ExecutionContext* context, int eventID, const KURL& requestURL, WebURLRequest::FetchRequestMode requestMode, WebURLRequest::FrameType frameType, WebURLRequest::RequestContext requestContext)
+ : RespondWithObserver(context, eventID, requestURL, requestMode, frameType, requestContext)
+{
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698