| 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 19 matching lines...) Expand all Loading... |
| 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" | 35 #include "core/dom/ContextLifecycleObserver.h" |
| 36 #include "core/fileapi/Blob.h" | 36 #include "core/fileapi/Blob.h" |
| 37 #include "core/fileapi/FileError.h" | 37 #include "core/fileapi/FileError.h" |
| 38 #include "modules/ModulesExport.h" | 38 #include "modules/ModulesExport.h" |
| 39 #include "modules/websockets/WebSocketChannel.h" | 39 #include "modules/websockets/WebSocketChannel.h" |
| 40 #include "modules/websockets/WebSocketHandle.h" | |
| 41 #include "modules/websockets/WebSocketHandleClient.h" | |
| 42 #include "platform/heap/Handle.h" | 40 #include "platform/heap/Handle.h" |
| 43 #include "platform/weborigin/KURL.h" | 41 #include "platform/weborigin/KURL.h" |
| 42 #include "public/platform/modules/websockets/WebSocketHandle.h" |
| 43 #include "public/platform/modules/websockets/WebSocketHandleClient.h" |
| 44 #include "wtf/Deque.h" | 44 #include "wtf/Deque.h" |
| 45 #include "wtf/PassRefPtr.h" | 45 #include "wtf/PassRefPtr.h" |
| 46 #include "wtf/RefPtr.h" | 46 #include "wtf/RefPtr.h" |
| 47 #include "wtf/Vector.h" | 47 #include "wtf/Vector.h" |
| 48 #include "wtf/text/CString.h" | 48 #include "wtf/text/CString.h" |
| 49 #include "wtf/text/WTFString.h" | 49 #include "wtf/text/WTFString.h" |
| 50 #include <memory> | 50 #include <memory> |
| 51 #include <stdint.h> | 51 #include <stdint.h> |
| 52 | 52 |
| 53 namespace blink { | 53 namespace blink { |
| 54 | 54 |
| 55 class Document; | 55 class Document; |
| 56 class WebSocketHandshakeRequest; | 56 class WebSocketHandshakeRequest; |
| 57 class WebSocketHandshakeRequestInfo; |
| 58 class WebSocketHandshakeResponseInfo; |
| 57 | 59 |
| 58 // This class is a WebSocketChannel subclass that works with a Document in a | 60 // This class is a WebSocketChannel subclass that works with a Document in a |
| 59 // DOMWindow (i.e. works in the main thread). | 61 // DOMWindow (i.e. works in the main thread). |
| 60 class MODULES_EXPORT DocumentWebSocketChannel final : public WebSocketChannel, p
ublic WebSocketHandleClient, public ContextLifecycleObserver { | 62 class MODULES_EXPORT DocumentWebSocketChannel final : public WebSocketChannel, p
ublic WebSocketHandleClient, public ContextLifecycleObserver { |
| 61 USING_GARBAGE_COLLECTED_MIXIN(DocumentWebSocketChannel); | 63 USING_GARBAGE_COLLECTED_MIXIN(DocumentWebSocketChannel); |
| 62 public: | 64 public: |
| 63 // You can specify the source file and the line number information | 65 // You can specify the source file and the line number information |
| 64 // explicitly by passing the last parameter. | 66 // explicitly by passing the last parameter. |
| 65 // In the usual case, they are set automatically and you don't have to | 67 // In the usual case, they are set automatically and you don't have to |
| 66 // pass it. | 68 // pass it. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 DocumentWebSocketChannel(Document*, WebSocketChannelClient*, std::unique_ptr
<SourceLocation>, WebSocketHandle*); | 109 DocumentWebSocketChannel(Document*, WebSocketChannelClient*, std::unique_ptr
<SourceLocation>, WebSocketHandle*); |
| 108 void sendInternal(WebSocketHandle::MessageType, const char* data, size_t tot
alSize, uint64_t* consumedBufferedAmount); | 110 void sendInternal(WebSocketHandle::MessageType, const char* data, size_t tot
alSize, uint64_t* consumedBufferedAmount); |
| 109 void processSendQueue(); | 111 void processSendQueue(); |
| 110 void flowControlIfNecessary(); | 112 void flowControlIfNecessary(); |
| 111 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_l
ocationAtConstruction->clone()); } | 113 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_l
ocationAtConstruction->clone()); } |
| 112 void abortAsyncOperations(); | 114 void abortAsyncOperations(); |
| 113 void handleDidClose(bool wasClean, unsigned short code, const String& reason
); | 115 void handleDidClose(bool wasClean, unsigned short code, const String& reason
); |
| 114 Document* document(); | 116 Document* document(); |
| 115 | 117 |
| 116 // WebSocketHandleClient functions. | 118 // WebSocketHandleClient functions. |
| 117 void didConnect(WebSocketHandle*, const String& selectedProtocol, const Stri
ng& extensions) override; | 119 void didConnect(WebSocketHandle*, const WebString& selectedProtocol, const W
ebString& extensions) override; |
| 118 void didStartOpeningHandshake(WebSocketHandle*, PassRefPtr<WebSocketHandshak
eRequest>) override; | 120 void didStartOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRequ
estInfo&) override; |
| 119 void didFinishOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRes
ponse*) override; | 121 void didFinishOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRes
ponseInfo&) override; |
| 120 void didFail(WebSocketHandle*, const String& message) override; | 122 void didFail(WebSocketHandle*, const WebString& message) override; |
| 121 void didReceiveData(WebSocketHandle*, bool fin, WebSocketHandle::MessageType
, const char* data, size_t) override; | 123 void didReceiveData(WebSocketHandle*, bool fin, WebSocketHandle::MessageType
, const char* data, size_t /* size */) override; |
| 122 void didClose(WebSocketHandle*, bool wasClean, unsigned short code, const St
ring& reason) override; | 124 void didClose(WebSocketHandle*, bool wasClean, unsigned short code, const We
bString& reason) override; |
| 123 void didReceiveFlowControl(WebSocketHandle*, int64_t quota) override; | 125 void didReceiveFlowControl(WebSocketHandle*, int64_t quota) override; |
| 124 void didStartClosingHandshake(WebSocketHandle*) override; | 126 void didStartClosingHandshake(WebSocketHandle*) override; |
| 125 | 127 |
| 126 // Methods for BlobLoader. | 128 // Methods for BlobLoader. |
| 127 void didFinishLoadingBlob(DOMArrayBuffer*); | 129 void didFinishLoadingBlob(DOMArrayBuffer*); |
| 128 void didFailLoadingBlob(FileError::ErrorCode); | 130 void didFailLoadingBlob(FileError::ErrorCode); |
| 129 | 131 |
| 130 // m_handle is a handle of the connection. | 132 // m_handle is a handle of the connection. |
| 131 // m_handle == 0 means this channel is closed. | 133 // m_handle == 0 means this channel is closed. |
| 132 std::unique_ptr<WebSocketHandle> m_handle; | 134 std::unique_ptr<WebSocketHandle> m_handle; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 150 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; | 152 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; |
| 151 | 153 |
| 152 static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; | 154 static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; |
| 153 }; | 155 }; |
| 154 | 156 |
| 155 std::ostream& operator<<(std::ostream&, const DocumentWebSocketChannel*); | 157 std::ostream& operator<<(std::ostream&, const DocumentWebSocketChannel*); |
| 156 | 158 |
| 157 } // namespace blink | 159 } // namespace blink |
| 158 | 160 |
| 159 #endif // DocumentWebSocketChannel_h | 161 #endif // DocumentWebSocketChannel_h |
| OLD | NEW |