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 FetchEvent_h | 5 #ifndef FetchEvent_h |
6 #define FetchEvent_h | 6 #define FetchEvent_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseProperty.h" | |
9 #include "modules/EventModules.h" | 10 #include "modules/EventModules.h" |
10 #include "modules/ModulesExport.h" | 11 #include "modules/ModulesExport.h" |
11 #include "modules/fetch/Request.h" | 12 #include "modules/fetch/Request.h" |
12 #include "modules/serviceworkers/ExtendableEvent.h" | 13 #include "modules/serviceworkers/ExtendableEvent.h" |
13 #include "modules/serviceworkers/FetchEventInit.h" | 14 #include "modules/serviceworkers/FetchEventInit.h" |
14 #include "modules/serviceworkers/RespondWithObserver.h" | 15 #include "modules/serviceworkers/RespondWithObserver.h" |
15 #include "modules/serviceworkers/WaitUntilObserver.h" | 16 #include "modules/serviceworkers/WaitUntilObserver.h" |
16 #include "platform/heap/Handle.h" | 17 #include "platform/heap/Handle.h" |
18 #include "public/platform/modules/serviceworker/WebServiceWorkerPreloadResponseC allbacks.h" | |
17 | 19 |
18 namespace blink { | 20 namespace blink { |
19 | 21 |
20 class ExceptionState; | 22 class ExceptionState; |
21 class Request; | 23 class Request; |
24 class Response; | |
22 class RespondWithObserver; | 25 class RespondWithObserver; |
23 | 26 |
24 // A fetch event is dispatched by the client to a service worker's script | 27 // A fetch event is dispatched by the client to a service worker's script |
25 // context. RespondWithObserver can be used to notify the client about the | 28 // context. RespondWithObserver can be used to notify the client about the |
26 // service worker's response. | 29 // service worker's response. |
27 class MODULES_EXPORT FetchEvent final : public ExtendableEvent { | 30 class MODULES_EXPORT FetchEvent final : public ExtendableEvent { |
28 DEFINE_WRAPPERTYPEINFO(); | 31 DEFINE_WRAPPERTYPEINFO(); |
29 | 32 |
30 public: | 33 public: |
34 typedef ScriptPromiseProperty<Member<FetchEvent>, | |
dcheng
2016/10/21 06:44:23
Nit: prefer `using A = B` over `typedef B A` in ne
horo
2016/10/21 10:56:40
Done.
| |
35 Member<Response>, | |
36 Member<DOMException>> | |
37 PreloadResponseProperty; | |
31 static FetchEvent* create(ScriptState*, | 38 static FetchEvent* create(ScriptState*, |
32 const AtomicString& type, | 39 const AtomicString& type, |
33 const FetchEventInit&); | 40 const FetchEventInit&); |
34 static FetchEvent* create(ScriptState*, | 41 static FetchEvent* create(ScriptState*, |
35 const AtomicString& type, | 42 const AtomicString& type, |
36 const FetchEventInit&, | 43 const FetchEventInit&, |
37 RespondWithObserver*, | 44 RespondWithObserver*, |
38 WaitUntilObserver*); | 45 WaitUntilObserver*, |
46 bool navigationPreloadSent); | |
39 | 47 |
40 Request* request() const; | 48 Request* request() const; |
41 String clientId() const; | 49 String clientId() const; |
42 bool isReload() const; | 50 bool isReload() const; |
43 | 51 |
44 void respondWith(ScriptState*, ScriptPromise, ExceptionState&); | 52 void respondWith(ScriptState*, ScriptPromise, ExceptionState&); |
53 ScriptPromise navigationPreload(ScriptState*, bool& isNull); | |
54 | |
55 std::unique_ptr<WebServiceWorkerPreloadResponseCallbacks> | |
56 createPreloadResponseCallback(ScriptState*); | |
45 | 57 |
46 const AtomicString& interfaceName() const override; | 58 const AtomicString& interfaceName() const override; |
47 | 59 |
48 DECLARE_VIRTUAL_TRACE(); | 60 DECLARE_VIRTUAL_TRACE(); |
49 | 61 |
50 protected: | 62 protected: |
51 FetchEvent(ScriptState*, | 63 FetchEvent(ScriptState*, |
52 const AtomicString& type, | 64 const AtomicString& type, |
53 const FetchEventInit&, | 65 const FetchEventInit&, |
54 RespondWithObserver*, | 66 RespondWithObserver*, |
55 WaitUntilObserver*); | 67 WaitUntilObserver*, |
68 bool navigationPreloadSent); | |
56 | 69 |
57 private: | 70 private: |
71 class PreloadResponseCallbackImpl; | |
72 | |
58 Member<RespondWithObserver> m_observer; | 73 Member<RespondWithObserver> m_observer; |
59 Member<Request> m_request; | 74 Member<Request> m_request; |
75 Member<PreloadResponseProperty> m_navigationPreloadProperty; | |
60 String m_clientId; | 76 String m_clientId; |
61 bool m_isReload; | 77 bool m_isReload; |
62 }; | 78 }; |
63 | 79 |
64 } // namespace blink | 80 } // namespace blink |
65 | 81 |
66 #endif // FetchEvent_h | 82 #endif // FetchEvent_h |
OLD | NEW |