| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 if (m_state != Initial) | 80 if (m_state != Initial) |
| 81 return; | 81 return; |
| 82 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven
t(m_eventID); | 82 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven
t(m_eventID); |
| 83 m_state = Done; | 83 m_state = Done; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void RespondWithObserver::respondWith(ScriptState* scriptState, const ScriptValu
e& value, ExceptionState& exceptionState) | 86 void RespondWithObserver::respondWith(ScriptState* scriptState, const ScriptValu
e& value, ExceptionState& exceptionState) |
| 87 { | 87 { |
| 88 ASSERT(RuntimeEnabledFeatures::serviceWorkerOnFetchEnabled()); | 88 ASSERT(RuntimeEnabledFeatures::serviceWorkerOnFetchEnabled()); |
| 89 if (m_state != Initial) { | 89 if (m_state != Initial) { |
| 90 exceptionState.throwDOMException(InvalidStateError, "respondWith is alre
ady called."); | 90 exceptionState.throwDOMException(InvalidStateError, "The fetch event has
already been responded to."); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 m_state = Pending; | 94 m_state = Pending; |
| 95 ScriptPromise::cast(scriptState, value).then( | 95 ScriptPromise::cast(scriptState, value).then( |
| 96 ThenFunction::createFunction(scriptState, this, ThenFunction::Fulfilled)
, | 96 ThenFunction::createFunction(scriptState, this, ThenFunction::Fulfilled)
, |
| 97 ThenFunction::createFunction(scriptState, this, ThenFunction::Rejected))
; | 97 ThenFunction::createFunction(scriptState, this, ThenFunction::Rejected))
; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void RespondWithObserver::responseWasRejected() | 100 void RespondWithObserver::responseWasRejected() |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID,
WebURLRequest::FetchRequestMode requestMode, WebURLRequest::FrameType frameType
) | 136 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID,
WebURLRequest::FetchRequestMode requestMode, WebURLRequest::FrameType frameType
) |
| 137 : ContextLifecycleObserver(context) | 137 : ContextLifecycleObserver(context) |
| 138 , m_eventID(eventID) | 138 , m_eventID(eventID) |
| 139 , m_requestMode(requestMode) | 139 , m_requestMode(requestMode) |
| 140 , m_frameType(frameType) | 140 , m_frameType(frameType) |
| 141 , m_state(Initial) | 141 , m_state(Initial) |
| 142 { | 142 { |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace blink | 145 } // namespace blink |
| OLD | NEW |