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

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

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

Powered by Google App Engine
This is Rietveld 408576698