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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #include "base/gtest_prod_util.h" | 28 #include "base/gtest_prod_util.h" |
29 #include "bindings/core/v8/ActiveScriptWrappable.h" | 29 #include "bindings/core/v8/ActiveScriptWrappable.h" |
30 #include "core/dom/ActiveDOMObject.h" | 30 #include "core/dom/ActiveDOMObject.h" |
31 #include "modules/EventTargetModules.h" | 31 #include "modules/EventTargetModules.h" |
32 #include "platform/Timer.h" | 32 #include "platform/Timer.h" |
33 #include "platform/heap/Handle.h" | 33 #include "platform/heap/Handle.h" |
34 #include "public/platform/WebRTCDataChannelHandler.h" | 34 #include "public/platform/WebRTCDataChannelHandler.h" |
35 #include "public/platform/WebRTCDataChannelHandlerClient.h" | 35 #include "public/platform/WebRTCDataChannelHandlerClient.h" |
36 #include "wtf/Compiler.h" | 36 #include "wtf/Compiler.h" |
| 37 #include <memory> |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
39 | 40 |
40 class Blob; | 41 class Blob; |
41 class DOMArrayBuffer; | 42 class DOMArrayBuffer; |
42 class DOMArrayBufferView; | 43 class DOMArrayBufferView; |
43 class ExceptionState; | 44 class ExceptionState; |
44 class RTCPeerConnection; | 45 class RTCPeerConnection; |
45 class WebRTCDataChannelHandler; | 46 class WebRTCDataChannelHandler; |
46 class WebRTCPeerConnectionHandler; | 47 class WebRTCPeerConnectionHandler; |
47 struct WebRTCDataChannelInit; | 48 struct WebRTCDataChannelInit; |
48 | 49 |
49 class MODULES_EXPORT RTCDataChannel final | 50 class MODULES_EXPORT RTCDataChannel final |
50 : public EventTargetWithInlineData | 51 : public EventTargetWithInlineData |
51 , WTF_NON_EXPORTED_BASE(public WebRTCDataChannelHandlerClient) | 52 , WTF_NON_EXPORTED_BASE(public WebRTCDataChannelHandlerClient) |
52 , public ActiveScriptWrappable | 53 , public ActiveScriptWrappable |
53 , public ActiveDOMObject { | 54 , public ActiveDOMObject { |
54 USING_GARBAGE_COLLECTED_MIXIN(RTCDataChannel); | 55 USING_GARBAGE_COLLECTED_MIXIN(RTCDataChannel); |
55 DEFINE_WRAPPERTYPEINFO(); | 56 DEFINE_WRAPPERTYPEINFO(); |
56 USING_PRE_FINALIZER(RTCDataChannel, dispose); | 57 USING_PRE_FINALIZER(RTCDataChannel, dispose); |
57 public: | 58 public: |
58 static RTCDataChannel* create(ExecutionContext*, PassOwnPtr<WebRTCDataChanne
lHandler>); | 59 static RTCDataChannel* create(ExecutionContext*, std::unique_ptr<WebRTCDataC
hannelHandler>); |
59 static RTCDataChannel* create(ExecutionContext*, WebRTCPeerConnectionHandler
*, const String& label, const WebRTCDataChannelInit&, ExceptionState&); | 60 static RTCDataChannel* create(ExecutionContext*, WebRTCPeerConnectionHandler
*, const String& label, const WebRTCDataChannelInit&, ExceptionState&); |
60 ~RTCDataChannel() override; | 61 ~RTCDataChannel() override; |
61 | 62 |
62 ReadyState getHandlerState() const; | 63 ReadyState getHandlerState() const; |
63 | 64 |
64 String label() const; | 65 String label() const; |
65 | 66 |
66 // DEPRECATED | 67 // DEPRECATED |
67 bool reliable() const; | 68 bool reliable() const; |
68 | 69 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 DECLARE_VIRTUAL_TRACE(); | 110 DECLARE_VIRTUAL_TRACE(); |
110 | 111 |
111 // WebRTCDataChannelHandlerClient | 112 // WebRTCDataChannelHandlerClient |
112 void didChangeReadyState(WebRTCDataChannelHandlerClient::ReadyState) overrid
e; | 113 void didChangeReadyState(WebRTCDataChannelHandlerClient::ReadyState) overrid
e; |
113 void didDecreaseBufferedAmount(unsigned) override; | 114 void didDecreaseBufferedAmount(unsigned) override; |
114 void didReceiveStringData(const WebString&) override; | 115 void didReceiveStringData(const WebString&) override; |
115 void didReceiveRawData(const char*, size_t) override; | 116 void didReceiveRawData(const char*, size_t) override; |
116 void didDetectError() override; | 117 void didDetectError() override; |
117 | 118 |
118 private: | 119 private: |
119 RTCDataChannel(ExecutionContext*, PassOwnPtr<WebRTCDataChannelHandler>); | 120 RTCDataChannel(ExecutionContext*, std::unique_ptr<WebRTCDataChannelHandler>)
; |
120 void dispose(); | 121 void dispose(); |
121 | 122 |
122 void scheduleDispatchEvent(Event*); | 123 void scheduleDispatchEvent(Event*); |
123 void scheduledEventTimerFired(Timer<RTCDataChannel>*); | 124 void scheduledEventTimerFired(Timer<RTCDataChannel>*); |
124 | 125 |
125 OwnPtr<WebRTCDataChannelHandler> m_handler; | 126 std::unique_ptr<WebRTCDataChannelHandler> m_handler; |
126 | 127 |
127 WebRTCDataChannelHandlerClient::ReadyState m_readyState; | 128 WebRTCDataChannelHandlerClient::ReadyState m_readyState; |
128 | 129 |
129 enum BinaryType { | 130 enum BinaryType { |
130 BinaryTypeBlob, | 131 BinaryTypeBlob, |
131 BinaryTypeArrayBuffer | 132 BinaryTypeArrayBuffer |
132 }; | 133 }; |
133 BinaryType m_binaryType; | 134 BinaryType m_binaryType; |
134 | 135 |
135 Timer<RTCDataChannel> m_scheduledEventTimer; | 136 Timer<RTCDataChannel> m_scheduledEventTimer; |
136 HeapVector<Member<Event>> m_scheduledEvents; | 137 HeapVector<Member<Event>> m_scheduledEvents; |
137 | 138 |
138 unsigned m_bufferedAmountLowThreshold; | 139 unsigned m_bufferedAmountLowThreshold; |
139 | 140 |
140 bool m_stopped; | 141 bool m_stopped; |
141 | 142 |
142 FRIEND_TEST_ALL_PREFIXES(RTCDataChannelTest, BufferedAmountLow); | 143 FRIEND_TEST_ALL_PREFIXES(RTCDataChannelTest, BufferedAmountLow); |
143 }; | 144 }; |
144 | 145 |
145 } // namespace blink | 146 } // namespace blink |
146 | 147 |
147 #endif // RTCDataChannel_h | 148 #endif // RTCDataChannel_h |
OLD | NEW |