| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | |
| 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | |
| 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 23 */ | |
| 24 | |
| 25 #ifndef RTCDataChannel_h | |
| 26 #define RTCDataChannel_h | |
| 27 | |
| 28 #include "base/gtest_prod_util.h" | |
| 29 #include "bindings/core/v8/ActiveScriptWrappable.h" | |
| 30 #include "core/dom/ActiveDOMObject.h" | |
| 31 #include "modules/EventTargetModules.h" | |
| 32 #include "platform/Timer.h" | |
| 33 #include "platform/heap/Handle.h" | |
| 34 #include "public/platform/WebRTCDataChannelHandler.h" | |
| 35 #include "public/platform/WebRTCDataChannelHandlerClient.h" | |
| 36 #include "wtf/Compiler.h" | |
| 37 #include <memory> | |
| 38 | |
| 39 namespace blink { | |
| 40 | |
| 41 class Blob; | |
| 42 class DOMArrayBuffer; | |
| 43 class DOMArrayBufferView; | |
| 44 class ExceptionState; | |
| 45 class RTCPeerConnection; | |
| 46 class WebRTCDataChannelHandler; | |
| 47 class WebRTCPeerConnectionHandler; | |
| 48 struct WebRTCDataChannelInit; | |
| 49 | |
| 50 class MODULES_EXPORT RTCDataChannel final | |
| 51 : public EventTargetWithInlineData | |
| 52 , WTF_NON_EXPORTED_BASE(public WebRTCDataChannelHandlerClient) | |
| 53 , public ActiveScriptWrappable | |
| 54 , public ActiveDOMObject { | |
| 55 USING_GARBAGE_COLLECTED_MIXIN(RTCDataChannel); | |
| 56 DEFINE_WRAPPERTYPEINFO(); | |
| 57 USING_PRE_FINALIZER(RTCDataChannel, dispose); | |
| 58 public: | |
| 59 static RTCDataChannel* create(ExecutionContext*, std::unique_ptr<WebRTCDataC
hannelHandler>); | |
| 60 static RTCDataChannel* create(ExecutionContext*, WebRTCPeerConnectionHandler
*, const String& label, const WebRTCDataChannelInit&, ExceptionState&); | |
| 61 ~RTCDataChannel() override; | |
| 62 | |
| 63 ReadyState getHandlerState() const; | |
| 64 | |
| 65 String label() const; | |
| 66 | |
| 67 // DEPRECATED | |
| 68 bool reliable() const; | |
| 69 | |
| 70 bool ordered() const; | |
| 71 unsigned short maxRetransmitTime() const; | |
| 72 unsigned short maxRetransmits() const; | |
| 73 String protocol() const; | |
| 74 bool negotiated() const; | |
| 75 unsigned short id() const; | |
| 76 String readyState() const; | |
| 77 unsigned bufferedAmount() const; | |
| 78 | |
| 79 unsigned bufferedAmountLowThreshold() const; | |
| 80 void setBufferedAmountLowThreshold(unsigned); | |
| 81 | |
| 82 String binaryType() const; | |
| 83 void setBinaryType(const String&, ExceptionState&); | |
| 84 | |
| 85 void send(const String&, ExceptionState&); | |
| 86 void send(DOMArrayBuffer*, ExceptionState&); | |
| 87 void send(DOMArrayBufferView*, ExceptionState&); | |
| 88 void send(Blob*, ExceptionState&); | |
| 89 | |
| 90 void close(); | |
| 91 | |
| 92 DEFINE_ATTRIBUTE_EVENT_LISTENER(open); | |
| 93 DEFINE_ATTRIBUTE_EVENT_LISTENER(bufferedamountlow); | |
| 94 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | |
| 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); | |
| 96 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | |
| 97 | |
| 98 // EventTarget | |
| 99 const AtomicString& interfaceName() const override; | |
| 100 ExecutionContext* getExecutionContext() const override; | |
| 101 | |
| 102 // ActiveDOMObject | |
| 103 void suspend() override; | |
| 104 void resume() override; | |
| 105 void stop() override; | |
| 106 | |
| 107 // ActiveScriptWrappable | |
| 108 bool hasPendingActivity() const override; | |
| 109 | |
| 110 DECLARE_VIRTUAL_TRACE(); | |
| 111 | |
| 112 // WebRTCDataChannelHandlerClient | |
| 113 void didChangeReadyState(WebRTCDataChannelHandlerClient::ReadyState) overrid
e; | |
| 114 void didDecreaseBufferedAmount(unsigned) override; | |
| 115 void didReceiveStringData(const WebString&) override; | |
| 116 void didReceiveRawData(const char*, size_t) override; | |
| 117 void didDetectError() override; | |
| 118 | |
| 119 private: | |
| 120 RTCDataChannel(ExecutionContext*, std::unique_ptr<WebRTCDataChannelHandler>)
; | |
| 121 void dispose(); | |
| 122 | |
| 123 void scheduleDispatchEvent(Event*); | |
| 124 void scheduledEventTimerFired(Timer<RTCDataChannel>*); | |
| 125 | |
| 126 std::unique_ptr<WebRTCDataChannelHandler> m_handler; | |
| 127 | |
| 128 WebRTCDataChannelHandlerClient::ReadyState m_readyState; | |
| 129 | |
| 130 enum BinaryType { | |
| 131 BinaryTypeBlob, | |
| 132 BinaryTypeArrayBuffer | |
| 133 }; | |
| 134 BinaryType m_binaryType; | |
| 135 | |
| 136 Timer<RTCDataChannel> m_scheduledEventTimer; | |
| 137 HeapVector<Member<Event>> m_scheduledEvents; | |
| 138 | |
| 139 unsigned m_bufferedAmountLowThreshold; | |
| 140 | |
| 141 bool m_stopped; | |
| 142 | |
| 143 FRIEND_TEST_ALL_PREFIXES(RTCDataChannelTest, BufferedAmountLow); | |
| 144 }; | |
| 145 | |
| 146 } // namespace blink | |
| 147 | |
| 148 #endif // RTCDataChannel_h | |
| OLD | NEW |