| 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 #ifndef RespondWithObserver_h | 5 #ifndef RespondWithObserver_h |
| 6 #define RespondWithObserver_h | 6 #define RespondWithObserver_h |
| 7 | 7 |
| 8 #include "core/dom/ContextLifecycleObserver.h" | 8 #include "core/dom/ContextLifecycleObserver.h" |
| 9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
| 10 #include "public/platform/WebURLRequest.h" |
| 10 #include "wtf/Forward.h" | 11 #include "wtf/Forward.h" |
| 11 #include "wtf/RefCounted.h" | 12 #include "wtf/RefCounted.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 class ExceptionState; | 16 class ExceptionState; |
| 16 class ExecutionContext; | 17 class ExecutionContext; |
| 17 class Response; | 18 class Response; |
| 18 class ScriptState; | 19 class ScriptState; |
| 19 class ScriptValue; | 20 class ScriptValue; |
| 20 | 21 |
| 21 // This class observes the service worker's handling of a FetchEvent and | 22 // This class observes the service worker's handling of a FetchEvent and |
| 22 // notifies the client. | 23 // notifies the client. |
| 23 class RespondWithObserver FINAL : public GarbageCollectedFinalized<RespondWithOb
server>, public ContextLifecycleObserver { | 24 class RespondWithObserver FINAL : public GarbageCollectedFinalized<RespondWithOb
server>, public ContextLifecycleObserver { |
| 24 public: | 25 public: |
| 25 static RespondWithObserver* create(ExecutionContext*, int eventID); | 26 static RespondWithObserver* create(ExecutionContext*, int eventID, WebURLReq
uest::ServiceWorkerRequestMode); |
| 26 | 27 |
| 27 virtual void contextDestroyed() OVERRIDE; | 28 virtual void contextDestroyed() OVERRIDE; |
| 28 | 29 |
| 29 void didDispatchEvent(); | 30 void didDispatchEvent(); |
| 30 | 31 |
| 31 // Observes the promise and delays calling didHandleFetchEvent() until the | 32 // Observes the promise and delays calling didHandleFetchEvent() until the |
| 32 // given promise is resolved or rejected. | 33 // given promise is resolved or rejected. |
| 33 void respondWith(ScriptState*, const ScriptValue&, ExceptionState&); | 34 void respondWith(ScriptState*, const ScriptValue&, ExceptionState&); |
| 34 | 35 |
| 35 void responseWasRejected(); | 36 void responseWasRejected(); |
| 36 void responseWasFulfilled(const ScriptValue&); | 37 void responseWasFulfilled(const ScriptValue&); |
| 37 | 38 |
| 38 void trace(Visitor*) { } | 39 void trace(Visitor*) { } |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 class ThenFunction; | 42 class ThenFunction; |
| 42 | 43 |
| 43 RespondWithObserver(ExecutionContext*, int eventID); | 44 RespondWithObserver(ExecutionContext*, int eventID, WebURLRequest::ServiceWo
rkerRequestMode); |
| 44 | 45 |
| 45 int m_eventID; | 46 int m_eventID; |
| 47 WebURLRequest::ServiceWorkerRequestMode m_requestMode; |
| 46 | 48 |
| 47 enum State { Initial, Pending, Done }; | 49 enum State { Initial, Pending, Done }; |
| 48 State m_state; | 50 State m_state; |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 } // namespace blink | 53 } // namespace blink |
| 52 | 54 |
| 53 #endif // RespondWithObserver_h | 55 #endif // RespondWithObserver_h |
| OLD | NEW |