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