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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 class Document; | 56 class Document; |
57 class WebSocketHandshakeRequest; | 57 class WebSocketHandshakeRequest; |
58 class WebSocketHandshakeRequestInfo; | 58 class WebSocketHandshakeRequestInfo; |
59 class WebSocketHandshakeResponseInfo; | 59 class WebSocketHandshakeResponseInfo; |
60 | 60 |
61 // This class is a WebSocketChannel subclass that works with a Document in a | 61 // This class is a WebSocketChannel subclass that works with a Document in a |
62 // DOMWindow (i.e. works in the main thread). | 62 // DOMWindow (i.e. works in the main thread). |
63 class MODULES_EXPORT DocumentWebSocketChannel final : public WebSocketChannel, p
ublic WebSocketHandleClient, public ContextLifecycleObserver { | 63 class MODULES_EXPORT DocumentWebSocketChannel final : public WebSocketChannel, p
ublic WebSocketHandleClient, public ContextLifecycleObserver { |
64 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DocumentWebSocketChannel); | 64 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DocumentWebSocketChannel); |
65 USING_PRE_FINALIZER(DocumentWebSocketChannel, handleShouldBeDisconnected); | |
66 public: | 65 public: |
67 // You can specify the source file and the line number information | 66 // You can specify the source file and the line number information |
68 // explicitly by passing the last parameter. | 67 // explicitly by passing the last parameter. |
69 // In the usual case, they are set automatically and you don't have to | 68 // In the usual case, they are set automatically and you don't have to |
70 // pass it. | 69 // pass it. |
71 // Specify handle explicitly only in tests. | 70 // Specify handle explicitly only in tests. |
72 static DocumentWebSocketChannel* create(Document* document, WebSocketChannel
Client* client, const String& sourceURL = String(), unsigned lineNumber = 0, Web
SocketHandle *handle = 0) | 71 static DocumentWebSocketChannel* create(Document* document, WebSocketChannel
Client* client, const String& sourceURL = String(), unsigned lineNumber = 0, Web
SocketHandle *handle = 0) |
73 { | 72 { |
74 return new DocumentWebSocketChannel(document, client, sourceURL, lineNum
ber, handle); | 73 return new DocumentWebSocketChannel(document, client, sourceURL, lineNum
ber, handle); |
75 } | 74 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 class BlobLoader; | 126 class BlobLoader; |
128 | 127 |
129 DocumentWebSocketChannel(Document*, WebSocketChannelClient*, const String&,
unsigned, WebSocketHandle*); | 128 DocumentWebSocketChannel(Document*, WebSocketChannelClient*, const String&,
unsigned, WebSocketHandle*); |
130 void sendInternal(WebSocketHandle::MessageType, const char* data, size_t tot
alSize, uint64_t* consumedBufferedAmount); | 129 void sendInternal(WebSocketHandle::MessageType, const char* data, size_t tot
alSize, uint64_t* consumedBufferedAmount); |
131 void processSendQueue(); | 130 void processSendQueue(); |
132 void flowControlIfNecessary(); | 131 void flowControlIfNecessary(); |
133 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_s
ourceURLAtConstruction, m_lineNumberAtConstruction); } | 132 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_s
ourceURLAtConstruction, m_lineNumberAtConstruction); } |
134 void abortAsyncOperations(); | 133 void abortAsyncOperations(); |
135 void handleDidClose(bool wasClean, unsigned short code, const String& reason
); | 134 void handleDidClose(bool wasClean, unsigned short code, const String& reason
); |
136 Document* document(); | 135 Document* document(); |
137 void handleShouldBeDisconnected(); | |
138 | 136 |
139 // WebSocketHandleClient functions. | 137 // WebSocketHandleClient functions. |
140 void didConnect(WebSocketHandle*, const WebString& selectedProtocol, const W
ebString& extensions) override; | 138 void didConnect(WebSocketHandle*, const WebString& selectedProtocol, const W
ebString& extensions) override; |
141 void didStartOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRequ
estInfo&) override; | 139 void didStartOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRequ
estInfo&) override; |
142 void didFinishOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRes
ponseInfo&) override; | 140 void didFinishOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRes
ponseInfo&) override; |
143 void didFail(WebSocketHandle*, const WebString& message) override; | 141 void didFail(WebSocketHandle*, const WebString& message) override; |
144 void didReceiveData(WebSocketHandle*, bool fin, WebSocketHandle::MessageType
, const char* data, size_t /* size */) override; | 142 void didReceiveData(WebSocketHandle*, bool fin, WebSocketHandle::MessageType
, const char* data, size_t /* size */) override; |
145 void didClose(WebSocketHandle*, bool wasClean, unsigned short code, const We
bString& reason) override; | 143 void didClose(WebSocketHandle*, bool wasClean, unsigned short code, const We
bString& reason) override; |
146 void didReceiveFlowControl(WebSocketHandle*, int64_t quota) override; | 144 void didReceiveFlowControl(WebSocketHandle*, int64_t quota) override; |
147 void didStartClosingHandshake(WebSocketHandle*) override; | 145 void didStartClosingHandshake(WebSocketHandle*) override; |
(...skipping 24 matching lines...) Expand all Loading... |
172 String m_sourceURLAtConstruction; | 170 String m_sourceURLAtConstruction; |
173 unsigned m_lineNumberAtConstruction; | 171 unsigned m_lineNumberAtConstruction; |
174 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; | 172 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; |
175 | 173 |
176 static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; | 174 static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; |
177 }; | 175 }; |
178 | 176 |
179 } // namespace blink | 177 } // namespace blink |
180 | 178 |
181 #endif // DocumentWebSocketChannel_h | 179 #endif // DocumentWebSocketChannel_h |
OLD | NEW |