| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "wtf/RefPtr.h" | 48 #include "wtf/RefPtr.h" |
| 49 #include "wtf/Vector.h" | 49 #include "wtf/Vector.h" |
| 50 #include "wtf/text/CString.h" | 50 #include "wtf/text/CString.h" |
| 51 #include "wtf/text/WTFString.h" | 51 #include "wtf/text/WTFString.h" |
| 52 | 52 |
| 53 namespace WebCore { | 53 namespace WebCore { |
| 54 | 54 |
| 55 class Document; | 55 class Document; |
| 56 | 56 |
| 57 // This class may replace MainThreadWebSocketChannel. | 57 // This class may replace MainThreadWebSocketChannel. |
| 58 class NewWebSocketChannelImpl : public WebSocketChannel, public RefCounted<NewWe
bSocketChannelImpl>, public WebKit::WebSocketHandleClient, public ContextLifecyc
leObserver { | 58 class NewWebSocketChannelImpl : public WebSocketChannel, public RefCounted<NewWe
bSocketChannelImpl>, public blink::WebSocketHandleClient, public ContextLifecycl
eObserver { |
| 59 WTF_MAKE_FAST_ALLOCATED; | 59 WTF_MAKE_FAST_ALLOCATED; |
| 60 public: | 60 public: |
| 61 // You can specify the source file and the line number information | 61 // You can specify the source file and the line number information |
| 62 // explicitly by passing the last parameter. | 62 // explicitly by passing the last parameter. |
| 63 // In the usual case, they are set automatically and you don't have to | 63 // In the usual case, they are set automatically and you don't have to |
| 64 // pass it. | 64 // pass it. |
| 65 static PassRefPtr<NewWebSocketChannelImpl> create(ExecutionContext* context,
WebSocketChannelClient* client, const String& sourceURL = String(), unsigned li
neNumber = 0) | 65 static PassRefPtr<NewWebSocketChannelImpl> create(ExecutionContext* context,
WebSocketChannelClient* client, const String& sourceURL = String(), unsigned li
neNumber = 0) |
| 66 { | 66 { |
| 67 return adoptRef(new NewWebSocketChannelImpl(context, client, sourceURL,
lineNumber)); | 67 return adoptRef(new NewWebSocketChannelImpl(context, client, sourceURL,
lineNumber)); |
| 68 } | 68 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 NewWebSocketChannelImpl(ExecutionContext*, WebSocketChannelClient*, const St
ring&, unsigned); | 116 NewWebSocketChannelImpl(ExecutionContext*, WebSocketChannelClient*, const St
ring&, unsigned); |
| 117 void sendInternal(); | 117 void sendInternal(); |
| 118 void flowControlIfNecessary(); | 118 void flowControlIfNecessary(); |
| 119 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_s
ourceURLAtConnection, m_lineNumberAtConnection); } | 119 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_s
ourceURLAtConnection, m_lineNumberAtConnection); } |
| 120 void abortAsyncOperations(); | 120 void abortAsyncOperations(); |
| 121 void handleDidClose(unsigned short code, const String& reason); | 121 void handleDidClose(unsigned short code, const String& reason); |
| 122 Document* document(); // can be called only when m_identifier > 0. | 122 Document* document(); // can be called only when m_identifier > 0. |
| 123 | 123 |
| 124 // WebSocketHandleClient functions. | 124 // WebSocketHandleClient functions. |
| 125 virtual void didConnect(WebKit::WebSocketHandle*, bool fail, const WebKit::W
ebString& selectedProtocol, const WebKit::WebString& extensions) OVERRIDE; | 125 virtual void didConnect(blink::WebSocketHandle*, bool fail, const blink::Web
String& selectedProtocol, const blink::WebString& extensions) OVERRIDE; |
| 126 virtual void didFail(WebKit::WebSocketHandle*, const WebKit::WebString& mess
age) OVERRIDE; | 126 virtual void didFail(blink::WebSocketHandle*, const blink::WebString& messag
e) OVERRIDE; |
| 127 virtual void didReceiveData(WebKit::WebSocketHandle*, bool fin, WebKit::WebS
ocketHandle::MessageType, const char* data, size_t /* size */) OVERRIDE; | 127 virtual void didReceiveData(blink::WebSocketHandle*, bool fin, blink::WebSoc
ketHandle::MessageType, const char* data, size_t /* size */) OVERRIDE; |
| 128 virtual void didClose(WebKit::WebSocketHandle*, bool wasClean, unsigned shor
t code, const WebKit::WebString& reason) OVERRIDE; | 128 virtual void didClose(blink::WebSocketHandle*, bool wasClean, unsigned short
code, const blink::WebString& reason) OVERRIDE; |
| 129 virtual void didReceiveFlowControl(WebKit::WebSocketHandle*, int64_t quota)
OVERRIDE; | 129 virtual void didReceiveFlowControl(blink::WebSocketHandle*, int64_t quota) O
VERRIDE; |
| 130 | 130 |
| 131 // Methods for BlobLoader. | 131 // Methods for BlobLoader. |
| 132 void didFinishLoadingBlob(PassRefPtr<ArrayBuffer>); | 132 void didFinishLoadingBlob(PassRefPtr<ArrayBuffer>); |
| 133 void didFailLoadingBlob(FileError::ErrorCode); | 133 void didFailLoadingBlob(FileError::ErrorCode); |
| 134 | 134 |
| 135 // WebSocketChannel functions. | 135 // WebSocketChannel functions. |
| 136 virtual void refWebSocketChannel() OVERRIDE { ref(); } | 136 virtual void refWebSocketChannel() OVERRIDE { ref(); } |
| 137 virtual void derefWebSocketChannel() OVERRIDE { deref(); } | 137 virtual void derefWebSocketChannel() OVERRIDE { deref(); } |
| 138 | 138 |
| 139 // LifecycleObserver functions. | 139 // LifecycleObserver functions. |
| 140 // This object must be destroyed before the context. | 140 // This object must be destroyed before the context. |
| 141 virtual void contextDestroyed() OVERRIDE { ASSERT_NOT_REACHED(); } | 141 virtual void contextDestroyed() OVERRIDE { ASSERT_NOT_REACHED(); } |
| 142 | 142 |
| 143 // m_handle is a handle of the connection. | 143 // m_handle is a handle of the connection. |
| 144 // m_handle == 0 means this channel is closed. | 144 // m_handle == 0 means this channel is closed. |
| 145 OwnPtr<WebKit::WebSocketHandle> m_handle; | 145 OwnPtr<blink::WebSocketHandle> m_handle; |
| 146 | 146 |
| 147 // m_client can be deleted while this channel is alive, but this class | 147 // m_client can be deleted while this channel is alive, but this class |
| 148 // expects that disconnect() is called before the deletion. | 148 // expects that disconnect() is called before the deletion. |
| 149 WebSocketChannelClient* m_client; | 149 WebSocketChannelClient* m_client; |
| 150 KURL m_url; | 150 KURL m_url; |
| 151 // m_identifier > 0 means calling scriptContextExecution() returns a Documen
t. | 151 // m_identifier > 0 means calling scriptContextExecution() returns a Documen
t. |
| 152 unsigned long m_identifier; | 152 unsigned long m_identifier; |
| 153 OwnPtr<BlobLoader> m_blobLoader; | 153 OwnPtr<BlobLoader> m_blobLoader; |
| 154 Deque<Message> m_messages; | 154 Deque<Message> m_messages; |
| 155 Vector<char> m_receivingMessageData; | 155 Vector<char> m_receivingMessageData; |
| 156 | 156 |
| 157 bool m_receivingMessageTypeIsText; | 157 bool m_receivingMessageTypeIsText; |
| 158 int64_t m_sendingQuota; | 158 int64_t m_sendingQuota; |
| 159 int64_t m_receivedDataSizeForFlowControl; | 159 int64_t m_receivedDataSizeForFlowControl; |
| 160 unsigned long m_bufferedAmount; | 160 unsigned long m_bufferedAmount; |
| 161 size_t m_sentSizeOfTopMessage; | 161 size_t m_sentSizeOfTopMessage; |
| 162 String m_subprotocol; | 162 String m_subprotocol; |
| 163 String m_extensions; | 163 String m_extensions; |
| 164 | 164 |
| 165 String m_sourceURLAtConnection; | 165 String m_sourceURLAtConnection; |
| 166 unsigned m_lineNumberAtConnection; | 166 unsigned m_lineNumberAtConnection; |
| 167 | 167 |
| 168 static const int64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; | 168 static const int64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 } // namespace WebCore | 171 } // namespace WebCore |
| 172 | 172 |
| 173 #endif // NewWebSocketChannelImpl_h | 173 #endif // NewWebSocketChannelImpl_h |
| OLD | NEW |