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