| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 OwnPtr<Vector<char>> vectorData; | 116 OwnPtr<Vector<char>> vectorData; |
| 117 unsigned short code; | 117 unsigned short code; |
| 118 String reason; | 118 String reason; |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 struct ReceivedMessage { | 121 struct ReceivedMessage { |
| 122 bool isMessageText; | 122 bool isMessageText; |
| 123 Vector<char> data; | 123 Vector<char> data; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 class BlobLoader; | |
| 127 | |
| 128 DocumentWebSocketChannel(Document*, WebSocketChannelClient*, const String&,
unsigned, WebSocketHandle*); | 126 DocumentWebSocketChannel(Document*, WebSocketChannelClient*, const String&,
unsigned, WebSocketHandle*); |
| 129 void sendInternal(WebSocketHandle::MessageType, const char* data, size_t tot
alSize, uint64_t* consumedBufferedAmount); | 127 void sendInternal(WebSocketHandle::MessageType, const char* data, size_t tot
alSize, uint64_t* consumedBufferedAmount); |
| 128 void sendBlob(const BlobDataHandle&); |
| 130 void processSendQueue(); | 129 void processSendQueue(); |
| 131 void flowControlIfNecessary(); | 130 void flowControlIfNecessary(); |
| 132 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_s
ourceURLAtConstruction, m_lineNumberAtConstruction); } | 131 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_s
ourceURLAtConstruction, m_lineNumberAtConstruction); } |
| 133 void abortAsyncOperations(); | |
| 134 void handleDidClose(bool wasClean, unsigned short code, const String& reason
); | 132 void handleDidClose(bool wasClean, unsigned short code, const String& reason
); |
| 135 Document* document(); | 133 Document* document(); |
| 136 | 134 |
| 137 // WebSocketHandleClient functions. | 135 // WebSocketHandleClient functions. |
| 138 void didConnect(WebSocketHandle*, const WebString& selectedProtocol, const W
ebString& extensions) override; | 136 void didConnect(WebSocketHandle*, const WebString& selectedProtocol, const W
ebString& extensions) override; |
| 139 void didStartOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRequ
estInfo&) override; | 137 void didStartOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRequ
estInfo&) override; |
| 140 void didFinishOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRes
ponseInfo&) override; | 138 void didFinishOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRes
ponseInfo&) override; |
| 141 void didFail(WebSocketHandle*, const WebString& message) override; | 139 void didFail(WebSocketHandle*, const WebString& message) override; |
| 142 void didReceiveData(WebSocketHandle*, bool fin, WebSocketHandle::MessageType
, const char* data, size_t /* size */) override; | 140 void didReceiveData(WebSocketHandle*, bool fin, WebSocketHandle::MessageType
, const char* data, size_t /* size */) override; |
| 143 void didClose(WebSocketHandle*, bool wasClean, unsigned short code, const We
bString& reason) override; | 141 void didClose(WebSocketHandle*, bool wasClean, unsigned short code, const We
bString& reason) override; |
| 144 void didReceiveFlowControl(WebSocketHandle*, int64_t quota) override; | 142 void didReceiveFlowControl(WebSocketHandle*, int64_t quota) override; |
| 145 void didStartClosingHandshake(WebSocketHandle*) override; | 143 void didStartClosingHandshake(WebSocketHandle*) override; |
| 146 | 144 void didCompleteSendingBlob(WebSocketHandle*) override; |
| 147 // Methods for BlobLoader. | |
| 148 void didFinishLoadingBlob(PassRefPtr<DOMArrayBuffer>); | |
| 149 void didFailLoadingBlob(FileError::ErrorCode); | |
| 150 | 145 |
| 151 // m_handle is a handle of the connection. | 146 // m_handle is a handle of the connection. |
| 152 // m_handle == 0 means this channel is closed. | 147 // m_handle == 0 means this channel is closed. |
| 153 OwnPtr<WebSocketHandle> m_handle; | 148 OwnPtr<WebSocketHandle> m_handle; |
| 154 | 149 |
| 155 // m_client can be deleted while this channel is alive, but this class | 150 // m_client can be deleted while this channel is alive, but this class |
| 156 // expects that disconnect() is called before the deletion. | 151 // expects that disconnect() is called before the deletion. |
| 157 Member<WebSocketChannelClient> m_client; | 152 Member<WebSocketChannelClient> m_client; |
| 158 KURL m_url; | 153 KURL m_url; |
| 159 // m_identifier > 0 means calling scriptContextExecution() returns a Documen
t. | 154 // m_identifier > 0 means calling scriptContextExecution() returns a Documen
t. |
| 160 unsigned long m_identifier; | 155 unsigned long m_identifier; |
| 161 Member<BlobLoader> m_blobLoader; | 156 bool m_blobLoadingMode; |
| 157 uint64_t m_blobDataPending; |
| 162 Deque<OwnPtr<Message>> m_messages; | 158 Deque<OwnPtr<Message>> m_messages; |
| 163 Vector<char> m_receivingMessageData; | 159 Vector<char> m_receivingMessageData; |
| 164 | 160 |
| 165 bool m_receivingMessageTypeIsText; | 161 bool m_receivingMessageTypeIsText; |
| 166 uint64_t m_sendingQuota; | 162 uint64_t m_sendingQuota; |
| 167 uint64_t m_receivedDataSizeForFlowControl; | 163 uint64_t m_receivedDataSizeForFlowControl; |
| 168 size_t m_sentSizeOfTopMessage; | 164 size_t m_sentSizeOfTopMessage; |
| 169 | 165 |
| 170 String m_sourceURLAtConstruction; | 166 String m_sourceURLAtConstruction; |
| 171 unsigned m_lineNumberAtConstruction; | 167 unsigned m_lineNumberAtConstruction; |
| 172 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; | 168 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; |
| 173 | 169 |
| 174 static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; | 170 static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; |
| 175 }; | 171 }; |
| 176 | 172 |
| 177 } // namespace blink | 173 } // namespace blink |
| 178 | 174 |
| 179 #endif // DocumentWebSocketChannel_h | 175 #endif // DocumentWebSocketChannel_h |
| OLD | NEW |