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" |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
19 | 20 |
20 class ExceptionState; | 21 class ExceptionState; |
21 class Request; | 22 class Request; |
| 23 class Response; |
22 class RespondWithObserver; | 24 class RespondWithObserver; |
| 25 class ScriptState; |
| 26 class WebDataConsumerHandle; |
| 27 struct WebServiceWorkerError; |
| 28 class WebServiceWorkerResponse; |
23 | 29 |
24 // A fetch event is dispatched by the client to a service worker's script | 30 // 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 | 31 // context. RespondWithObserver can be used to notify the client about the |
26 // service worker's response. | 32 // service worker's response. |
27 class MODULES_EXPORT FetchEvent final : public ExtendableEvent { | 33 class MODULES_EXPORT FetchEvent final : public ExtendableEvent { |
28 DEFINE_WRAPPERTYPEINFO(); | 34 DEFINE_WRAPPERTYPEINFO(); |
29 | 35 |
30 public: | 36 public: |
| 37 using PreloadResponseProperty = ScriptPromiseProperty<Member<FetchEvent>, |
| 38 Member<Response>, |
| 39 Member<DOMException>>; |
31 static FetchEvent* create(ScriptState*, | 40 static FetchEvent* create(ScriptState*, |
32 const AtomicString& type, | 41 const AtomicString& type, |
33 const FetchEventInit&); | 42 const FetchEventInit&); |
34 static FetchEvent* create(ScriptState*, | 43 static FetchEvent* create(ScriptState*, |
35 const AtomicString& type, | 44 const AtomicString& type, |
36 const FetchEventInit&, | 45 const FetchEventInit&, |
37 RespondWithObserver*, | 46 RespondWithObserver*, |
38 WaitUntilObserver*); | 47 WaitUntilObserver*, |
| 48 bool navigationPreloadSent); |
39 | 49 |
40 Request* request() const; | 50 Request* request() const; |
41 String clientId() const; | 51 String clientId() const; |
42 bool isReload() const; | 52 bool isReload() const; |
43 | 53 |
44 void respondWith(ScriptState*, ScriptPromise, ExceptionState&); | 54 void respondWith(ScriptState*, ScriptPromise, ExceptionState&); |
| 55 ScriptPromise navigationPreload(ScriptState*); |
| 56 |
| 57 void onNavigationPreloadResponse(std::unique_ptr<WebServiceWorkerResponse>, |
| 58 std::unique_ptr<WebDataConsumerHandle>); |
| 59 void onNavigationPreloadError(std::unique_ptr<WebServiceWorkerError>); |
45 | 60 |
46 const AtomicString& interfaceName() const override; | 61 const AtomicString& interfaceName() const override; |
47 | 62 |
48 DECLARE_VIRTUAL_TRACE(); | 63 DECLARE_VIRTUAL_TRACE(); |
49 | 64 |
50 protected: | 65 protected: |
51 FetchEvent(ScriptState*, | 66 FetchEvent(ScriptState*, |
52 const AtomicString& type, | 67 const AtomicString& type, |
53 const FetchEventInit&, | 68 const FetchEventInit&, |
54 RespondWithObserver*, | 69 RespondWithObserver*, |
55 WaitUntilObserver*); | 70 WaitUntilObserver*, |
| 71 bool navigationPreloadSent); |
56 | 72 |
57 private: | 73 private: |
| 74 RefPtr<ScriptState> m_scriptState; |
58 Member<RespondWithObserver> m_observer; | 75 Member<RespondWithObserver> m_observer; |
59 Member<Request> m_request; | 76 Member<Request> m_request; |
| 77 Member<PreloadResponseProperty> m_navigationPreloadProperty; |
60 String m_clientId; | 78 String m_clientId; |
61 bool m_isReload; | 79 bool m_isReload; |
62 }; | 80 }; |
63 | 81 |
64 } // namespace blink | 82 } // namespace blink |
65 | 83 |
66 #endif // FetchEvent_h | 84 #endif // FetchEvent_h |
OLD | NEW |