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

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

Issue 2218943002: Introduce ServiceWorker.EventDispatchingDelay UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated mpearson@'s comment Created 4 years, 3 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 : public GarbageCollectedFinalized<Resp ondWithObserver>, public ContextLifecycleObserver { 26 class MODULES_EXPORT RespondWithObserver : public GarbageCollectedFinalized<Resp ondWithObserver>, public ContextLifecycleObserver {
27 USING_GARBAGE_COLLECTED_MIXIN(RespondWithObserver); 27 USING_GARBAGE_COLLECTED_MIXIN(RespondWithObserver);
28 public: 28 public:
29 virtual ~RespondWithObserver(); 29 virtual ~RespondWithObserver();
30 30
31 static RespondWithObserver* create(ExecutionContext*, int eventID, const KUR L& requestURL, WebURLRequest::FetchRequestMode, WebURLRequest::FrameType, WebURL Request::RequestContext, WaitUntilObserver*); 31 static RespondWithObserver* create(ExecutionContext*, int eventID, const KUR L& requestURL, WebURLRequest::FetchRequestMode, WebURLRequest::FrameType, WebURL Request::RequestContext, WaitUntilObserver*);
32 32
33 void contextDestroyed() override; 33 void contextDestroyed() override;
34 34
35 void willDispatchEvent();
35 void didDispatchEvent(DispatchEventResult dispatchResult); 36 void didDispatchEvent(DispatchEventResult dispatchResult);
36 37
37 // Observes the promise and delays calling didHandleFetchEvent() until the 38 // Observes the promise and delays calling didHandleFetchEvent() until the
38 // given promise is resolved or rejected. 39 // given promise is resolved or rejected.
39 void respondWith(ScriptState*, ScriptPromise, ExceptionState&); 40 void respondWith(ScriptState*, ScriptPromise, ExceptionState&);
40 41
41 void responseWasRejected(WebServiceWorkerResponseError); 42 void responseWasRejected(WebServiceWorkerResponseError);
42 virtual void responseWasFulfilled(const ScriptValue&); 43 virtual void responseWasFulfilled(const ScriptValue&);
43 44
44 DECLARE_VIRTUAL_TRACE(); 45 DECLARE_VIRTUAL_TRACE();
45 46
46 protected: 47 protected:
47 RespondWithObserver(ExecutionContext*, int eventID, const KURL& requestURL, WebURLRequest::FetchRequestMode, WebURLRequest::FrameType, WebURLRequest::Reques tContext, WaitUntilObserver*); 48 RespondWithObserver(ExecutionContext*, int eventID, const KURL& requestURL, WebURLRequest::FetchRequestMode, WebURLRequest::FrameType, WebURLRequest::Reques tContext, WaitUntilObserver*);
48 49
49 private: 50 private:
50 class ThenFunction; 51 class ThenFunction;
51 52
52 int m_eventID; 53 int m_eventID;
53 KURL m_requestURL; 54 KURL m_requestURL;
54 WebURLRequest::FetchRequestMode m_requestMode; 55 WebURLRequest::FetchRequestMode m_requestMode;
55 WebURLRequest::FrameType m_frameType; 56 WebURLRequest::FrameType m_frameType;
56 WebURLRequest::RequestContext m_requestContext; 57 WebURLRequest::RequestContext m_requestContext;
57 58
59 double m_eventDispatchTime = 0;
60
58 enum State { Initial, Pending, Done }; 61 enum State { Initial, Pending, Done };
59 State m_state; 62 State m_state;
60 63
61 // RespondWith should ensure the ExtendableEvent is alive until the promise 64 // RespondWith should ensure the ExtendableEvent is alive until the promise
62 // passed to RespondWith is resolved. The lifecycle of the ExtendableEvent 65 // passed to RespondWith is resolved. The lifecycle of the ExtendableEvent
63 // is controlled by WaitUntilObserver, so not only 66 // is controlled by WaitUntilObserver, so not only
64 // WaitUntilObserver::ThenFunction but RespondWith needs to have a strong 67 // WaitUntilObserver::ThenFunction but RespondWith needs to have a strong
65 // reference to the WaitUntilObserver. 68 // reference to the WaitUntilObserver.
66 Member<WaitUntilObserver> m_observer; 69 Member<WaitUntilObserver> m_observer;
67 }; 70 };
68 71
69 } // namespace blink 72 } // namespace blink
70 73
71 #endif // RespondWithObserver_h 74 #endif // RespondWithObserver_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698