| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "wtf/Forward.h" | 43 #include "wtf/Forward.h" |
| 44 #include "wtf/OwnPtr.h" | 44 #include "wtf/OwnPtr.h" |
| 45 #include "wtf/RefCounted.h" | 45 #include "wtf/RefCounted.h" |
| 46 #include "wtf/text/AtomicStringHash.h" | 46 #include "wtf/text/AtomicStringHash.h" |
| 47 | 47 |
| 48 namespace WebCore { | 48 namespace WebCore { |
| 49 | 49 |
| 50 class Blob; | 50 class Blob; |
| 51 class ExceptionState; | 51 class ExceptionState; |
| 52 | 52 |
| 53 class WebSocket : public RefCounted<WebSocket>, public ScriptWrappable, public E
ventTarget, public ActiveDOMObject, public WebSocketChannelClient { | 53 class WebSocket : public RefCounted<WebSocket>, public ScriptWrappable, public E
ventTargetWithInlineData, public ActiveDOMObject, public WebSocketChannelClient
{ |
| 54 public: | 54 public: |
| 55 static const char* subProtocolSeperator(); | 55 static const char* subProtocolSeperator(); |
| 56 static PassRefPtr<WebSocket> create(ScriptExecutionContext*, const String& u
rl, ExceptionState&); | 56 static PassRefPtr<WebSocket> create(ScriptExecutionContext*, const String& u
rl, ExceptionState&); |
| 57 static PassRefPtr<WebSocket> create(ScriptExecutionContext*, const String& u
rl, const String& protocol, ExceptionState&); | 57 static PassRefPtr<WebSocket> create(ScriptExecutionContext*, const String& u
rl, const String& protocol, ExceptionState&); |
| 58 static PassRefPtr<WebSocket> create(ScriptExecutionContext*, const String& u
rl, const Vector<String>& protocols, ExceptionState&); | 58 static PassRefPtr<WebSocket> create(ScriptExecutionContext*, const String& u
rl, const Vector<String>& protocols, ExceptionState&); |
| 59 virtual ~WebSocket(); | 59 virtual ~WebSocket(); |
| 60 | 60 |
| 61 enum State { | 61 enum State { |
| 62 CONNECTING = 0, | 62 CONNECTING = 0, |
| 63 OPEN = 1, | 63 OPEN = 1, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 // Handle the JavaScript close method call. close() methods on this class | 127 // Handle the JavaScript close method call. close() methods on this class |
| 128 // are just for determining if the optional code argument is supplied or | 128 // are just for determining if the optional code argument is supplied or |
| 129 // not. | 129 // not. |
| 130 void closeInternal(int, const String&, ExceptionState&); | 130 void closeInternal(int, const String&, ExceptionState&); |
| 131 | 131 |
| 132 // Calls unsetPendingActivity(). Used for m_timerForDeferredDropProtection | 132 // Calls unsetPendingActivity(). Used for m_timerForDeferredDropProtection |
| 133 // to drop the reference for protection asynchronously. | 133 // to drop the reference for protection asynchronously. |
| 134 void dropProtection(Timer<WebSocket>*); | 134 void dropProtection(Timer<WebSocket>*); |
| 135 | 135 |
| 136 virtual void refEventTarget() { ref(); } | 136 virtual void refEventTarget() OVERRIDE { ref(); } |
| 137 virtual void derefEventTarget() { deref(); } | 137 virtual void derefEventTarget() OVERRIDE { deref(); } |
| 138 virtual EventTargetData* eventTargetData(); | |
| 139 virtual EventTargetData* ensureEventTargetData(); | |
| 140 | 138 |
| 141 size_t getFramingOverhead(size_t payloadSize); | 139 size_t getFramingOverhead(size_t payloadSize); |
| 142 | 140 |
| 143 // Checks the result of WebSocketChannel::send() method, and shows console | 141 // Checks the result of WebSocketChannel::send() method, and shows console |
| 144 // message and sets ec appropriately. | 142 // message and sets ec appropriately. |
| 145 void handleSendResult(WebSocketChannel::SendResult, ExceptionState&); | 143 void handleSendResult(WebSocketChannel::SendResult, ExceptionState&); |
| 146 | 144 |
| 147 // Updates m_bufferedAmountAfterClose given the amount of data passed to | 145 // Updates m_bufferedAmountAfterClose given the amount of data passed to |
| 148 // send() method after the state changed to CLOSING or CLOSED. | 146 // send() method after the state changed to CLOSING or CLOSED. |
| 149 void updateBufferedAmountAfterClose(unsigned long); | 147 void updateBufferedAmountAfterClose(unsigned long); |
| 150 | 148 |
| 151 enum BinaryType { | 149 enum BinaryType { |
| 152 BinaryTypeBlob, | 150 BinaryTypeBlob, |
| 153 BinaryTypeArrayBuffer | 151 BinaryTypeArrayBuffer |
| 154 }; | 152 }; |
| 155 | 153 |
| 156 RefPtr<WebSocketChannel> m_channel; | 154 RefPtr<WebSocketChannel> m_channel; |
| 157 | 155 |
| 158 State m_state; | 156 State m_state; |
| 159 KURL m_url; | 157 KURL m_url; |
| 160 EventTargetData m_eventTargetData; | |
| 161 unsigned long m_bufferedAmount; | 158 unsigned long m_bufferedAmount; |
| 162 unsigned long m_bufferedAmountAfterClose; | 159 unsigned long m_bufferedAmountAfterClose; |
| 163 BinaryType m_binaryType; | 160 BinaryType m_binaryType; |
| 164 String m_subprotocol; | 161 String m_subprotocol; |
| 165 String m_extensions; | 162 String m_extensions; |
| 166 | 163 |
| 167 // stop() needs to call some methods that may lead to invocation of handlers | 164 // stop() needs to call some methods that may lead to invocation of handlers |
| 168 // including a dispatchEvent() call. This flag is set at the beginning of | 165 // including a dispatchEvent() call. This flag is set at the beginning of |
| 169 // stop() to prevent dispatchEvent() from being called in such handlers. | 166 // stop() to prevent dispatchEvent() from being called in such handlers. |
| 170 bool m_stopped; | 167 bool m_stopped; |
| 171 | 168 |
| 172 Timer<WebSocket> m_timerForDeferredDropProtection; | 169 Timer<WebSocket> m_timerForDeferredDropProtection; |
| 173 }; | 170 }; |
| 174 | 171 |
| 175 } // namespace WebCore | 172 } // namespace WebCore |
| 176 | 173 |
| 177 #endif // WebSocket_h | 174 #endif // WebSocket_h |
| OLD | NEW |