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

Unified Diff: third_party/WebKit/Source/modules/serviceworkers/FetchEvent.cpp

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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/serviceworkers/FetchEvent.cpp
diff --git a/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.cpp b/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.cpp
index d1650d9c297c55c41e4d9b8c5c609089b29313c6..b0cea898f7c86a1bfa779d9a26c18be5b9ec9ff8 100644
--- a/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.cpp
+++ b/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.cpp
@@ -67,6 +67,15 @@ const AtomicString& FetchEvent::InterfaceName() const {
return EventNames::FetchEvent;
}
+bool FetchEvent::HasPendingActivity() const {
+ // Prevent V8 from garbage collecting the wrapper object while waiting for the
+ // preload response. This is in order to keep the resolver of preloadResponse
+ // Promise alive.
+ return preload_response_property_->GetState() ==
+ PreloadResponseProperty::kPending &&
+ GetExecutionContext();
+}
+
FetchEvent::FetchEvent(ScriptState* script_state,
const AtomicString& type,
const FetchEventInit& initializer,
@@ -74,6 +83,7 @@ FetchEvent::FetchEvent(ScriptState* script_state,
WaitUntilObserver* wait_until_observer,
bool navigation_preload_sent)
: ExtendableEvent(type, initializer, wait_until_observer),
+ ContextClient(ExecutionContext::From(script_state)),
observer_(respond_with_observer),
preload_response_property_(new PreloadResponseProperty(
ExecutionContext::From(script_state),
@@ -107,6 +117,8 @@ FetchEvent::FetchEvent(ScriptState* script_state,
}
}
+FetchEvent::~FetchEvent() {}
+
void FetchEvent::OnNavigationPreloadResponse(
ScriptState* script_state,
std::unique_ptr<WebURLResponse> response,
@@ -156,6 +168,7 @@ DEFINE_TRACE(FetchEvent) {
visitor->Trace(request_);
visitor->Trace(preload_response_property_);
ExtendableEvent::Trace(visitor);
+ ContextClient::Trace(visitor);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698