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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef DOMWebSocket_h | 31 #ifndef DOMWebSocket_h |
32 #define DOMWebSocket_h | 32 #define DOMWebSocket_h |
33 | 33 |
| 34 #include "bindings/core/v8/ActiveScriptWrappable.h" |
34 #include "bindings/core/v8/ScriptWrappable.h" | 35 #include "bindings/core/v8/ScriptWrappable.h" |
35 #include "core/dom/ActiveDOMObject.h" | 36 #include "core/dom/ActiveDOMObject.h" |
36 #include "core/events/EventListener.h" | 37 #include "core/events/EventListener.h" |
37 #include "core/events/EventTarget.h" | 38 #include "core/events/EventTarget.h" |
38 #include "modules/EventTargetModules.h" | 39 #include "modules/EventTargetModules.h" |
39 #include "modules/ModulesExport.h" | 40 #include "modules/ModulesExport.h" |
40 #include "modules/websockets/WebSocketChannel.h" | 41 #include "modules/websockets/WebSocketChannel.h" |
41 #include "modules/websockets/WebSocketChannelClient.h" | 42 #include "modules/websockets/WebSocketChannelClient.h" |
42 #include "platform/Timer.h" | 43 #include "platform/Timer.h" |
43 #include "platform/heap/Handle.h" | 44 #include "platform/heap/Handle.h" |
44 #include "platform/weborigin/KURL.h" | 45 #include "platform/weborigin/KURL.h" |
45 #include "wtf/Deque.h" | 46 #include "wtf/Deque.h" |
46 #include "wtf/Forward.h" | 47 #include "wtf/Forward.h" |
47 #include "wtf/PassRefPtr.h" | 48 #include "wtf/PassRefPtr.h" |
48 #include "wtf/RefPtr.h" | 49 #include "wtf/RefPtr.h" |
49 #include "wtf/text/WTFString.h" | 50 #include "wtf/text/WTFString.h" |
50 #include <stdint.h> | 51 #include <stdint.h> |
51 | 52 |
52 namespace blink { | 53 namespace blink { |
53 | 54 |
54 class Blob; | 55 class Blob; |
55 class DOMArrayBuffer; | 56 class DOMArrayBuffer; |
56 class DOMArrayBufferView; | 57 class DOMArrayBufferView; |
57 class ExceptionState; | 58 class ExceptionState; |
58 class ExecutionContext; | 59 class ExecutionContext; |
59 class StringOrStringSequence; | 60 class StringOrStringSequence; |
60 | 61 |
61 class MODULES_EXPORT DOMWebSocket : public RefCountedGarbageCollectedEventTarget
WithInlineData<DOMWebSocket>, public ActiveDOMObject, public WebSocketChannelCli
ent { | 62 class MODULES_EXPORT DOMWebSocket : public RefCountedGarbageCollectedEventTarget
WithInlineData<DOMWebSocket>, public ActiveScriptWrappable, public ActiveDOMObje
ct, public WebSocketChannelClient { |
62 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(DOMWebSocket); | 63 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(DOMWebSocket); |
63 DEFINE_WRAPPERTYPEINFO(); | 64 DEFINE_WRAPPERTYPEINFO(); |
64 USING_GARBAGE_COLLECTED_MIXIN(DOMWebSocket); | 65 USING_GARBAGE_COLLECTED_MIXIN(DOMWebSocket); |
65 public: | 66 public: |
66 static const char* subprotocolSeperator(); | 67 static const char* subprotocolSeperator(); |
67 // DOMWebSocket instances must be used with a wrapper since this class's | 68 // DOMWebSocket instances must be used with a wrapper since this class's |
68 // lifetime management is designed assuming the V8 holds a ref on it while | 69 // lifetime management is designed assuming the V8 holds a ref on it while |
69 // hasPendingActivity() returns true. | 70 // hasPendingActivity() returns true. |
70 static DOMWebSocket* create(ExecutionContext*, const String& url, ExceptionS
tate&); | 71 static DOMWebSocket* create(ExecutionContext*, const String& url, ExceptionS
tate&); |
71 static DOMWebSocket* create(ExecutionContext*, const String& url, const Stri
ngOrStringSequence& protocols, ExceptionState&); | 72 static DOMWebSocket* create(ExecutionContext*, const String& url, const Stri
ngOrStringSequence& protocols, ExceptionState&); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 109 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
109 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 110 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
110 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); | 111 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); |
111 | 112 |
112 // EventTarget functions. | 113 // EventTarget functions. |
113 const AtomicString& interfaceName() const override; | 114 const AtomicString& interfaceName() const override; |
114 ExecutionContext* getExecutionContext() const override; | 115 ExecutionContext* getExecutionContext() const override; |
115 | 116 |
116 // ActiveDOMObject functions. | 117 // ActiveDOMObject functions. |
117 void contextDestroyed() override; | 118 void contextDestroyed() override; |
118 // Prevent this instance from being collected while it's not in CLOSED | |
119 // state. | |
120 bool hasPendingActivity() const override; | |
121 void suspend() override; | 119 void suspend() override; |
122 void resume() override; | 120 void resume() override; |
123 void stop() override; | 121 void stop() override; |
124 | 122 |
| 123 // ActiveScriptWrappable |
| 124 // Prevent this instance from being collected while it's not in CLOSED |
| 125 // state. |
| 126 bool hasPendingActivity() const final; |
| 127 |
125 // WebSocketChannelClient functions. | 128 // WebSocketChannelClient functions. |
126 void didConnect(const String& subprotocol, const String& extensions) overrid
e; | 129 void didConnect(const String& subprotocol, const String& extensions) overrid
e; |
127 void didReceiveTextMessage(const String& message) override; | 130 void didReceiveTextMessage(const String& message) override; |
128 void didReceiveBinaryMessage(PassOwnPtr<Vector<char>>) override; | 131 void didReceiveBinaryMessage(PassOwnPtr<Vector<char>>) override; |
129 void didError() override; | 132 void didError() override; |
130 void didConsumeBufferedAmount(uint64_t) override; | 133 void didConsumeBufferedAmount(uint64_t) override; |
131 void didStartClosingHandshake() override; | 134 void didStartClosingHandshake() override; |
132 void didClose(ClosingHandshakeCompletionStatus, unsigned short code, const S
tring& reason) override; | 135 void didClose(ClosingHandshakeCompletionStatus, unsigned short code, const S
tring& reason) override; |
133 | 136 |
134 DECLARE_VIRTUAL_TRACE(); | 137 DECLARE_VIRTUAL_TRACE(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 String m_subprotocol; | 242 String m_subprotocol; |
240 String m_extensions; | 243 String m_extensions; |
241 | 244 |
242 Member<EventQueue> m_eventQueue; | 245 Member<EventQueue> m_eventQueue; |
243 Timer<DOMWebSocket> m_bufferedAmountConsumeTimer; | 246 Timer<DOMWebSocket> m_bufferedAmountConsumeTimer; |
244 }; | 247 }; |
245 | 248 |
246 } // namespace blink | 249 } // namespace blink |
247 | 250 |
248 #endif // DOMWebSocket_h | 251 #endif // DOMWebSocket_h |
OLD | NEW |