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

Side by Side Diff: third_party/WebKit/Source/modules/webmidi/MIDIAccess.cpp

Issue 2489033005: Web MIDI: deprecate MIDIMessageEvent.receivedTime (Closed)
Patch Set: expectation for virtual Created 4 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 184 }
185 185
186 void MIDIAccess::didReceiveMIDIData(unsigned portIndex, 186 void MIDIAccess::didReceiveMIDIData(unsigned portIndex,
187 const unsigned char* data, 187 const unsigned char* data,
188 size_t length, 188 size_t length,
189 double timeStamp) { 189 double timeStamp) {
190 DCHECK(isMainThread()); 190 DCHECK(isMainThread());
191 if (portIndex >= m_inputs.size()) 191 if (portIndex >= m_inputs.size())
192 return; 192 return;
193 193
194 // Convert from time in seconds which is based on the time coordinate system 194 m_inputs[portIndex]->didReceiveMIDIData(portIndex, data, length, timeStamp);
195 // of monotonicallyIncreasingTime() into time in milliseconds (a
196 // DOMHighResTimeStamp) according to the same time coordinate system as
197 // performance.now(). This is how timestamps are defined in the Web MIDI
198 // spec.
199 Document* document = toDocument(getExecutionContext());
200 DCHECK(document);
201
202 double timeStampInMilliseconds =
203 1000 *
204 document->loader()->timing().monotonicTimeToZeroBasedDocumentTime(
205 timeStamp);
206
207 m_inputs[portIndex]->didReceiveMIDIData(portIndex, data, length,
208 timeStampInMilliseconds);
209 } 195 }
210 196
211 void MIDIAccess::sendMIDIData(unsigned portIndex, 197 void MIDIAccess::sendMIDIData(unsigned portIndex,
212 const unsigned char* data, 198 const unsigned char* data,
213 size_t length, 199 size_t length,
214 double timeStampInMilliseconds) { 200 double timeStampInMilliseconds) {
215 if (!data || !length || portIndex >= m_outputs.size()) 201 if (!data || !length || portIndex >= m_outputs.size())
216 return; 202 return;
217 // Convert from a time in milliseconds (a DOMHighResTimeStamp) according to 203 // Convert from a time in milliseconds (a DOMHighResTimeStamp) according to
218 // the same time coordinate system as performance.now() into a time in seconds 204 // the same time coordinate system as performance.now() into a time in seconds
(...skipping 21 matching lines...) Expand all
240 } 226 }
241 227
242 DEFINE_TRACE(MIDIAccess) { 228 DEFINE_TRACE(MIDIAccess) {
243 visitor->trace(m_inputs); 229 visitor->trace(m_inputs);
244 visitor->trace(m_outputs); 230 visitor->trace(m_outputs);
245 EventTargetWithInlineData::trace(visitor); 231 EventTargetWithInlineData::trace(visitor);
246 ActiveDOMObject::trace(visitor); 232 ActiveDOMObject::trace(visitor);
247 } 233 }
248 234
249 } // namespace blink 235 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/Deprecation.cpp ('k') | third_party/WebKit/Source/modules/webmidi/MIDIMessageEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698