Chromium Code Reviews| 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) |
| { |
| } |