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 "V8Response.h" | 8 #include "V8Response.h" |
9 #include "bindings/v8/ScriptFunction.h" | 9 #include "bindings/v8/ScriptFunction.h" |
10 #include "bindings/v8/ScriptPromise.h" | 10 #include "bindings/v8/ScriptPromise.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 if (m_state == Initial) | 74 if (m_state == Initial) |
75 sendResponse(nullptr); | 75 sendResponse(nullptr); |
76 } | 76 } |
77 | 77 |
78 void RespondWithObserver::respondWith(const ScriptValue& value) | 78 void RespondWithObserver::respondWith(const ScriptValue& value) |
79 { | 79 { |
80 if (m_state != Initial) | 80 if (m_state != Initial) |
81 return; | 81 return; |
82 | 82 |
83 m_state = Pending; | 83 m_state = Pending; |
84 ScriptPromise(value).then( | 84 ScriptPromise::cast(value).then( |
85 ThenFunction::create(this, ThenFunction::Fulfilled), | 85 ThenFunction::create(this, ThenFunction::Fulfilled), |
86 ThenFunction::create(this, ThenFunction::Rejected)); | 86 ThenFunction::create(this, ThenFunction::Rejected)); |
87 } | 87 } |
88 | 88 |
89 void RespondWithObserver::sendResponse(PassRefPtr<Response> response) | 89 void RespondWithObserver::sendResponse(PassRefPtr<Response> response) |
90 { | 90 { |
91 if (!executionContext()) | 91 if (!executionContext()) |
92 return; | 92 return; |
93 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven
t(m_eventID, response); | 93 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven
t(m_eventID, response); |
94 m_state = Done; | 94 m_state = Done; |
(...skipping 18 matching lines...) Expand all Loading... |
113 } | 113 } |
114 | 114 |
115 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID) | 115 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID) |
116 : ContextLifecycleObserver(context) | 116 : ContextLifecycleObserver(context) |
117 , m_eventID(eventID) | 117 , m_eventID(eventID) |
118 , m_state(Initial) | 118 , m_state(Initial) |
119 { | 119 { |
120 } | 120 } |
121 | 121 |
122 } // namespace WebCore | 122 } // namespace WebCore |
OLD | NEW |