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

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/RTCDataChannel.cpp

Issue 1964183004: Revert of Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 if (m_readyState != ReadyStateOpen) { 188 if (m_readyState != ReadyStateOpen) {
189 throwNotOpenException(exceptionState); 189 throwNotOpenException(exceptionState);
190 return; 190 return;
191 } 191 }
192 if (!m_handler->sendStringData(data)) { 192 if (!m_handler->sendStringData(data)) {
193 // FIXME: This should not throw an exception but instead forcefully clos e the data channel. 193 // FIXME: This should not throw an exception but instead forcefully clos e the data channel.
194 throwCouldNotSendDataException(exceptionState); 194 throwCouldNotSendDataException(exceptionState);
195 } 195 }
196 } 196 }
197 197
198 void RTCDataChannel::send(DOMArrayBuffer* data, ExceptionState& exceptionState) 198 void RTCDataChannel::send(PassRefPtr<DOMArrayBuffer> prpData, ExceptionState& ex ceptionState)
199 { 199 {
200 if (m_readyState != ReadyStateOpen) { 200 if (m_readyState != ReadyStateOpen) {
201 throwNotOpenException(exceptionState); 201 throwNotOpenException(exceptionState);
202 return; 202 return;
203 } 203 }
204 204
205 RefPtr<DOMArrayBuffer> data = prpData;
206
205 size_t dataLength = data->byteLength(); 207 size_t dataLength = data->byteLength();
206 if (!dataLength) 208 if (!dataLength)
207 return; 209 return;
208 210
209 if (!m_handler->sendRawData(static_cast<const char*>((data->data())), dataLe ngth)) { 211 if (!m_handler->sendRawData(static_cast<const char*>((data->data())), dataLe ngth)) {
210 // FIXME: This should not throw an exception but instead forcefully clos e the data channel. 212 // FIXME: This should not throw an exception but instead forcefully clos e the data channel.
211 throwCouldNotSendDataException(exceptionState); 213 throwCouldNotSendDataException(exceptionState);
212 } 214 }
213 } 215 }
214 216
215 void RTCDataChannel::send(DOMArrayBufferView* data, ExceptionState& exceptionSta te) 217 void RTCDataChannel::send(PassRefPtr<DOMArrayBufferView> data, ExceptionState& e xceptionState)
216 { 218 {
217 if (!m_handler->sendRawData(static_cast<const char*>(data->baseAddress()), d ata->byteLength())) { 219 if (!m_handler->sendRawData(static_cast<const char*>(data->baseAddress()), d ata->byteLength())) {
218 // FIXME: This should not throw an exception but instead forcefully clos e the data channel. 220 // FIXME: This should not throw an exception but instead forcefully clos e the data channel.
219 throwCouldNotSendDataException(exceptionState); 221 throwCouldNotSendDataException(exceptionState);
220 } 222 }
221 } 223 }
222 224
223 void RTCDataChannel::send(Blob* data, ExceptionState& exceptionState) 225 void RTCDataChannel::send(Blob* data, ExceptionState& exceptionState)
224 { 226 {
225 // FIXME: implement 227 // FIXME: implement
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 scheduleDispatchEvent(MessageEvent::create(text)); 265 scheduleDispatchEvent(MessageEvent::create(text));
264 } 266 }
265 267
266 void RTCDataChannel::didReceiveRawData(const char* data, size_t dataLength) 268 void RTCDataChannel::didReceiveRawData(const char* data, size_t dataLength)
267 { 269 {
268 if (m_binaryType == BinaryTypeBlob) { 270 if (m_binaryType == BinaryTypeBlob) {
269 // FIXME: Implement. 271 // FIXME: Implement.
270 return; 272 return;
271 } 273 }
272 if (m_binaryType == BinaryTypeArrayBuffer) { 274 if (m_binaryType == BinaryTypeArrayBuffer) {
273 DOMArrayBuffer* buffer = DOMArrayBuffer::create(data, dataLength); 275 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(data, dataLength) ;
274 scheduleDispatchEvent(MessageEvent::create(buffer)); 276 scheduleDispatchEvent(MessageEvent::create(buffer.release()));
275 return; 277 return;
276 } 278 }
277 NOTREACHED(); 279 NOTREACHED();
278 } 280 }
279 281
280 void RTCDataChannel::didDetectError() 282 void RTCDataChannel::didDetectError()
281 { 283 {
282 scheduleDispatchEvent(Event::create(EventTypeNames::error)); 284 scheduleDispatchEvent(Event::create(EventTypeNames::error));
283 } 285 }
284 286
(...skipping 28 matching lines...) Expand all
313 } 315 }
314 316
315 DEFINE_TRACE(RTCDataChannel) 317 DEFINE_TRACE(RTCDataChannel)
316 { 318 {
317 visitor->trace(m_executionContext); 319 visitor->trace(m_executionContext);
318 visitor->trace(m_scheduledEvents); 320 visitor->trace(m_scheduledEvents);
319 RefCountedGarbageCollectedEventTargetWithInlineData<RTCDataChannel>::trace(v isitor); 321 RefCountedGarbageCollectedEventTargetWithInlineData<RTCDataChannel>::trace(v isitor);
320 } 322 }
321 323
322 } // namespace blink 324 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698