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

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

Issue 2707243006: [SharedArrayBuffer] Prevent SharedArrayBuffer being used in Web APIs (Closed)
Patch Set: Created 3 years, 10 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, TypeOutput, version, state), 219 : MIDIPort(access, id, manufacturer, name, TypeOutput, version, state),
220 m_portIndex(portIndex) {} 220 m_portIndex(portIndex) {}
221 221
222 MIDIOutput::~MIDIOutput() {} 222 MIDIOutput::~MIDIOutput() {}
223 223
224 void MIDIOutput::send(DOMUint8Array* array, 224 void MIDIOutput::send(const MaybeShared<DOMUint8Array>& maybeShared,
225 double timestamp, 225 double timestamp,
226 ExceptionState& exceptionState) { 226 ExceptionState& exceptionState) {
227 DCHECK(array); 227 DCHECK(maybeShared);
228 if (maybeShared.isShared()) {
229 exceptionState.throwTypeError(
230 "The array is backed by a SharedArrayBuffer.");
231 return;
232 }
233 DOMUint8Array* array = maybeShared.viewNotShared();
228 234
229 if (timestamp == 0.0) 235 if (timestamp == 0.0)
230 timestamp = now(getExecutionContext()); 236 timestamp = now(getExecutionContext());
231 237
232 // Implicit open. It does nothing if the port is already opened. 238 // Implicit open. It does nothing if the port is already opened.
233 // This should be performed even if |array| is invalid. 239 // This should be performed even if |array| is invalid.
234 open(); 240 open();
235 241
236 if (MessageValidator::validate(array, exceptionState, 242 if (MessageValidator::validate(array, exceptionState,
237 midiAccess()->sysexEnabled())) 243 midiAccess()->sysexEnabled()))
(...skipping 18 matching lines...) Expand all
256 ") is greater than 0xFF."); 262 ") is greater than 0xFF.");
257 return; 263 return;
258 } 264 }
259 if (i < arrayLength) 265 if (i < arrayLength)
260 arrayData[i] = unsignedData[i] & 0xff; 266 arrayData[i] = unsignedData[i] & 0xff;
261 } 267 }
262 268
263 send(array, timestamp, exceptionState); 269 send(array, timestamp, exceptionState);
264 } 270 }
265 271
266 void MIDIOutput::send(DOMUint8Array* data, ExceptionState& exceptionState) { 272 void MIDIOutput::send(const MaybeShared<DOMUint8Array>& data,
273 ExceptionState& exceptionState) {
267 DCHECK(data); 274 DCHECK(data);
268 send(data, 0.0, exceptionState); 275 send(data, 0.0, exceptionState);
269 } 276 }
270 277
271 void MIDIOutput::send(Vector<unsigned> unsignedData, 278 void MIDIOutput::send(Vector<unsigned> unsignedData,
272 ExceptionState& exceptionState) { 279 ExceptionState& exceptionState) {
273 send(unsignedData, 0.0, exceptionState); 280 send(unsignedData, 0.0, exceptionState);
274 } 281 }
275 282
276 DEFINE_TRACE(MIDIOutput) { 283 DEFINE_TRACE(MIDIOutput) {
277 MIDIPort::trace(visitor); 284 MIDIPort::trace(visitor);
278 } 285 }
279 286
280 } // namespace blink 287 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698