Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/FetchEvent.h

Issue 2933463002: [Merge to M59] Keep the wrapper of FetchEvent alive while waiting for the preload response. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ActiveScriptWrappable.h"
8 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseProperty.h" 10 #include "bindings/core/v8/ScriptPromiseProperty.h"
11 #include "core/dom/ContextLifecycleObserver.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"
17 19
18 namespace blink { 20 namespace blink {
19 21
20 class ExceptionState; 22 class ExceptionState;
21 class FetchRespondWithObserver; 23 class FetchRespondWithObserver;
22 class Request; 24 class Request;
23 class Response; 25 class Response;
24 class ScriptState; 26 class ScriptState;
25 class WebDataConsumerHandle; 27 class WebDataConsumerHandle;
26 struct WebServiceWorkerError; 28 struct WebServiceWorkerError;
27 class WebURLResponse; 29 class WebURLResponse;
28 30
29 // A fetch event is dispatched by the client to a service worker's script 31 // 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 32 // context. FetchRespondWithObserver can be used to notify the client about the
31 // service worker's response. 33 // service worker's response.
32 class MODULES_EXPORT FetchEvent final : public ExtendableEvent { 34 class MODULES_EXPORT FetchEvent final
35 : public ExtendableEvent,
36 public ActiveScriptWrappable<FetchEvent>,
37 public ContextClient {
33 DEFINE_WRAPPERTYPEINFO(); 38 DEFINE_WRAPPERTYPEINFO();
39 USING_GARBAGE_COLLECTED_MIXIN(FetchEvent);
34 40
35 public: 41 public:
36 using PreloadResponseProperty = ScriptPromiseProperty<Member<FetchEvent>, 42 using PreloadResponseProperty = ScriptPromiseProperty<Member<FetchEvent>,
37 Member<Response>, 43 Member<Response>,
38 Member<DOMException>>; 44 Member<DOMException>>;
39 static FetchEvent* Create(ScriptState*, 45 static FetchEvent* Create(ScriptState*,
40 const AtomicString& type, 46 const AtomicString& type,
41 const FetchEventInit&); 47 const FetchEventInit&);
42 static FetchEvent* Create(ScriptState*, 48 static FetchEvent* Create(ScriptState*,
43 const AtomicString& type, 49 const AtomicString& type,
44 const FetchEventInit&, 50 const FetchEventInit&,
45 FetchRespondWithObserver*, 51 FetchRespondWithObserver*,
46 WaitUntilObserver*, 52 WaitUntilObserver*,
47 bool navigation_preload_sent); 53 bool navigation_preload_sent);
48 54
55 ~FetchEvent() override;
56
49 Request* request() const; 57 Request* request() const;
50 String clientId() const; 58 String clientId() const;
51 bool isReload() const; 59 bool isReload() const;
52 60
53 void respondWith(ScriptState*, ScriptPromise, ExceptionState&); 61 void respondWith(ScriptState*, ScriptPromise, ExceptionState&);
54 ScriptPromise preloadResponse(ScriptState*); 62 ScriptPromise preloadResponse(ScriptState*);
55 63
56 void OnNavigationPreloadResponse(ScriptState*, 64 void OnNavigationPreloadResponse(ScriptState*,
57 std::unique_ptr<WebURLResponse>, 65 std::unique_ptr<WebURLResponse>,
58 std::unique_ptr<WebDataConsumerHandle>); 66 std::unique_ptr<WebDataConsumerHandle>);
59 void OnNavigationPreloadError(ScriptState*, 67 void OnNavigationPreloadError(ScriptState*,
60 std::unique_ptr<WebServiceWorkerError>); 68 std::unique_ptr<WebServiceWorkerError>);
61 69
62 const AtomicString& InterfaceName() const override; 70 const AtomicString& InterfaceName() const override;
63 71
72 // ScriptWrappable
73 bool HasPendingActivity() const override;
74
64 DECLARE_VIRTUAL_TRACE(); 75 DECLARE_VIRTUAL_TRACE();
65 76
66 protected: 77 protected:
67 FetchEvent(ScriptState*, 78 FetchEvent(ScriptState*,
68 const AtomicString& type, 79 const AtomicString& type,
69 const FetchEventInit&, 80 const FetchEventInit&,
70 FetchRespondWithObserver*, 81 FetchRespondWithObserver*,
71 WaitUntilObserver*, 82 WaitUntilObserver*,
72 bool navigation_preload_sent); 83 bool navigation_preload_sent);
73 84
74 private: 85 private:
75 Member<FetchRespondWithObserver> observer_; 86 Member<FetchRespondWithObserver> observer_;
76 Member<Request> request_; 87 Member<Request> request_;
77 Member<PreloadResponseProperty> preload_response_property_; 88 Member<PreloadResponseProperty> preload_response_property_;
78 String client_id_; 89 String client_id_;
79 bool is_reload_; 90 bool is_reload_;
80 }; 91 };
81 92
82 } // namespace blink 93 } // namespace blink
83 94
84 #endif // FetchEvent_h 95 #endif // FetchEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698