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

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

Issue 2812833003: Revert of [SharedArrayBuffer] Prevent SharedArrayBuffer being used in Web APIs (Closed)
Patch Set: Created 3 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 const String& id, 214 const String& id,
215 const String& manufacturer, 215 const String& manufacturer,
216 const String& name, 216 const String& name,
217 const String& version, 217 const String& version,
218 PortState state) 218 PortState state)
219 : MIDIPort(access, id, manufacturer, name, kTypeOutput, version, state), 219 : MIDIPort(access, id, manufacturer, name, kTypeOutput, version, state),
220 port_index_(port_index) {} 220 port_index_(port_index) {}
221 221
222 MIDIOutput::~MIDIOutput() {} 222 MIDIOutput::~MIDIOutput() {}
223 223
224 void MIDIOutput::send(NotShared<DOMUint8Array> array, 224 void MIDIOutput::send(DOMUint8Array* array,
225 double timestamp, 225 double timestamp,
226 ExceptionState& exception_state) { 226 ExceptionState& exception_state) {
227 DCHECK(array); 227 DCHECK(array);
228 228
229 if (timestamp == 0.0) 229 if (timestamp == 0.0)
230 timestamp = Now(GetExecutionContext()); 230 timestamp = Now(GetExecutionContext());
231 231
232 // Implicit open. It does nothing if the port is already opened. 232 // Implicit open. It does nothing if the port is already opened.
233 // This should be performed even if |array| is invalid. 233 // This should be performed even if |array| is invalid.
234 open(); 234 open();
235 235
236 if (MessageValidator::Validate(array.View(), exception_state, 236 if (MessageValidator::Validate(array, exception_state,
237 midiAccess()->sysexEnabled())) { 237 midiAccess()->sysexEnabled()))
238 midiAccess()->SendMIDIData(port_index_, array.View()->Data(), 238 midiAccess()->SendMIDIData(port_index_, array->Data(), array->length(),
239 array.View()->length(), timestamp); 239 timestamp);
240 }
241 } 240 }
242 241
243 void MIDIOutput::send(Vector<unsigned> unsigned_data, 242 void MIDIOutput::send(Vector<unsigned> unsigned_data,
244 double timestamp, 243 double timestamp,
245 ExceptionState& exception_state) { 244 ExceptionState& exception_state) {
246 if (timestamp == 0.0) 245 if (timestamp == 0.0)
247 timestamp = Now(GetExecutionContext()); 246 timestamp = Now(GetExecutionContext());
248 247
249 DOMUint8Array* array = DOMUint8Array::Create(unsigned_data.size()); 248 DOMUint8Array* array = DOMUint8Array::Create(unsigned_data.size());
250 DOMUint8Array::ValueType* const array_data = array->Data(); 249 DOMUint8Array::ValueType* const array_data = array->Data();
251 const uint32_t array_length = array->length(); 250 const uint32_t array_length = array->length();
252 251
253 for (size_t i = 0; i < unsigned_data.size(); ++i) { 252 for (size_t i = 0; i < unsigned_data.size(); ++i) {
254 if (unsigned_data[i] > 0xff) { 253 if (unsigned_data[i] > 0xff) {
255 exception_state.ThrowTypeError("The value at index " + String::Number(i) + 254 exception_state.ThrowTypeError("The value at index " + String::Number(i) +
256 " (" + String::Number(unsigned_data[i]) + 255 " (" + String::Number(unsigned_data[i]) +
257 ") is greater than 0xFF."); 256 ") is greater than 0xFF.");
258 return; 257 return;
259 } 258 }
260 if (i < array_length) 259 if (i < array_length)
261 array_data[i] = unsigned_data[i] & 0xff; 260 array_data[i] = unsigned_data[i] & 0xff;
262 } 261 }
263 262
264 send(NotShared<DOMUint8Array>(array), timestamp, exception_state); 263 send(array, timestamp, exception_state);
265 } 264 }
266 265
267 void MIDIOutput::send(NotShared<DOMUint8Array> data, 266 void MIDIOutput::send(DOMUint8Array* data, ExceptionState& exception_state) {
268 ExceptionState& exception_state) {
269 DCHECK(data); 267 DCHECK(data);
270 send(data, 0.0, exception_state); 268 send(data, 0.0, exception_state);
271 } 269 }
272 270
273 void MIDIOutput::send(Vector<unsigned> unsigned_data, 271 void MIDIOutput::send(Vector<unsigned> unsigned_data,
274 ExceptionState& exception_state) { 272 ExceptionState& exception_state) {
275 send(unsigned_data, 0.0, exception_state); 273 send(unsigned_data, 0.0, exception_state);
276 } 274 }
277 275
278 DEFINE_TRACE(MIDIOutput) { 276 DEFINE_TRACE(MIDIOutput) {
279 MIDIPort::Trace(visitor); 277 MIDIPort::Trace(visitor);
280 } 278 }
281 279
282 } // namespace blink 280 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webmidi/MIDIOutput.h ('k') | third_party/WebKit/Source/modules/websockets/DOMWebSocket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698