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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 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 | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 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 | 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 | 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 */ | 23 */ |
24 | 24 |
25 #ifndef RTCDataChannel_h | 25 #ifndef RTCDataChannel_h |
26 #define RTCDataChannel_h | 26 #define RTCDataChannel_h |
27 | 27 |
28 #include "bindings/v8/ScriptWrappable.h" | 28 #include "bindings/v8/ScriptWrappable.h" |
29 #include "core/events/EventTarget.h" | 29 #include "core/events/EventTarget.h" |
| 30 #include "core/fileapi/FileError.h" |
| 31 #include "core/fileapi/FileReaderLoaderClient.h" |
30 #include "platform/Timer.h" | 32 #include "platform/Timer.h" |
31 #include "platform/heap/Handle.h" | 33 #include "platform/heap/Handle.h" |
32 #include "public/platform/WebRTCDataChannelHandler.h" | 34 #include "public/platform/WebRTCDataChannelHandler.h" |
33 #include "public/platform/WebRTCDataChannelHandlerClient.h" | 35 #include "public/platform/WebRTCDataChannelHandlerClient.h" |
| 36 #include "wtf/Deque.h" |
34 #include "wtf/RefCounted.h" | 37 #include "wtf/RefCounted.h" |
35 | 38 |
36 namespace blink { | 39 namespace blink { |
37 class WebRTCDataChannelHandler; | 40 class WebRTCDataChannelHandler; |
38 class WebRTCPeerConnectionHandler; | 41 class WebRTCPeerConnectionHandler; |
39 struct WebRTCDataChannelInit; | 42 struct WebRTCDataChannelInit; |
40 } | 43 } |
41 | 44 |
42 namespace WebCore { | 45 namespace WebCore { |
43 | 46 |
44 class Blob; | 47 class Blob; |
| 48 class BlobDataHandle; |
45 class ExceptionState; | 49 class ExceptionState; |
| 50 class FileReaderLoader; |
46 | 51 |
47 class RTCDataChannel FINAL : public RefCounted<RTCDataChannel>, public ScriptWra
ppable, public EventTargetWithInlineData, public blink::WebRTCDataChannelHandler
Client { | 52 class RTCDataChannel FINAL : public RefCounted<RTCDataChannel>, public ScriptWra
ppable, public EventTargetWithInlineData, public blink::WebRTCDataChannelHandler
Client, public FileReaderLoaderClient { |
48 REFCOUNTED_EVENT_TARGET(RTCDataChannel); | 53 REFCOUNTED_EVENT_TARGET(RTCDataChannel); |
49 public: | 54 public: |
50 static PassRefPtr<RTCDataChannel> create(ExecutionContext*, PassOwnPtr<blink
::WebRTCDataChannelHandler>); | 55 static PassRefPtr<RTCDataChannel> create(ExecutionContext*, PassOwnPtr<blink
::WebRTCDataChannelHandler>); |
51 static PassRefPtr<RTCDataChannel> create(ExecutionContext*, blink::WebRTCPee
rConnectionHandler*, const String& label, const blink::WebRTCDataChannelInit&, E
xceptionState&); | 56 static PassRefPtr<RTCDataChannel> create(ExecutionContext*, blink::WebRTCPee
rConnectionHandler*, const String& label, const blink::WebRTCDataChannelInit&, E
xceptionState&); |
52 virtual ~RTCDataChannel(); | 57 virtual ~RTCDataChannel(); |
53 | 58 |
54 String label() const; | 59 String label() const; |
55 | 60 |
56 // DEPRECATED | 61 // DEPRECATED |
57 bool reliable() const; | 62 bool reliable() const; |
(...skipping 21 matching lines...) Expand all Loading... |
79 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 84 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
80 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); | 85 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); |
81 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 86 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
82 | 87 |
83 void stop(); | 88 void stop(); |
84 | 89 |
85 // EventTarget | 90 // EventTarget |
86 virtual const AtomicString& interfaceName() const OVERRIDE; | 91 virtual const AtomicString& interfaceName() const OVERRIDE; |
87 virtual ExecutionContext* executionContext() const OVERRIDE; | 92 virtual ExecutionContext* executionContext() const OVERRIDE; |
88 | 93 |
| 94 // FileReaderLoaderClient functions. |
| 95 virtual void didStartLoading() OVERRIDE; |
| 96 virtual void didReceiveData() OVERRIDE; |
| 97 virtual void didFinishLoading() OVERRIDE; |
| 98 virtual void didFail(FileError::ErrorCode) OVERRIDE; |
| 99 |
89 private: | 100 private: |
90 RTCDataChannel(ExecutionContext*, PassOwnPtr<blink::WebRTCDataChannelHandler
>); | 101 RTCDataChannel(ExecutionContext*, PassOwnPtr<blink::WebRTCDataChannelHandler
>); |
91 | 102 |
92 void scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event>); | 103 void scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event>); |
93 void scheduledEventTimerFired(Timer<RTCDataChannel>*); | 104 void scheduledEventTimerFired(Timer<RTCDataChannel>*); |
94 | 105 |
| 106 void processOutgoingBlobQueue(); |
| 107 |
95 ExecutionContext* m_executionContext; | 108 ExecutionContext* m_executionContext; |
96 | 109 |
97 // blink::WebRTCDataChannelHandlerClient | 110 // blink::WebRTCDataChannelHandlerClient |
98 virtual void didChangeReadyState(blink::WebRTCDataChannelHandlerClient::Read
yState) OVERRIDE; | 111 virtual void didChangeReadyState(blink::WebRTCDataChannelHandlerClient::Read
yState) OVERRIDE; |
99 virtual void didReceiveStringData(const blink::WebString&) OVERRIDE; | 112 virtual void didReceiveStringData(const blink::WebString&) OVERRIDE; |
100 virtual void didReceiveRawData(const char*, size_t) OVERRIDE; | 113 virtual void didReceiveRawData(const char*, size_t) OVERRIDE; |
101 virtual void didDetectError() OVERRIDE; | 114 virtual void didDetectError() OVERRIDE; |
102 | 115 |
103 OwnPtr<blink::WebRTCDataChannelHandler> m_handler; | 116 OwnPtr<blink::WebRTCDataChannelHandler> m_handler; |
104 | 117 |
105 bool m_stopped; | 118 bool m_stopped; |
106 | 119 |
107 blink::WebRTCDataChannelHandlerClient::ReadyState m_readyState; | 120 blink::WebRTCDataChannelHandlerClient::ReadyState m_readyState; |
108 | 121 |
109 enum BinaryType { | 122 enum BinaryType { |
110 BinaryTypeBlob, | 123 BinaryTypeBlob, |
111 BinaryTypeArrayBuffer | 124 BinaryTypeArrayBuffer |
112 }; | 125 }; |
113 BinaryType m_binaryType; | 126 BinaryType m_binaryType; |
114 | 127 |
| 128 enum BlobLoaderStatus { |
| 129 BlobLoaderNotStarted, |
| 130 BlobLoaderStarted, |
| 131 BlobLoaderFinished, |
| 132 BlobLoaderFailed |
| 133 }; |
| 134 OwnPtr<FileReaderLoader> m_blobLoader; |
| 135 Deque<RefPtr<BlobDataHandle> > m_outgoingBlobQueue; |
| 136 BlobLoaderStatus m_blobLoaderStatus; |
| 137 |
115 Timer<RTCDataChannel> m_scheduledEventTimer; | 138 Timer<RTCDataChannel> m_scheduledEventTimer; |
116 WillBePersistentHeapVector<RefPtrWillBeMember<Event> > m_scheduledEvents; | 139 WillBePersistentHeapVector<RefPtrWillBeMember<Event> > m_scheduledEvents; |
117 }; | 140 }; |
118 | 141 |
119 } // namespace WebCore | 142 } // namespace WebCore |
120 | 143 |
121 #endif // RTCDataChannel_h | 144 #endif // RTCDataChannel_h |
OLD | NEW |