| 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 <memory> |
| 9 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseProperty.h" | 11 #include "bindings/core/v8/ScriptPromiseProperty.h" |
| 10 #include "modules/EventModules.h" | 12 #include "modules/EventModules.h" |
| 11 #include "modules/ModulesExport.h" | 13 #include "modules/ModulesExport.h" |
| 12 #include "modules/fetch/Request.h" | 14 #include "modules/fetch/Request.h" |
| 13 #include "modules/serviceworkers/ExtendableEvent.h" | 15 #include "modules/serviceworkers/ExtendableEvent.h" |
| 14 #include "modules/serviceworkers/FetchEventInit.h" | 16 #include "modules/serviceworkers/FetchEventInit.h" |
| 15 #include "modules/serviceworkers/WaitUntilObserver.h" | 17 #include "modules/serviceworkers/WaitUntilObserver.h" |
| 16 #include "platform/heap/Handle.h" | 18 #include "platform/heap/Handle.h" |
| 19 #include "platform/loader/fetch/ResourceResponse.h" |
| 17 | 20 |
| 18 namespace blink { | 21 namespace blink { |
| 19 | 22 |
| 20 class ExceptionState; | 23 class ExceptionState; |
| 21 class FetchRespondWithObserver; | 24 class FetchRespondWithObserver; |
| 22 class Request; | 25 class Request; |
| 23 class Response; | 26 class Response; |
| 24 class ScriptState; | 27 class ScriptState; |
| 25 class WebDataConsumerHandle; | 28 class WebDataConsumerHandle; |
| 26 struct WebServiceWorkerError; | 29 struct WebServiceWorkerError; |
| 27 class WebURLResponse; | 30 class WebURLResponse; |
| 31 class WorkerGlobalScope; |
| 28 | 32 |
| 29 // A fetch event is dispatched by the client to a service worker's script | 33 // A fetch event is dispatched by the client to a service worker's script |
| 30 // context. FetchRespondWithObserver can be used to notify the client about the | 34 // context. FetchRespondWithObserver can be used to notify the client about the |
| 31 // service worker's response. | 35 // service worker's response. |
| 32 class MODULES_EXPORT FetchEvent final : public ExtendableEvent { | 36 class MODULES_EXPORT FetchEvent final : public ExtendableEvent { |
| 33 DEFINE_WRAPPERTYPEINFO(); | 37 DEFINE_WRAPPERTYPEINFO(); |
| 34 | 38 |
| 35 public: | 39 public: |
| 36 using PreloadResponseProperty = ScriptPromiseProperty<Member<FetchEvent>, | 40 using PreloadResponseProperty = ScriptPromiseProperty<Member<FetchEvent>, |
| 37 Member<Response>, | 41 Member<Response>, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 51 bool isReload() const; | 55 bool isReload() const; |
| 52 | 56 |
| 53 void respondWith(ScriptState*, ScriptPromise, ExceptionState&); | 57 void respondWith(ScriptState*, ScriptPromise, ExceptionState&); |
| 54 ScriptPromise preloadResponse(ScriptState*); | 58 ScriptPromise preloadResponse(ScriptState*); |
| 55 | 59 |
| 56 void OnNavigationPreloadResponse(ScriptState*, | 60 void OnNavigationPreloadResponse(ScriptState*, |
| 57 std::unique_ptr<WebURLResponse>, | 61 std::unique_ptr<WebURLResponse>, |
| 58 std::unique_ptr<WebDataConsumerHandle>); | 62 std::unique_ptr<WebDataConsumerHandle>); |
| 59 void OnNavigationPreloadError(ScriptState*, | 63 void OnNavigationPreloadError(ScriptState*, |
| 60 std::unique_ptr<WebServiceWorkerError>); | 64 std::unique_ptr<WebServiceWorkerError>); |
| 65 void OnNavigationPreloadComplete(WorkerGlobalScope*, |
| 66 double completion_time, |
| 67 int64_t encoded_data_length, |
| 68 int64_t encoded_body_length, |
| 69 int64_t decoded_body_length); |
| 61 | 70 |
| 62 const AtomicString& InterfaceName() const override; | 71 const AtomicString& InterfaceName() const override; |
| 63 | 72 |
| 64 DECLARE_VIRTUAL_TRACE(); | 73 DECLARE_VIRTUAL_TRACE(); |
| 65 | 74 |
| 66 protected: | 75 protected: |
| 67 FetchEvent(ScriptState*, | 76 FetchEvent(ScriptState*, |
| 68 const AtomicString& type, | 77 const AtomicString& type, |
| 69 const FetchEventInit&, | 78 const FetchEventInit&, |
| 70 FetchRespondWithObserver*, | 79 FetchRespondWithObserver*, |
| 71 WaitUntilObserver*, | 80 WaitUntilObserver*, |
| 72 bool navigation_preload_sent); | 81 bool navigation_preload_sent); |
| 73 | 82 |
| 74 private: | 83 private: |
| 75 Member<FetchRespondWithObserver> observer_; | 84 Member<FetchRespondWithObserver> observer_; |
| 76 Member<Request> request_; | 85 Member<Request> request_; |
| 77 Member<PreloadResponseProperty> preload_response_property_; | 86 Member<PreloadResponseProperty> preload_response_property_; |
| 87 std::unique_ptr<WebURLResponse> preload_response_; |
| 78 String client_id_; | 88 String client_id_; |
| 79 bool is_reload_; | 89 bool is_reload_; |
| 80 }; | 90 }; |
| 81 | 91 |
| 82 } // namespace blink | 92 } // namespace blink |
| 83 | 93 |
| 84 #endif // FetchEvent_h | 94 #endif // FetchEvent_h |
| OLD | NEW |