OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef DocumentWebSocketChannel_h | 31 #ifndef DocumentWebSocketChannel_h |
32 #define DocumentWebSocketChannel_h | 32 #define DocumentWebSocketChannel_h |
33 | 33 |
34 #include "bindings/core/v8/SourceLocation.h" | 34 #include "bindings/core/v8/SourceLocation.h" |
35 #include "core/dom/ContextLifecycleObserver.h" | |
36 #include "core/fileapi/Blob.h" | 35 #include "core/fileapi/Blob.h" |
37 #include "core/fileapi/FileError.h" | 36 #include "core/fileapi/FileError.h" |
38 #include "modules/ModulesExport.h" | 37 #include "modules/ModulesExport.h" |
39 #include "modules/websockets/WebSocketChannel.h" | 38 #include "modules/websockets/WebSocketChannel.h" |
40 #include "modules/websockets/WebSocketHandle.h" | 39 #include "modules/websockets/WebSocketHandle.h" |
41 #include "modules/websockets/WebSocketHandleClient.h" | 40 #include "modules/websockets/WebSocketHandleClient.h" |
42 #include "platform/heap/Handle.h" | 41 #include "platform/heap/Handle.h" |
43 #include "platform/weborigin/KURL.h" | 42 #include "platform/weborigin/KURL.h" |
44 #include "wtf/Deque.h" | 43 #include "wtf/Deque.h" |
45 #include "wtf/PassRefPtr.h" | 44 #include "wtf/PassRefPtr.h" |
46 #include "wtf/RefPtr.h" | 45 #include "wtf/RefPtr.h" |
47 #include "wtf/Vector.h" | 46 #include "wtf/Vector.h" |
48 #include "wtf/text/CString.h" | 47 #include "wtf/text/CString.h" |
49 #include "wtf/text/WTFString.h" | 48 #include "wtf/text/WTFString.h" |
50 #include <memory> | 49 #include <memory> |
51 #include <stdint.h> | 50 #include <stdint.h> |
52 | 51 |
53 namespace blink { | 52 namespace blink { |
54 | 53 |
55 class Document; | 54 class Document; |
56 class WebSocketHandshakeRequest; | 55 class WebSocketHandshakeRequest; |
57 | 56 |
58 // This class is a WebSocketChannel subclass that works with a Document in a | 57 // This class is a WebSocketChannel subclass that works with a Document in a |
59 // DOMWindow (i.e. works in the main thread). | 58 // DOMWindow (i.e. works in the main thread). |
60 class MODULES_EXPORT DocumentWebSocketChannel final | 59 class MODULES_EXPORT DocumentWebSocketChannel final |
61 : public WebSocketChannel, | 60 : public WebSocketChannel, |
62 public WebSocketHandleClient, | 61 public WebSocketHandleClient { |
63 public ContextLifecycleObserver { | |
64 USING_GARBAGE_COLLECTED_MIXIN(DocumentWebSocketChannel); | |
65 | |
66 public: | 62 public: |
67 // You can specify the source file and the line number information | 63 // You can specify the source file and the line number information |
68 // explicitly by passing the last parameter. | 64 // explicitly by passing the last parameter. |
69 // In the usual case, they are set automatically and you don't have to | 65 // In the usual case, they are set automatically and you don't have to |
70 // pass it. | 66 // pass it. |
71 // Specify handle explicitly only in tests. | 67 // Specify handle explicitly only in tests. |
72 static DocumentWebSocketChannel* create( | 68 static DocumentWebSocketChannel* create( |
73 Document* document, | 69 Document* document, |
74 WebSocketChannelClient* client, | 70 WebSocketChannelClient* client, |
75 std::unique_ptr<SourceLocation> location, | 71 std::unique_ptr<SourceLocation> location, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 160 |
165 // m_client can be deleted while this channel is alive, but this class | 161 // m_client can be deleted while this channel is alive, but this class |
166 // expects that disconnect() is called before the deletion. | 162 // expects that disconnect() is called before the deletion. |
167 Member<WebSocketChannelClient> m_client; | 163 Member<WebSocketChannelClient> m_client; |
168 KURL m_url; | 164 KURL m_url; |
169 // m_identifier > 0 means calling scriptContextExecution() returns a Document. | 165 // m_identifier > 0 means calling scriptContextExecution() returns a Document. |
170 unsigned long m_identifier; | 166 unsigned long m_identifier; |
171 Member<BlobLoader> m_blobLoader; | 167 Member<BlobLoader> m_blobLoader; |
172 HeapDeque<Member<Message>> m_messages; | 168 HeapDeque<Member<Message>> m_messages; |
173 Vector<char> m_receivingMessageData; | 169 Vector<char> m_receivingMessageData; |
| 170 Member<Document> m_document; |
174 | 171 |
175 bool m_receivingMessageTypeIsText; | 172 bool m_receivingMessageTypeIsText; |
176 uint64_t m_sendingQuota; | 173 uint64_t m_sendingQuota; |
177 uint64_t m_receivedDataSizeForFlowControl; | 174 uint64_t m_receivedDataSizeForFlowControl; |
178 size_t m_sentSizeOfTopMessage; | 175 size_t m_sentSizeOfTopMessage; |
179 | 176 |
180 std::unique_ptr<SourceLocation> m_locationAtConstruction; | 177 std::unique_ptr<SourceLocation> m_locationAtConstruction; |
181 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; | 178 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; |
182 | 179 |
183 static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; | 180 static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; |
184 }; | 181 }; |
185 | 182 |
186 std::ostream& operator<<(std::ostream&, const DocumentWebSocketChannel*); | 183 std::ostream& operator<<(std::ostream&, const DocumentWebSocketChannel*); |
187 | 184 |
188 } // namespace blink | 185 } // namespace blink |
189 | 186 |
190 #endif // DocumentWebSocketChannel_h | 187 #endif // DocumentWebSocketChannel_h |
OLD | NEW |