Chromium Code Reviews| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 #include "wtf/Forward.h" | 44 #include "wtf/Forward.h" |
| 45 #include "wtf/OwnPtr.h" | 45 #include "wtf/OwnPtr.h" |
| 46 #include "wtf/RefCounted.h" | 46 #include "wtf/RefCounted.h" |
| 47 #include "wtf/text/AtomicStringHash.h" | 47 #include "wtf/text/AtomicStringHash.h" |
| 48 | 48 |
| 49 namespace WebCore { | 49 namespace WebCore { |
| 50 | 50 |
| 51 class Blob; | 51 class Blob; |
| 52 class ExceptionState; | 52 class ExceptionState; |
| 53 | 53 |
| 54 class WebSocket FINAL : public RefCountedWillBeRefCountedGarbageCollected<WebSoc ket>, public ScriptWrappable, public EventTargetWithInlineData, public ActiveDOM Object, public WebSocketChannelClient { | 54 class WebSocket : public RefCountedWillBeRefCountedGarbageCollected<WebSocket>, public ScriptWrappable, public EventTargetWithInlineData, public ActiveDOMObject , public WebSocketChannelClient { |
| 55 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<W ebSocket>); | 55 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<W ebSocket>); |
| 56 public: | 56 public: |
| 57 static const char* subProtocolSeperator(); | 57 static const char* subprotocolSeperator(); |
| 58 // WebSocket instances must be used with a wrapper since this class's | 58 // WebSocket instances must be used with a wrapper since this class's |
| 59 // lifetime management is designed assuming the V8 holds a ref on it while | 59 // lifetime management is designed assuming the V8 holds a ref on it while |
| 60 // hasPendingActivity() returns true. | 60 // hasPendingActivity() returns true. |
| 61 static PassRefPtrWillBeRawPtr<WebSocket> create(ExecutionContext*, const Str ing& url, ExceptionState&); | 61 static PassRefPtrWillBeRawPtr<WebSocket> create(ExecutionContext*, const Str ing& url, ExceptionState&); |
| 62 static PassRefPtrWillBeRawPtr<WebSocket> create(ExecutionContext*, const Str ing& url, const String& protocol, ExceptionState&); | 62 static PassRefPtrWillBeRawPtr<WebSocket> create(ExecutionContext*, const Str ing& url, const String& protocol, ExceptionState&); |
| 63 static PassRefPtrWillBeRawPtr<WebSocket> create(ExecutionContext*, const Str ing& url, const Vector<String>& protocols, ExceptionState&); | 63 static PassRefPtrWillBeRawPtr<WebSocket> create(ExecutionContext*, const Str ing& url, const Vector<String>& protocols, ExceptionState&); |
| 64 virtual ~WebSocket(); | 64 virtual ~WebSocket(); |
| 65 | 65 |
| 66 enum State { | 66 enum State { |
| 67 CONNECTING = 0, | 67 CONNECTING = 0, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 | 116 |
| 117 // WebSocketChannelClient functions. | 117 // WebSocketChannelClient functions. |
| 118 virtual void didConnect() OVERRIDE; | 118 virtual void didConnect() OVERRIDE; |
| 119 virtual void didReceiveMessage(const String& message) OVERRIDE; | 119 virtual void didReceiveMessage(const String& message) OVERRIDE; |
| 120 virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) OVERRIDE; | 120 virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) OVERRIDE; |
| 121 virtual void didReceiveMessageError() OVERRIDE; | 121 virtual void didReceiveMessageError() OVERRIDE; |
| 122 virtual void didUpdateBufferedAmount(unsigned long bufferedAmount) OVERRIDE; | 122 virtual void didUpdateBufferedAmount(unsigned long bufferedAmount) OVERRIDE; |
| 123 virtual void didStartClosingHandshake() OVERRIDE; | 123 virtual void didStartClosingHandshake() OVERRIDE; |
| 124 virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshak eCompletionStatus, unsigned short code, const String& reason) OVERRIDE; | 124 virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshak eCompletionStatus, unsigned short code, const String& reason) OVERRIDE; |
| 125 | 125 |
| 126 void trace(Visitor*); | 126 void trace(Visitor*); |
|
haraken
2014/05/27 04:35:08
You need to make this a virtual method.
yhirano
2014/05/27 05:03:02
Done.
haraken
2014/05/27 05:23:56
Ian: Would it be possible to detect missing 'virtu
zerny-chromium
2014/05/27 08:26:28
Actually, is should already have issued an error f
| |
| 127 | 127 |
| 128 static bool isValidSubprotocolString(const String&); | |
| 129 | |
| 130 protected: | |
| 131 explicit WebSocket(ExecutionContext*); | |
| 132 | |
| 128 private: | 133 private: |
| 129 // FIXME: This should inherit WebCore::EventQueue. | 134 // FIXME: This should inherit WebCore::EventQueue. |
| 130 class EventQueue FINAL : public RefCountedWillBeGarbageCollectedFinalized<Ev entQueue> { | 135 class EventQueue FINAL : public RefCountedWillBeGarbageCollectedFinalized<Ev entQueue> { |
| 131 public: | 136 public: |
| 132 static PassRefPtrWillBeRawPtr<EventQueue> create(EventTarget* target) | 137 static PassRefPtrWillBeRawPtr<EventQueue> create(EventTarget* target) |
| 133 { | 138 { |
| 134 return adoptRefWillBeNoop(new EventQueue(target)); | 139 return adoptRefWillBeNoop(new EventQueue(target)); |
| 135 } | 140 } |
| 136 ~EventQueue(); | 141 ~EventQueue(); |
| 137 | 142 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 }; | 174 }; |
| 170 | 175 |
| 171 enum WebSocketSendType { | 176 enum WebSocketSendType { |
| 172 WebSocketSendTypeString, | 177 WebSocketSendTypeString, |
| 173 WebSocketSendTypeArrayBuffer, | 178 WebSocketSendTypeArrayBuffer, |
| 174 WebSocketSendTypeArrayBufferView, | 179 WebSocketSendTypeArrayBufferView, |
| 175 WebSocketSendTypeBlob, | 180 WebSocketSendTypeBlob, |
| 176 WebSocketSendTypeMax, | 181 WebSocketSendTypeMax, |
| 177 }; | 182 }; |
| 178 | 183 |
| 179 explicit WebSocket(ExecutionContext*); | 184 // This function is virtual for unittests. |
| 185 // FIXME: Move WebSocketChannel::create here. | |
| 186 virtual PassRefPtrWillBeRawPtr<WebSocketChannel> createChannel(ExecutionCont ext* context, WebSocketChannelClient* client) | |
| 187 { | |
| 188 return WebSocketChannel::create(context, client); | |
| 189 } | |
| 180 | 190 |
| 181 // Adds a console message with JSMessageSource and ErrorMessageLevel. | 191 // Adds a console message with JSMessageSource and ErrorMessageLevel. |
| 182 void logError(const String& message); | 192 void logError(const String& message); |
| 183 | 193 |
| 184 // Handle the JavaScript close method call. close() methods on this class | 194 // Handle the JavaScript close method call. close() methods on this class |
| 185 // are just for determining if the optional code argument is supplied or | 195 // are just for determining if the optional code argument is supplied or |
| 186 // not. | 196 // not. |
| 187 void closeInternal(int, const String&, ExceptionState&); | 197 void closeInternal(int, const String&, ExceptionState&); |
| 188 | 198 |
| 189 size_t getFramingOverhead(size_t payloadSize); | 199 size_t getFramingOverhead(size_t payloadSize); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 215 // The subprotocol the server selected. | 225 // The subprotocol the server selected. |
| 216 String m_subprotocol; | 226 String m_subprotocol; |
| 217 String m_extensions; | 227 String m_extensions; |
| 218 | 228 |
| 219 RefPtrWillBeMember<EventQueue> m_eventQueue; | 229 RefPtrWillBeMember<EventQueue> m_eventQueue; |
| 220 }; | 230 }; |
| 221 | 231 |
| 222 } // namespace WebCore | 232 } // namespace WebCore |
| 223 | 233 |
| 224 #endif // WebSocket_h | 234 #endif // WebSocket_h |
| OLD | NEW |