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

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

Issue 1901103006: Web MIDI: Replace ASSERT macros with DCHECK macros (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 for (; !isEndOfData(); m_offset++) { 118 for (; !isEndOfData(); m_offset++) {
119 if (isRealTimeMessage() && !isReservedStatusByte()) 119 if (isRealTimeMessage() && !isReservedStatusByte())
120 continue; 120 continue;
121 return true; 121 return true;
122 } 122 }
123 return false; 123 return false;
124 } 124 }
125 125
126 bool acceptCurrentSysex() 126 bool acceptCurrentSysex()
127 { 127 {
128 ASSERT(isSysex()); 128 DCHECK(isSysex());
129 for (m_offset++; !isEndOfData(); m_offset++) { 129 for (m_offset++; !isEndOfData(); m_offset++) {
130 if (isReservedStatusByte()) 130 if (isReservedStatusByte())
131 return false; 131 return false;
132 if (isRealTimeMessage()) 132 if (isRealTimeMessage())
133 continue; 133 continue;
134 if (isEndOfSysex()) { 134 if (isEndOfSysex()) {
135 m_offset++; 135 m_offset++;
136 return true; 136 return true;
137 } 137 }
138 if (isStatusByte()) 138 if (isStatusByte())
139 return false; 139 return false;
140 } 140 }
141 return false; 141 return false;
142 } 142 }
143 143
144 bool acceptCurrentMessage() 144 bool acceptCurrentMessage()
145 { 145 {
146 ASSERT(isStatusByte()); 146 DCHECK(isStatusByte());
147 ASSERT(!isSysex()); 147 DCHECK(!isSysex());
148 ASSERT(!isReservedStatusByte()); 148 DCHECK(!isReservedStatusByte());
149 ASSERT(!isRealTimeMessage()); 149 DCHECK(!isRealTimeMessage());
150 static const int channelMessageLength[7] = { 3, 3, 3, 3, 2, 2, 3 }; // f or 0x8*, 0x9*, ..., 0xe* 150 static const int channelMessageLength[7] = { 3, 3, 3, 3, 2, 2, 3 }; // f or 0x8*, 0x9*, ..., 0xe*
151 static const int systemMessageLength[7] = { 2, 3, 2, 0, 0, 1, 0 }; // fo r 0xf1, 0xf2, ..., 0xf7 151 static const int systemMessageLength[7] = { 2, 3, 2, 0, 0, 1, 0 }; // fo r 0xf1, 0xf2, ..., 0xf7
152 size_t length = isSystemMessage() ? systemMessageLength[m_data[m_offset] - 0xf1] : channelMessageLength[(m_data[m_offset] >> 4) - 8]; 152 size_t length = isSystemMessage() ? systemMessageLength[m_data[m_offset] - 0xf1] : channelMessageLength[(m_data[m_offset] >> 4) - 8];
153 size_t count = 1; 153 size_t count = 1;
154 for (m_offset++; !isEndOfData(); m_offset++) { 154 for (m_offset++; !isEndOfData(); m_offset++) {
155 if (isReservedStatusByte()) 155 if (isReservedStatusByte())
156 return false; 156 return false;
157 if (isRealTimeMessage()) 157 if (isRealTimeMessage())
158 continue; 158 continue;
159 if (isStatusByte()) 159 if (isStatusByte())
(...skipping 10 matching lines...) Expand all
170 170
171 const unsigned char* m_data; 171 const unsigned char* m_data;
172 const size_t m_length; 172 const size_t m_length;
173 size_t m_offset; 173 size_t m_offset;
174 }; 174 };
175 175
176 } // namespace 176 } // namespace
177 177
178 MIDIOutput* MIDIOutput::create(MIDIAccess* access, unsigned portIndex, const Str ing& id, const String& manufacturer, const String& name, const String& version, PortState state) 178 MIDIOutput* MIDIOutput::create(MIDIAccess* access, unsigned portIndex, const Str ing& id, const String& manufacturer, const String& name, const String& version, PortState state)
179 { 179 {
180 ASSERT(access); 180 DCHECK(access);
181 MIDIOutput* output = new MIDIOutput(access, portIndex, id, manufacturer, nam e, version, state); 181 MIDIOutput* output = new MIDIOutput(access, portIndex, id, manufacturer, nam e, version, state);
182 output->suspendIfNeeded(); 182 output->suspendIfNeeded();
183 return output; 183 return output;
184 } 184 }
185 185
186 MIDIOutput::MIDIOutput(MIDIAccess* access, unsigned portIndex, const String& id, const String& manufacturer, const String& name, const String& version, PortStat e state) 186 MIDIOutput::MIDIOutput(MIDIAccess* access, unsigned portIndex, const String& id, const String& manufacturer, const String& name, const String& version, PortStat e state)
187 : MIDIPort(access, id, manufacturer, name, TypeOutput, version, state) 187 : MIDIPort(access, id, manufacturer, name, TypeOutput, version, state)
188 , m_portIndex(portIndex) 188 , m_portIndex(portIndex)
189 { 189 {
190 } 190 }
191 191
192 MIDIOutput::~MIDIOutput() 192 MIDIOutput::~MIDIOutput()
193 { 193 {
194 } 194 }
195 195
196 void MIDIOutput::send(DOMUint8Array* array, double timestamp, ExceptionState& ex ceptionState) 196 void MIDIOutput::send(DOMUint8Array* array, double timestamp, ExceptionState& ex ceptionState)
197 { 197 {
198 ASSERT(array); 198 DCHECK(array);
199 199
200 if (timestamp == 0.0) 200 if (timestamp == 0.0)
201 timestamp = now(getExecutionContext()); 201 timestamp = now(getExecutionContext());
202 202
203 // Implicit open. It does nothing if the port is already opened. 203 // Implicit open. It does nothing if the port is already opened.
204 // This should be performed even if |array| is invalid. 204 // This should be performed even if |array| is invalid.
205 open(); 205 open();
206 206
207 if (MessageValidator::validate(array, exceptionState, midiAccess()->sysexEna bled())) 207 if (MessageValidator::validate(array, exceptionState, midiAccess()->sysexEna bled()))
208 midiAccess()->sendMIDIData(m_portIndex, array->data(), array->length(), timestamp); 208 midiAccess()->sendMIDIData(m_portIndex, array->data(), array->length(), timestamp);
(...skipping 15 matching lines...) Expand all
224 } 224 }
225 if (i < arrayLength) 225 if (i < arrayLength)
226 arrayData[i] = unsignedData[i] & 0xff; 226 arrayData[i] = unsignedData[i] & 0xff;
227 } 227 }
228 228
229 send(array, timestamp, exceptionState); 229 send(array, timestamp, exceptionState);
230 } 230 }
231 231
232 void MIDIOutput::send(DOMUint8Array* data, ExceptionState& exceptionState) 232 void MIDIOutput::send(DOMUint8Array* data, ExceptionState& exceptionState)
233 { 233 {
234 ASSERT(data); 234 DCHECK(data);
235 send(data, 0.0, exceptionState); 235 send(data, 0.0, exceptionState);
236 } 236 }
237 237
238 void MIDIOutput::send(Vector<unsigned> unsignedData, ExceptionState& exceptionSt ate) 238 void MIDIOutput::send(Vector<unsigned> unsignedData, ExceptionState& exceptionSt ate)
239 { 239 {
240 send(unsignedData, 0.0, exceptionState); 240 send(unsignedData, 0.0, exceptionState);
241 } 241 }
242 242
243 DEFINE_TRACE(MIDIOutput) 243 DEFINE_TRACE(MIDIOutput)
244 { 244 {
245 MIDIPort::trace(visitor); 245 MIDIPort::trace(visitor);
246 } 246 }
247 247
248 } // namespace blink 248 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webmidi/MIDIInput.cpp ('k') | third_party/WebKit/Source/modules/webmidi/MIDIPort.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698