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

Unified Diff: Source/modules/serviceworkers/RespondWithObserver.cpp

Issue 587213003: [ServiceWorker] Plumbing the request mode from the renderer to the ServiceWorker. [1/2 blink] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add opaque and not NoCors check in RespondWithObserver::responseWasFulfilled. Created 6 years, 3 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 | « Source/modules/serviceworkers/RespondWithObserver.h ('k') | Source/modules/serviceworkers/Response.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/RespondWithObserver.cpp
diff --git a/Source/modules/serviceworkers/RespondWithObserver.cpp b/Source/modules/serviceworkers/RespondWithObserver.cpp
index cb6b6b85d8497476fe2cd2255aec365a503782b8..1a3dc8b14146d20163ee6f6f377fa937d6185347 100644
--- a/Source/modules/serviceworkers/RespondWithObserver.cpp
+++ b/Source/modules/serviceworkers/RespondWithObserver.cpp
@@ -63,9 +63,9 @@ private:
ResolveType m_resolveType;
};
-RespondWithObserver* RespondWithObserver::create(ExecutionContext* context, int eventID)
+RespondWithObserver* RespondWithObserver::create(ExecutionContext* context, int eventID, WebURLRequest::FetchRequestMode requestMode)
{
- return new RespondWithObserver(context, eventID);
+ return new RespondWithObserver(context, eventID, requestMode);
}
void RespondWithObserver::contextDestroyed()
@@ -114,15 +114,23 @@ void RespondWithObserver::responseWasFulfilled(const ScriptValue& value)
responseWasRejected();
return;
}
+ Response* response = V8Response::toImplWithTypeCheck(toIsolate(executionContext()), value.v8Value());
+ // "If either |response|'s type is |opaque| and |request|'s mode is not |no CORS| or |response|'s type is |error|, return a network error.
yhirano 2014/09/25 11:45:03 Please wrap the comment in 80 columns.
horo 2014/09/25 11:51:40 Done.
+ const FetchResponseData::Type responseType = response->response()->type();
+ if ((responseType == FetchResponseData::OpaqueType && m_requestMode != WebURLRequest::FetchRequestModeNoCORS) || responseType == FetchResponseData::ErrorType) {
+ responseWasRejected();
+ return;
+ }
WebServiceWorkerResponse webResponse;
- V8Response::toImplWithTypeCheck(toIsolate(executionContext()), value.v8Value())->populateWebServiceWorkerResponse(webResponse);
+ response->populateWebServiceWorkerResponse(webResponse);
ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEvent(m_eventID, webResponse);
m_state = Done;
}
-RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID)
+RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID, WebURLRequest::FetchRequestMode requestMode)
: ContextLifecycleObserver(context)
, m_eventID(eventID)
+ , m_requestMode(requestMode)
, m_state(Initial)
{
}
« no previous file with comments | « Source/modules/serviceworkers/RespondWithObserver.h ('k') | Source/modules/serviceworkers/Response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698