Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/serviceworkers/RespondWithObserver.h" | 6 #include "modules/serviceworkers/RespondWithObserver.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptFunction.h" | 8 #include "bindings/core/v8/ScriptFunction.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptValue.h" | 10 #include "bindings/core/v8/ScriptValue.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 else | 56 else |
| 57 m_observer->responseWasFulfilled(value); | 57 m_observer->responseWasFulfilled(value); |
| 58 m_observer = nullptr; | 58 m_observer = nullptr; |
| 59 return value; | 59 return value; |
| 60 } | 60 } |
| 61 | 61 |
| 62 Member<RespondWithObserver> m_observer; | 62 Member<RespondWithObserver> m_observer; |
| 63 ResolveType m_resolveType; | 63 ResolveType m_resolveType; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 RespondWithObserver* RespondWithObserver::create(ExecutionContext* context, int eventID) | 66 RespondWithObserver* RespondWithObserver::create(ExecutionContext* context, int eventID, WebURLRequest::FetchRequestMode requestMode) |
| 67 { | 67 { |
| 68 return new RespondWithObserver(context, eventID); | 68 return new RespondWithObserver(context, eventID, requestMode); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void RespondWithObserver::contextDestroyed() | 71 void RespondWithObserver::contextDestroyed() |
| 72 { | 72 { |
| 73 ContextLifecycleObserver::contextDestroyed(); | 73 ContextLifecycleObserver::contextDestroyed(); |
| 74 m_state = Done; | 74 m_state = Done; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void RespondWithObserver::didDispatchEvent() | 77 void RespondWithObserver::didDispatchEvent() |
| 78 { | 78 { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 107 m_state = Done; | 107 m_state = Done; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void RespondWithObserver::responseWasFulfilled(const ScriptValue& value) | 110 void RespondWithObserver::responseWasFulfilled(const ScriptValue& value) |
| 111 { | 111 { |
| 112 ASSERT(executionContext()); | 112 ASSERT(executionContext()); |
| 113 if (!V8Response::hasInstance(value.v8Value(), toIsolate(executionContext())) ) { | 113 if (!V8Response::hasInstance(value.v8Value(), toIsolate(executionContext())) ) { |
| 114 responseWasRejected(); | 114 responseWasRejected(); |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 Response* response = V8Response::toImplWithTypeCheck(toIsolate(executionCont ext()), value.v8Value()); | |
| 118 // "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.
| |
| 119 const FetchResponseData::Type responseType = response->response()->type(); | |
| 120 if ((responseType == FetchResponseData::OpaqueType && m_requestMode != WebUR LRequest::FetchRequestModeNoCORS) || responseType == FetchResponseData::ErrorTyp e) { | |
| 121 responseWasRejected(); | |
| 122 return; | |
| 123 } | |
| 117 WebServiceWorkerResponse webResponse; | 124 WebServiceWorkerResponse webResponse; |
| 118 V8Response::toImplWithTypeCheck(toIsolate(executionContext()), value.v8Value ())->populateWebServiceWorkerResponse(webResponse); | 125 response->populateWebServiceWorkerResponse(webResponse); |
| 119 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven t(m_eventID, webResponse); | 126 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven t(m_eventID, webResponse); |
| 120 m_state = Done; | 127 m_state = Done; |
| 121 } | 128 } |
| 122 | 129 |
| 123 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID) | 130 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID, WebURLRequest::FetchRequestMode requestMode) |
| 124 : ContextLifecycleObserver(context) | 131 : ContextLifecycleObserver(context) |
| 125 , m_eventID(eventID) | 132 , m_eventID(eventID) |
| 133 , m_requestMode(requestMode) | |
| 126 , m_state(Initial) | 134 , m_state(Initial) |
| 127 { | 135 { |
| 128 } | 136 } |
| 129 | 137 |
| 130 } // namespace blink | 138 } // namespace blink |
| OLD | NEW |