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 : public RefCounted<WebSocket>, public ScriptWrappable, public E
ventTargetWithInlineData, public ActiveDOMObject, public WebSocketChannelClient
{ | 54 class WebSocket FINAL : public RefCounted<WebSocket>, public ScriptWrappable, pu
blic EventTargetWithInlineData, public ActiveDOMObject, public WebSocketChannelC
lient { |
55 REFCOUNTED_EVENT_TARGET(WebSocket); | 55 REFCOUNTED_EVENT_TARGET(WebSocket); |
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 PassRefPtr<WebSocket> create(ExecutionContext*, const String& url, Ex
ceptionState&); | 61 static PassRefPtr<WebSocket> create(ExecutionContext*, const String& url, Ex
ceptionState&); |
62 static PassRefPtr<WebSocket> create(ExecutionContext*, const String& url, co
nst String& protocol, ExceptionState&); | 62 static PassRefPtr<WebSocket> create(ExecutionContext*, const String& url, co
nst String& protocol, ExceptionState&); |
63 static PassRefPtr<WebSocket> create(ExecutionContext*, const String& url, co
nst Vector<String>& protocols, ExceptionState&); | 63 static PassRefPtr<WebSocket> create(ExecutionContext*, const String& url, co
nst Vector<String>& protocols, ExceptionState&); |
64 virtual ~WebSocket(); | 64 virtual ~WebSocket(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // WebSocketChannelClient functions. | 119 // WebSocketChannelClient functions. |
120 virtual void didConnect() OVERRIDE; | 120 virtual void didConnect() OVERRIDE; |
121 virtual void didReceiveMessage(const String& message) OVERRIDE; | 121 virtual void didReceiveMessage(const String& message) OVERRIDE; |
122 virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) OVERRIDE; | 122 virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) OVERRIDE; |
123 virtual void didReceiveMessageError() OVERRIDE; | 123 virtual void didReceiveMessageError() OVERRIDE; |
124 virtual void didUpdateBufferedAmount(unsigned long bufferedAmount) OVERRIDE; | 124 virtual void didUpdateBufferedAmount(unsigned long bufferedAmount) OVERRIDE; |
125 virtual void didStartClosingHandshake() OVERRIDE; | 125 virtual void didStartClosingHandshake() OVERRIDE; |
126 virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshak
eCompletionStatus, unsigned short code, const String& reason) OVERRIDE; | 126 virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshak
eCompletionStatus, unsigned short code, const String& reason) OVERRIDE; |
127 | 127 |
128 private: | 128 private: |
129 class EventQueue : public RefCounted<EventQueue> { | 129 class EventQueue FINAL : public RefCounted<EventQueue> { |
130 public: | 130 public: |
131 static PassRefPtr<EventQueue> create(EventTarget* target) { return adopt
Ref(new EventQueue(target)); } | 131 static PassRefPtr<EventQueue> create(EventTarget* target) { return adopt
Ref(new EventQueue(target)); } |
132 virtual ~EventQueue(); | 132 ~EventQueue(); |
133 | 133 |
134 // Dispatches the event if this queue is active. | 134 // Dispatches the event if this queue is active. |
135 // Queues the event if this queue is suspended. | 135 // Queues the event if this queue is suspended. |
136 // Does nothing otherwise. | 136 // Does nothing otherwise. |
137 void dispatch(PassRefPtr<Event> /* event */); | 137 void dispatch(PassRefPtr<Event> /* event */); |
138 | 138 |
139 void suspend(); | 139 void suspend(); |
140 void resume(); | 140 void resume(); |
141 void stop(); | 141 void stop(); |
142 | 142 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 BinaryType m_binaryType; | 194 BinaryType m_binaryType; |
195 String m_subprotocol; | 195 String m_subprotocol; |
196 String m_extensions; | 196 String m_extensions; |
197 | 197 |
198 RefPtr<EventQueue> m_eventQueue; | 198 RefPtr<EventQueue> m_eventQueue; |
199 }; | 199 }; |
200 | 200 |
201 } // namespace WebCore | 201 } // namespace WebCore |
202 | 202 |
203 #endif // WebSocket_h | 203 #endif // WebSocket_h |
OLD | NEW |