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

Unified Diff: third_party/WebKit/Source/modules/webmidi/MIDIAccess.cpp

Issue 2566223006: Web MIDI: stop sending messages when the document is going to be closed (Closed)
Patch Set: Created 4 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webmidi/MIDIAccess.cpp
diff --git a/third_party/WebKit/Source/modules/webmidi/MIDIAccess.cpp b/third_party/WebKit/Source/modules/webmidi/MIDIAccess.cpp
index 47ef628c0319c98951e68280bb6f7d0ed03faceb..f9090c1a4c7afaf9feb9e3b937b463308fdf25ed 100644
--- a/third_party/WebKit/Source/modules/webmidi/MIDIAccess.cpp
+++ b/third_party/WebKit/Source/modules/webmidi/MIDIAccess.cpp
@@ -198,8 +198,16 @@ void MIDIAccess::sendMIDIData(unsigned portIndex,
const unsigned char* data,
size_t length,
double timeStampInMilliseconds) {
+ // Do not continue sending when document is going to be closed.
+ Document* document = toDocument(getExecutionContext());
+ DCHECK(document);
+ DocumentLoader* loader = document->loader();
+ if (!loader)
+ return;
+
if (!data || !length || portIndex >= m_outputs.size())
return;
+
// Convert from a time in milliseconds (a DOMHighResTimeStamp) according to
// the same time coordinate system as performance.now() into a time in seconds
// which is based on the time coordinate system of
@@ -211,10 +219,7 @@ void MIDIAccess::sendMIDIData(unsigned portIndex,
// "now". We need to translate it exactly to 0 seconds.
timeStamp = 0;
} else {
- Document* document = toDocument(getExecutionContext());
- DCHECK(document);
- double documentStartTime =
- document->loader()->timing().referenceMonotonicTime();
+ double documentStartTime = loader->timing().referenceMonotonicTime();
timeStamp = documentStartTime + 0.001 * timeStampInMilliseconds;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698