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

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

Issue 1878463002: Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tidy 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) 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(PassRefPtr<DOMArrayBuffer> prpData, ExceptionState& ex ceptionState) 198 void RTCDataChannel::send(DOMArrayBuffer* data, ExceptionState& exceptionState)
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
207 size_t dataLength = data->byteLength(); 205 size_t dataLength = data->byteLength();
208 if (!dataLength) 206 if (!dataLength)
209 return; 207 return;
210 208
211 if (!m_handler->sendRawData(static_cast<const char*>((data->data())), dataLe ngth)) { 209 if (!m_handler->sendRawData(static_cast<const char*>((data->data())), dataLe ngth)) {
212 // FIXME: This should not throw an exception but instead forcefully clos e the data channel. 210 // FIXME: This should not throw an exception but instead forcefully clos e the data channel.
213 throwCouldNotSendDataException(exceptionState); 211 throwCouldNotSendDataException(exceptionState);
214 } 212 }
215 } 213 }
216 214
217 void RTCDataChannel::send(PassRefPtr<DOMArrayBufferView> data, ExceptionState& e xceptionState) 215 void RTCDataChannel::send(DOMArrayBufferView* data, ExceptionState& exceptionSta te)
218 { 216 {
219 if (!m_handler->sendRawData(static_cast<const char*>(data->baseAddress()), d ata->byteLength())) { 217 if (!m_handler->sendRawData(static_cast<const char*>(data->baseAddress()), d ata->byteLength())) {
220 // FIXME: This should not throw an exception but instead forcefully clos e the data channel. 218 // FIXME: This should not throw an exception but instead forcefully clos e the data channel.
221 throwCouldNotSendDataException(exceptionState); 219 throwCouldNotSendDataException(exceptionState);
222 } 220 }
223 } 221 }
224 222
225 void RTCDataChannel::send(Blob* data, ExceptionState& exceptionState) 223 void RTCDataChannel::send(Blob* data, ExceptionState& exceptionState)
226 { 224 {
227 // FIXME: implement 225 // FIXME: implement
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 scheduleDispatchEvent(MessageEvent::create(text)); 263 scheduleDispatchEvent(MessageEvent::create(text));
266 } 264 }
267 265
268 void RTCDataChannel::didReceiveRawData(const char* data, size_t dataLength) 266 void RTCDataChannel::didReceiveRawData(const char* data, size_t dataLength)
269 { 267 {
270 if (m_binaryType == BinaryTypeBlob) { 268 if (m_binaryType == BinaryTypeBlob) {
271 // FIXME: Implement. 269 // FIXME: Implement.
272 return; 270 return;
273 } 271 }
274 if (m_binaryType == BinaryTypeArrayBuffer) { 272 if (m_binaryType == BinaryTypeArrayBuffer) {
275 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(data, dataLength) ; 273 DOMArrayBuffer* buffer = DOMArrayBuffer::create(data, dataLength);
276 scheduleDispatchEvent(MessageEvent::create(buffer.release())); 274 scheduleDispatchEvent(MessageEvent::create(buffer));
277 return; 275 return;
278 } 276 }
279 NOTREACHED(); 277 NOTREACHED();
280 } 278 }
281 279
282 void RTCDataChannel::didDetectError() 280 void RTCDataChannel::didDetectError()
283 { 281 {
284 scheduleDispatchEvent(Event::create(EventTypeNames::error)); 282 scheduleDispatchEvent(Event::create(EventTypeNames::error));
285 } 283 }
286 284
(...skipping 28 matching lines...) Expand all
315 } 313 }
316 314
317 DEFINE_TRACE(RTCDataChannel) 315 DEFINE_TRACE(RTCDataChannel)
318 { 316 {
319 visitor->trace(m_executionContext); 317 visitor->trace(m_executionContext);
320 visitor->trace(m_scheduledEvents); 318 visitor->trace(m_scheduledEvents);
321 RefCountedGarbageCollectedEventTargetWithInlineData<RTCDataChannel>::trace(v isitor); 319 RefCountedGarbageCollectedEventTargetWithInlineData<RTCDataChannel>::trace(v isitor);
322 } 320 }
323 321
324 } // namespace blink 322 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698