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(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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*); |
| 127 | 127 |
| 128 static bool isValidSubprotocolString(const String&); | |
|
tyoshino (SeeGerritForStatus)
2014/05/27 01:12:14
use SubProtocol to align with subProtocolSeparator
yhirano
2014/05/27 03:30:07
I would rather prefer subprotocol over subProtocol
tyoshino (SeeGerritForStatus)
2014/05/27 11:51:23
OK. As far as they're consistent, I'm fine.
| |
| 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 virtual PassRefPtrWillBeRawPtr<WebSocketChannel> createChannel(ExecutionCont ext* context, WebSocketChannelClient* client) | |
| 186 { | |
| 187 return WebSocketChannel::create(context, client); | |
|
tyoshino (SeeGerritForStatus)
2014/05/27 01:12:14
We might want to move contents of WebSocketChannel
yhirano
2014/05/27 03:30:07
Done.
| |
| 188 } | |
| 180 | 189 |
| 181 // Adds a console message with JSMessageSource and ErrorMessageLevel. | 190 // Adds a console message with JSMessageSource and ErrorMessageLevel. |
| 182 void logError(const String& message); | 191 void logError(const String& message); |
| 183 | 192 |
| 184 // Handle the JavaScript close method call. close() methods on this class | 193 // Handle the JavaScript close method call. close() methods on this class |
| 185 // are just for determining if the optional code argument is supplied or | 194 // are just for determining if the optional code argument is supplied or |
| 186 // not. | 195 // not. |
| 187 void closeInternal(int, const String&, ExceptionState&); | 196 void closeInternal(int, const String&, ExceptionState&); |
| 188 | 197 |
| 189 size_t getFramingOverhead(size_t payloadSize); | 198 size_t getFramingOverhead(size_t payloadSize); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 215 // The subprotocol the server selected. | 224 // The subprotocol the server selected. |
| 216 String m_subprotocol; | 225 String m_subprotocol; |
| 217 String m_extensions; | 226 String m_extensions; |
| 218 | 227 |
| 219 RefPtrWillBeMember<EventQueue> m_eventQueue; | 228 RefPtrWillBeMember<EventQueue> m_eventQueue; |
| 220 }; | 229 }; |
| 221 | 230 |
| 222 } // namespace WebCore | 231 } // namespace WebCore |
| 223 | 232 |
| 224 #endif // WebSocket_h | 233 #endif // WebSocket_h |
| OLD | NEW |