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

Unified Diff: Source/modules/webmidi/MIDIAccessInitializer.cpp

Issue 864943003: Dispose of MIDIAccessInitializer on contextDestroyed() notification. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « Source/modules/webmidi/MIDIAccessInitializer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webmidi/MIDIAccessInitializer.cpp
diff --git a/Source/modules/webmidi/MIDIAccessInitializer.cpp b/Source/modules/webmidi/MIDIAccessInitializer.cpp
index b1fda8518b9de403711e7e3cf868bc9992bff26a..19e7bcd18d8e1f4c35ae3582cfe29231b7ec1a60 100644
--- a/Source/modules/webmidi/MIDIAccessInitializer.cpp
+++ b/Source/modules/webmidi/MIDIAccessInitializer.cpp
@@ -20,6 +20,7 @@ namespace blink {
MIDIAccessInitializer::MIDIAccessInitializer(ScriptState* scriptState, const MIDIOptions& options)
: ScriptPromiseResolver(scriptState)
, m_requestSysex(false)
+ , m_hasBeenDisposed(false)
{
#if ENABLE(OILPAN)
// A prefinalizer has already been registered (as a LifecycleObserver);
@@ -43,14 +44,27 @@ MIDIAccessInitializer::~MIDIAccessInitializer()
#endif
}
+void MIDIAccessInitializer::contextDestroyed()
+{
+ dispose();
+}
+
void MIDIAccessInitializer::dispose()
{
+ if (m_hasBeenDisposed)
+ return;
+
+ if (!executionContext())
+ return;
+
// It is safe to cancel a request which is already finished or cancelled.
Document* document = toDocument(executionContext());
ASSERT(document);
if (MIDIController* controller = MIDIController::from(document->frame()))
controller->cancelSysexPermissionRequest(this);
+ m_hasBeenDisposed = true;
+
#if ENABLE(OILPAN)
// Delegate to LifecycleObserver's prefinalizer.
LifecycleObserver::dispose();
« no previous file with comments | « Source/modules/webmidi/MIDIAccessInitializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698