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

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

Issue 2416863002: Use fetch_event_id (fetchEventID in blink) for FetchEvent (Closed)
Patch Set: Created 4 years, 2 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 RespondWithObserver_h 5 #ifndef RespondWithObserver_h
6 #define RespondWithObserver_h 6 #define RespondWithObserver_h
7 7
8 #include "core/dom/ContextLifecycleObserver.h" 8 #include "core/dom/ContextLifecycleObserver.h"
9 #include "core/events/EventTarget.h" 9 #include "core/events/EventTarget.h"
10 #include "modules/ModulesExport.h" 10 #include "modules/ModulesExport.h"
(...skipping 14 matching lines...) Expand all
25 // notifies the client. 25 // notifies the client.
26 class MODULES_EXPORT RespondWithObserver 26 class MODULES_EXPORT RespondWithObserver
27 : public GarbageCollectedFinalized<RespondWithObserver>, 27 : public GarbageCollectedFinalized<RespondWithObserver>,
28 public ContextLifecycleObserver { 28 public ContextLifecycleObserver {
29 USING_GARBAGE_COLLECTED_MIXIN(RespondWithObserver); 29 USING_GARBAGE_COLLECTED_MIXIN(RespondWithObserver);
30 30
31 public: 31 public:
32 virtual ~RespondWithObserver(); 32 virtual ~RespondWithObserver();
33 33
34 static RespondWithObserver* create(ExecutionContext*, 34 static RespondWithObserver* create(ExecutionContext*,
35 int eventID, 35 int fetchEventID,
36 const KURL& requestURL, 36 const KURL& requestURL,
37 WebURLRequest::FetchRequestMode, 37 WebURLRequest::FetchRequestMode,
38 WebURLRequest::FrameType, 38 WebURLRequest::FrameType,
39 WebURLRequest::RequestContext, 39 WebURLRequest::RequestContext,
40 WaitUntilObserver*); 40 WaitUntilObserver*);
41 41
42 void contextDestroyed() override; 42 void contextDestroyed() override;
43 43
44 void willDispatchEvent(); 44 void willDispatchEvent();
45 void didDispatchEvent(DispatchEventResult dispatchResult); 45 void didDispatchEvent(DispatchEventResult dispatchResult);
46 46
47 // Observes the promise and delays calling didHandleFetchEvent() until the 47 // Observes the promise and delays calling didHandleFetchEvent() until the
48 // given promise is resolved or rejected. 48 // given promise is resolved or rejected.
49 void respondWith(ScriptState*, ScriptPromise, ExceptionState&); 49 void respondWith(ScriptState*, ScriptPromise, ExceptionState&);
50 50
51 void responseWasRejected(WebServiceWorkerResponseError); 51 void responseWasRejected(WebServiceWorkerResponseError);
52 virtual void responseWasFulfilled(const ScriptValue&); 52 virtual void responseWasFulfilled(const ScriptValue&);
53 53
54 DECLARE_VIRTUAL_TRACE(); 54 DECLARE_VIRTUAL_TRACE();
55 55
56 protected: 56 protected:
57 RespondWithObserver(ExecutionContext*, 57 RespondWithObserver(ExecutionContext*,
58 int eventID, 58 int fetchEventID,
59 const KURL& requestURL, 59 const KURL& requestURL,
60 WebURLRequest::FetchRequestMode, 60 WebURLRequest::FetchRequestMode,
61 WebURLRequest::FrameType, 61 WebURLRequest::FrameType,
62 WebURLRequest::RequestContext, 62 WebURLRequest::RequestContext,
63 WaitUntilObserver*); 63 WaitUntilObserver*);
64 64
65 private: 65 private:
66 class ThenFunction; 66 class ThenFunction;
67 67
68 int m_eventID; 68 int m_fetchEventID;
69 KURL m_requestURL; 69 KURL m_requestURL;
70 WebURLRequest::FetchRequestMode m_requestMode; 70 WebURLRequest::FetchRequestMode m_requestMode;
71 WebURLRequest::FrameType m_frameType; 71 WebURLRequest::FrameType m_frameType;
72 WebURLRequest::RequestContext m_requestContext; 72 WebURLRequest::RequestContext m_requestContext;
73 73
74 double m_eventDispatchTime = 0; 74 double m_eventDispatchTime = 0;
75 75
76 enum State { Initial, Pending, Done }; 76 enum State { Initial, Pending, Done };
77 State m_state; 77 State m_state;
78 78
79 // RespondWith should ensure the ExtendableEvent is alive until the promise 79 // RespondWith should ensure the ExtendableEvent is alive until the promise
80 // passed to RespondWith is resolved. The lifecycle of the ExtendableEvent 80 // passed to RespondWith is resolved. The lifecycle of the ExtendableEvent
81 // is controlled by WaitUntilObserver, so not only 81 // is controlled by WaitUntilObserver, so not only
82 // WaitUntilObserver::ThenFunction but RespondWith needs to have a strong 82 // WaitUntilObserver::ThenFunction but RespondWith needs to have a strong
83 // reference to the WaitUntilObserver. 83 // reference to the WaitUntilObserver.
84 Member<WaitUntilObserver> m_observer; 84 Member<WaitUntilObserver> m_observer;
85 }; 85 };
86 86
87 } // namespace blink 87 } // namespace blink
88 88
89 #endif // RespondWithObserver_h 89 #endif // RespondWithObserver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698