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

Unified Diff: third_party/WebKit/Source/modules/serviceworkers/RespondWithObserver.h

Issue 2034663002: ServiceWorker: Keep the worker alive until FetchEvent.waitUntil settles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/serviceworkers/RespondWithObserver.h
diff --git a/third_party/WebKit/Source/modules/serviceworkers/RespondWithObserver.h b/third_party/WebKit/Source/modules/serviceworkers/RespondWithObserver.h
index b87cd8b0deabaf7b313fc0768e532ea82392b94c..3f9cd401865dd7e70138514f6a989db5a3acae21 100644
--- a/third_party/WebKit/Source/modules/serviceworkers/RespondWithObserver.h
+++ b/third_party/WebKit/Source/modules/serviceworkers/RespondWithObserver.h
@@ -8,6 +8,7 @@
#include "core/dom/ContextLifecycleObserver.h"
#include "core/events/EventTarget.h"
#include "modules/ModulesExport.h"
+#include "modules/serviceworkers/WaitUntilObserver.h"
#include "platform/heap/Handle.h"
#include "public/platform/WebURLRequest.h"
#include "public/platform/modules/serviceworker/WebServiceWorkerResponseError.h"
@@ -27,7 +28,7 @@ class MODULES_EXPORT RespondWithObserver : public GarbageCollectedFinalized<Resp
public:
virtual ~RespondWithObserver();
- static RespondWithObserver* create(ExecutionContext*, int eventID, const KURL& requestURL, WebURLRequest::FetchRequestMode, WebURLRequest::FrameType, WebURLRequest::RequestContext);
+ static RespondWithObserver* create(ExecutionContext*, int eventID, const KURL& requestURL, WebURLRequest::FetchRequestMode, WebURLRequest::FrameType, WebURLRequest::RequestContext, WaitUntilObserver*);
void contextDestroyed() override;
@@ -43,7 +44,7 @@ public:
DECLARE_VIRTUAL_TRACE();
protected:
- RespondWithObserver(ExecutionContext*, int eventID, const KURL& requestURL, WebURLRequest::FetchRequestMode, WebURLRequest::FrameType, WebURLRequest::RequestContext);
+ RespondWithObserver(ExecutionContext*, int eventID, const KURL& requestURL, WebURLRequest::FetchRequestMode, WebURLRequest::FrameType, WebURLRequest::RequestContext, WaitUntilObserver*);
private:
class ThenFunction;
@@ -56,6 +57,13 @@ private:
enum State { Initial, Pending, Done };
State m_state;
+
+ // RespondWith should ensure the ExtendableEvent is alive until the promise
+ // passed to RespondWith is resolved. The lifecycle of the ExtendableEvent
+ // is controlled by WaitUntilObserver, so not only
+ // WaitUntilObserver::ThenFunction but RespondWith needs to have a strong
+ // reference to the WaitUntilObserver.
+ Member<WaitUntilObserver> m_observer;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698