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

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

Issue 2392463004: reflow comments in modules/{webmidi,websocket} (Closed)
Patch Set: Created 4 years, 2 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 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 168 }
169 169
170 void MIDIAccess::didReceiveMIDIData(unsigned portIndex, 170 void MIDIAccess::didReceiveMIDIData(unsigned portIndex,
171 const unsigned char* data, 171 const unsigned char* data,
172 size_t length, 172 size_t length,
173 double timeStamp) { 173 double timeStamp) {
174 DCHECK(isMainThread()); 174 DCHECK(isMainThread());
175 if (portIndex >= m_inputs.size()) 175 if (portIndex >= m_inputs.size())
176 return; 176 return;
177 177
178 // Convert from time in seconds which is based on the time coordinate system o f monotonicallyIncreasingTime() 178 // Convert from time in seconds which is based on the time coordinate system
179 // into time in milliseconds (a DOMHighResTimeStamp) according to the same tim e coordinate system as performance.now(). 179 // of monotonicallyIncreasingTime() into time in milliseconds (a
180 // This is how timestamps are defined in the Web MIDI spec. 180 // DOMHighResTimeStamp) according to the same time coordinate system as
181 // performance.now(). This is how timestamps are defined in the Web MIDI
182 // spec.
181 Document* document = toDocument(getExecutionContext()); 183 Document* document = toDocument(getExecutionContext());
182 DCHECK(document); 184 DCHECK(document);
183 185
184 double timeStampInMilliseconds = 186 double timeStampInMilliseconds =
185 1000 * 187 1000 *
186 document->loader()->timing().monotonicTimeToZeroBasedDocumentTime( 188 document->loader()->timing().monotonicTimeToZeroBasedDocumentTime(
187 timeStamp); 189 timeStamp);
188 190
189 m_inputs[portIndex]->didReceiveMIDIData(portIndex, data, length, 191 m_inputs[portIndex]->didReceiveMIDIData(portIndex, data, length,
190 timeStampInMilliseconds); 192 timeStampInMilliseconds);
191 } 193 }
192 194
193 void MIDIAccess::sendMIDIData(unsigned portIndex, 195 void MIDIAccess::sendMIDIData(unsigned portIndex,
194 const unsigned char* data, 196 const unsigned char* data,
195 size_t length, 197 size_t length,
196 double timeStampInMilliseconds) { 198 double timeStampInMilliseconds) {
197 if (!data || !length || portIndex >= m_outputs.size()) 199 if (!data || !length || portIndex >= m_outputs.size())
198 return; 200 return;
199 // Convert from a time in milliseconds (a DOMHighResTimeStamp) according to th e same time coordinate system as performance.now() 201 // Convert from a time in milliseconds (a DOMHighResTimeStamp) according to
200 // into a time in seconds which is based on the time coordinate system of mono tonicallyIncreasingTime(). 202 // the same time coordinate system as performance.now() into a time in seconds
203 // which is based on the time coordinate system of
204 // monotonicallyIncreasingTime().
201 double timeStamp; 205 double timeStamp;
202 206
203 if (!timeStampInMilliseconds) { 207 if (!timeStampInMilliseconds) {
204 // We treat a value of 0 (which is the default value) as special, meaning "n ow". 208 // We treat a value of 0 (which is the default value) as special, meaning
205 // We need to translate it exactly to 0 seconds. 209 // "now". We need to translate it exactly to 0 seconds.
206 timeStamp = 0; 210 timeStamp = 0;
207 } else { 211 } else {
208 Document* document = toDocument(getExecutionContext()); 212 Document* document = toDocument(getExecutionContext());
209 DCHECK(document); 213 DCHECK(document);
210 double documentStartTime = 214 double documentStartTime =
211 document->loader()->timing().referenceMonotonicTime(); 215 document->loader()->timing().referenceMonotonicTime();
212 timeStamp = documentStartTime + 0.001 * timeStampInMilliseconds; 216 timeStamp = documentStartTime + 0.001 * timeStampInMilliseconds;
213 } 217 }
214 218
215 m_accessor->sendMIDIData(portIndex, data, length, timeStamp); 219 m_accessor->sendMIDIData(portIndex, data, length, timeStamp);
216 } 220 }
217 221
218 void MIDIAccess::stop() { 222 void MIDIAccess::stop() {
219 m_accessor.reset(); 223 m_accessor.reset();
220 } 224 }
221 225
222 DEFINE_TRACE(MIDIAccess) { 226 DEFINE_TRACE(MIDIAccess) {
223 visitor->trace(m_inputs); 227 visitor->trace(m_inputs);
224 visitor->trace(m_outputs); 228 visitor->trace(m_outputs);
225 EventTargetWithInlineData::trace(visitor); 229 EventTargetWithInlineData::trace(visitor);
226 ActiveDOMObject::trace(visitor); 230 ActiveDOMObject::trace(visitor);
227 } 231 }
228 232
229 } // namespace blink 233 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webmidi/MIDIAccess.h ('k') | third_party/WebKit/Source/modules/webmidi/MIDIInput.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698