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 { | 80 { |
81 if (m_state != Initial) | 81 if (m_state != Initial) |
82 return; | 82 return; |
83 | 83 |
84 m_state = Pending; | 84 m_state = Pending; |
85 ScriptPromise::cast(scriptState, value).then( | 85 ScriptPromise::cast(scriptState, value).then( |
86 ThenFunction::create(this, ThenFunction::Fulfilled), | 86 ThenFunction::create(this, ThenFunction::Fulfilled), |
87 ThenFunction::create(this, ThenFunction::Rejected)); | 87 ThenFunction::create(this, ThenFunction::Rejected)); |
88 } | 88 } |
89 | 89 |
90 void RespondWithObserver::sendResponse(PassRefPtrWillBeRawPtr<Response> response
) | 90 void RespondWithObserver::sendResponse(Response* response) |
91 { | 91 { |
92 if (!executionContext()) | 92 if (!executionContext()) |
93 return; | 93 return; |
94 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven
t(m_eventID, response); | 94 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven
t(m_eventID, response); |
95 m_state = Done; | 95 m_state = Done; |
96 } | 96 } |
97 | 97 |
98 void RespondWithObserver::responseWasRejected() | 98 void RespondWithObserver::responseWasRejected() |
99 { | 99 { |
100 // FIXME: Throw a NetworkError to service worker's execution context. | 100 // FIXME: Throw a NetworkError to service worker's execution context. |
(...skipping 13 matching lines...) Expand all Loading... |
114 } | 114 } |
115 | 115 |
116 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID) | 116 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID) |
117 : ContextLifecycleObserver(context) | 117 : ContextLifecycleObserver(context) |
118 , m_eventID(eventID) | 118 , m_eventID(eventID) |
119 , m_state(Initial) | 119 , m_state(Initial) |
120 { | 120 { |
121 } | 121 } |
122 | 122 |
123 } // namespace blink | 123 } // namespace blink |
OLD | NEW |