OLD | NEW |
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 19 matching lines...) Expand all Loading... |
30 #include "core/dom/ExecutionContext.h" | 30 #include "core/dom/ExecutionContext.h" |
31 #include "core/events/Event.h" | 31 #include "core/events/Event.h" |
32 #include "core/events/MessageEvent.h" | 32 #include "core/events/MessageEvent.h" |
33 #include "core/fileapi/Blob.h" | 33 #include "core/fileapi/Blob.h" |
34 #include "public/platform/WebRTCPeerConnectionHandler.h" | 34 #include "public/platform/WebRTCPeerConnectionHandler.h" |
35 #include "wtf/ArrayBuffer.h" | 35 #include "wtf/ArrayBuffer.h" |
36 #include "wtf/ArrayBufferView.h" | 36 #include "wtf/ArrayBufferView.h" |
37 | 37 |
38 namespace WebCore { | 38 namespace WebCore { |
39 | 39 |
| 40 DEFINE_GC_INFO(RTCDataChannel); |
| 41 |
40 static void throwNotOpenException(ExceptionState& exceptionState) | 42 static void throwNotOpenException(ExceptionState& exceptionState) |
41 { | 43 { |
42 exceptionState.throwDOMException(InvalidStateError, "RTCDataChannel.readySta
te is not 'open'"); | 44 exceptionState.throwDOMException(InvalidStateError, "RTCDataChannel.readySta
te is not 'open'"); |
43 } | 45 } |
44 | 46 |
45 static void throwCouldNotSendDataException(ExceptionState& exceptionState) | 47 static void throwCouldNotSendDataException(ExceptionState& exceptionState) |
46 { | 48 { |
47 exceptionState.throwDOMException(NetworkError, "Could not send data"); | 49 exceptionState.throwDOMException(NetworkError, "Could not send data"); |
48 } | 50 } |
49 | 51 |
50 static void throwNoBlobSupportException(ExceptionState& exceptionState) | 52 static void throwNoBlobSupportException(ExceptionState& exceptionState) |
51 { | 53 { |
52 exceptionState.throwDOMException(NotSupportedError, "Blob support not implem
ented yet"); | 54 exceptionState.throwDOMException(NotSupportedError, "Blob support not implem
ented yet"); |
53 } | 55 } |
54 | 56 |
55 PassRefPtr<RTCDataChannel> RTCDataChannel::create(ExecutionContext* context, Pas
sOwnPtr<blink::WebRTCDataChannelHandler> handler) | 57 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCDataChannel::create(ExecutionContext*
context, PassOwnPtr<blink::WebRTCDataChannelHandler> handler) |
56 { | 58 { |
57 ASSERT(handler); | 59 ASSERT(handler); |
58 return adoptRef(new RTCDataChannel(context, handler)); | 60 return adoptRefCountedWillBeRefCountedGarbageCollected(new RTCDataChannel(co
ntext, handler)); |
59 } | 61 } |
60 | 62 |
61 PassRefPtr<RTCDataChannel> RTCDataChannel::create(ExecutionContext* context, bli
nk::WebRTCPeerConnectionHandler* peerConnectionHandler, const String& label, con
st blink::WebRTCDataChannelInit& init, ExceptionState& exceptionState) | 63 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCDataChannel::create(ExecutionContext*
context, blink::WebRTCPeerConnectionHandler* peerConnectionHandler, const String
& label, const blink::WebRTCDataChannelInit& init, ExceptionState& exceptionStat
e) |
62 { | 64 { |
63 OwnPtr<blink::WebRTCDataChannelHandler> handler = adoptPtr(peerConnectionHan
dler->createDataChannel(label, init)); | 65 OwnPtr<blink::WebRTCDataChannelHandler> handler = adoptPtr(peerConnectionHan
dler->createDataChannel(label, init)); |
64 if (!handler) { | 66 if (!handler) { |
65 exceptionState.throwDOMException(NotSupportedError, "RTCDataChannel is n
ot supported"); | 67 exceptionState.throwDOMException(NotSupportedError, "RTCDataChannel is n
ot supported"); |
66 return nullptr; | 68 return nullptr; |
67 } | 69 } |
68 return adoptRef(new RTCDataChannel(context, handler.release())); | 70 return adoptRefCountedWillBeRefCountedGarbageCollected(new RTCDataChannel(co
ntext, handler.release())); |
69 } | 71 } |
70 | 72 |
71 RTCDataChannel::RTCDataChannel(ExecutionContext* context, PassOwnPtr<blink::WebR
TCDataChannelHandler> handler) | 73 RTCDataChannel::RTCDataChannel(ExecutionContext* context, PassOwnPtr<blink::WebR
TCDataChannelHandler> handler) |
72 : m_executionContext(context) | 74 : m_executionContext(context) |
73 , m_handler(handler) | 75 , m_handler(handler) |
74 , m_stopped(false) | 76 , m_stopped(false) |
75 , m_readyState(ReadyStateConnecting) | 77 , m_readyState(ReadyStateConnecting) |
76 , m_binaryType(BinaryTypeArrayBuffer) | 78 , m_binaryType(BinaryTypeArrayBuffer) |
77 , m_scheduledEventTimer(this, &RTCDataChannel::scheduledEventTimerFired) | 79 , m_scheduledEventTimer(this, &RTCDataChannel::scheduledEventTimerFired) |
78 { | 80 { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 events.swap(m_scheduledEvents); | 310 events.swap(m_scheduledEvents); |
309 | 311 |
310 Vector<RefPtr<Event> >::iterator it = events.begin(); | 312 Vector<RefPtr<Event> >::iterator it = events.begin(); |
311 for (; it != events.end(); ++it) | 313 for (; it != events.end(); ++it) |
312 dispatchEvent((*it).release()); | 314 dispatchEvent((*it).release()); |
313 | 315 |
314 events.clear(); | 316 events.clear(); |
315 } | 317 } |
316 | 318 |
317 } // namespace WebCore | 319 } // namespace WebCore |
OLD | NEW |