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

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: update comment, add TODO 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(DOMUint8Array* array, 224 void MIDIOutput::send(NotShared<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, exception_state, 236 if (MessageValidator::Validate(array.View(), exception_state,
237 midiAccess()->sysexEnabled())) 237 midiAccess()->sysexEnabled())) {
238 midiAccess()->SendMIDIData(port_index_, array->Data(), array->length(), 238 midiAccess()->SendMIDIData(port_index_, array.View()->Data(),
239 timestamp); 239 array.View()->length(), timestamp);
240 }
240 } 241 }
241 242
242 void MIDIOutput::send(Vector<unsigned> unsigned_data, 243 void MIDIOutput::send(Vector<unsigned> unsigned_data,
243 double timestamp, 244 double timestamp,
244 ExceptionState& exception_state) { 245 ExceptionState& exception_state) {
245 if (timestamp == 0.0) 246 if (timestamp == 0.0)
246 timestamp = Now(GetExecutionContext()); 247 timestamp = Now(GetExecutionContext());
247 248
248 DOMUint8Array* array = DOMUint8Array::Create(unsigned_data.size()); 249 DOMUint8Array* array = DOMUint8Array::Create(unsigned_data.size());
249 DOMUint8Array::ValueType* const array_data = array->Data(); 250 DOMUint8Array::ValueType* const array_data = array->Data();
250 const uint32_t array_length = array->length(); 251 const uint32_t array_length = array->length();
251 252
252 for (size_t i = 0; i < unsigned_data.size(); ++i) { 253 for (size_t i = 0; i < unsigned_data.size(); ++i) {
253 if (unsigned_data[i] > 0xff) { 254 if (unsigned_data[i] > 0xff) {
254 exception_state.ThrowTypeError("The value at index " + String::Number(i) + 255 exception_state.ThrowTypeError("The value at index " + String::Number(i) +
255 " (" + String::Number(unsigned_data[i]) + 256 " (" + String::Number(unsigned_data[i]) +
256 ") is greater than 0xFF."); 257 ") is greater than 0xFF.");
257 return; 258 return;
258 } 259 }
259 if (i < array_length) 260 if (i < array_length)
260 array_data[i] = unsigned_data[i] & 0xff; 261 array_data[i] = unsigned_data[i] & 0xff;
261 } 262 }
262 263
263 send(array, timestamp, exception_state); 264 send(NotShared<DOMUint8Array>(array), timestamp, exception_state);
264 } 265 }
265 266
266 void MIDIOutput::send(DOMUint8Array* data, ExceptionState& exception_state) { 267 void MIDIOutput::send(NotShared<DOMUint8Array> data,
268 ExceptionState& exception_state) {
267 DCHECK(data); 269 DCHECK(data);
268 send(data, 0.0, exception_state); 270 send(data, 0.0, exception_state);
269 } 271 }
270 272
271 void MIDIOutput::send(Vector<unsigned> unsigned_data, 273 void MIDIOutput::send(Vector<unsigned> unsigned_data,
272 ExceptionState& exception_state) { 274 ExceptionState& exception_state) {
273 send(unsigned_data, 0.0, exception_state); 275 send(unsigned_data, 0.0, exception_state);
274 } 276 }
275 277
276 DEFINE_TRACE(MIDIOutput) { 278 DEFINE_TRACE(MIDIOutput) {
277 MIDIPort::Trace(visitor); 279 MIDIPort::Trace(visitor);
278 } 280 }
279 281
280 } // namespace blink 282 } // 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