| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 exceptionState.throwDOMException(InvalidStateError, "respondWith is alre
ady called."); | 84 exceptionState.throwDOMException(InvalidStateError, "respondWith is alre
ady called."); |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 | 87 |
| 88 m_state = Pending; | 88 m_state = Pending; |
| 89 ScriptPromise::cast(scriptState, value).then( | 89 ScriptPromise::cast(scriptState, value).then( |
| 90 ThenFunction::createFunction(scriptState, this, ThenFunction::Fulfilled)
, | 90 ThenFunction::createFunction(scriptState, this, ThenFunction::Fulfilled)
, |
| 91 ThenFunction::createFunction(scriptState, this, ThenFunction::Rejected))
; | 91 ThenFunction::createFunction(scriptState, this, ThenFunction::Rejected))
; |
| 92 } | 92 } |
| 93 | 93 |
| 94 void RespondWithObserver::sendResponse(PassRefPtrWillBeRawPtr<Response> response
) | 94 void RespondWithObserver::sendResponse(Response* response) |
| 95 { | 95 { |
| 96 if (!executionContext()) | 96 if (!executionContext()) |
| 97 return; | 97 return; |
| 98 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven
t(m_eventID, response); | 98 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven
t(m_eventID, response); |
| 99 m_state = Done; | 99 m_state = Done; |
| 100 } | 100 } |
| 101 | 101 |
| 102 void RespondWithObserver::responseWasRejected() | 102 void RespondWithObserver::responseWasRejected() |
| 103 { | 103 { |
| 104 // FIXME: Throw a NetworkError to service worker's execution context. | 104 // FIXME: Throw a NetworkError to service worker's execution context. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 118 } | 118 } |
| 119 | 119 |
| 120 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID) | 120 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID) |
| 121 : ContextLifecycleObserver(context) | 121 : ContextLifecycleObserver(context) |
| 122 , m_eventID(eventID) | 122 , m_eventID(eventID) |
| 123 , m_state(Initial) | 123 , m_state(Initial) |
| 124 { | 124 { |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace blink | 127 } // namespace blink |
| OLD | NEW |