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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(DOMWebSocket); | 62 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(DOMWebSocket); |
63 DEFINE_WRAPPERTYPEINFO(); | 63 DEFINE_WRAPPERTYPEINFO(); |
64 USING_GARBAGE_COLLECTED_MIXIN(DOMWebSocket); | 64 USING_GARBAGE_COLLECTED_MIXIN(DOMWebSocket); |
65 public: | 65 public: |
66 static const char* subprotocolSeperator(); | 66 static const char* subprotocolSeperator(); |
67 // DOMWebSocket instances must be used with a wrapper since this class's | 67 // 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 | 68 // lifetime management is designed assuming the V8 holds a ref on it while |
69 // hasPendingActivity() returns true. | 69 // hasPendingActivity() returns true. |
70 static DOMWebSocket* create(ExecutionContext*, const String& url, ExceptionS
tate&); | 70 static DOMWebSocket* create(ExecutionContext*, const String& url, ExceptionS
tate&); |
71 static DOMWebSocket* create(ExecutionContext*, const String& url, const Stri
ngOrStringSequence& protocols, ExceptionState&); | 71 static DOMWebSocket* create(ExecutionContext*, const String& url, const Stri
ngOrStringSequence& protocols, ExceptionState&); |
72 virtual ~DOMWebSocket(); | 72 ~DOMWebSocket() override; |
73 | 73 |
74 enum State { | 74 enum State { |
75 CONNECTING = 0, | 75 CONNECTING = 0, |
76 OPEN = 1, | 76 OPEN = 1, |
77 CLOSING = 2, | 77 CLOSING = 2, |
78 CLOSED = 3 | 78 CLOSED = 3 |
79 }; | 79 }; |
80 | 80 |
81 void connect(const String& url, const Vector<String>& protocols, ExceptionSt
ate&); | 81 void connect(const String& url, const Vector<String>& protocols, ExceptionSt
ate&); |
82 | 82 |
(...skipping 20 matching lines...) Expand all Loading... |
103 | 103 |
104 String binaryType() const; | 104 String binaryType() const; |
105 void setBinaryType(const String&); | 105 void setBinaryType(const String&); |
106 | 106 |
107 DEFINE_ATTRIBUTE_EVENT_LISTENER(open); | 107 DEFINE_ATTRIBUTE_EVENT_LISTENER(open); |
108 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 108 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
109 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 109 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
110 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); | 110 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); |
111 | 111 |
112 // EventTarget functions. | 112 // EventTarget functions. |
113 virtual const AtomicString& interfaceName() const override; | 113 const AtomicString& interfaceName() const override; |
114 virtual ExecutionContext* executionContext() const override; | 114 ExecutionContext* executionContext() const override; |
115 | 115 |
116 // ActiveDOMObject functions. | 116 // ActiveDOMObject functions. |
117 virtual void contextDestroyed() override; | 117 void contextDestroyed() override; |
118 // Prevent this instance from being collected while it's not in CLOSED | 118 // Prevent this instance from being collected while it's not in CLOSED |
119 // state. | 119 // state. |
120 virtual bool hasPendingActivity() const override; | 120 bool hasPendingActivity() const override; |
121 virtual void suspend() override; | 121 void suspend() override; |
122 virtual void resume() override; | 122 void resume() override; |
123 virtual void stop() override; | 123 void stop() override; |
124 | 124 |
125 // WebSocketChannelClient functions. | 125 // WebSocketChannelClient functions. |
126 virtual void didConnect(const String& subprotocol, const String& extensions)
override; | 126 void didConnect(const String& subprotocol, const String& extensions) overrid
e; |
127 virtual void didReceiveTextMessage(const String& message) override; | 127 void didReceiveTextMessage(const String& message) override; |
128 virtual void didReceiveBinaryMessage(PassOwnPtr<Vector<char>>) override; | 128 void didReceiveBinaryMessage(PassOwnPtr<Vector<char>>) override; |
129 virtual void didError() override; | 129 void didError() override; |
130 virtual void didConsumeBufferedAmount(uint64_t) override; | 130 void didConsumeBufferedAmount(uint64_t) override; |
131 virtual void didStartClosingHandshake() override; | 131 void didStartClosingHandshake() override; |
132 virtual void didClose(ClosingHandshakeCompletionStatus, unsigned short code,
const String& reason) override; | 132 void didClose(ClosingHandshakeCompletionStatus, unsigned short code, const S
tring& reason) override; |
133 | 133 |
134 DECLARE_VIRTUAL_TRACE(); | 134 DECLARE_VIRTUAL_TRACE(); |
135 | 135 |
136 static bool isValidSubprotocolString(const String&); | 136 static bool isValidSubprotocolString(const String&); |
137 | 137 |
138 protected: | 138 protected: |
139 explicit DOMWebSocket(ExecutionContext*); | 139 explicit DOMWebSocket(ExecutionContext*); |
140 | 140 |
141 private: | 141 private: |
142 // FIXME: This should inherit blink::EventQueue. | 142 // FIXME: This should inherit blink::EventQueue. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 String m_subprotocol; | 237 String m_subprotocol; |
238 String m_extensions; | 238 String m_extensions; |
239 | 239 |
240 Member<EventQueue> m_eventQueue; | 240 Member<EventQueue> m_eventQueue; |
241 Timer<DOMWebSocket> m_bufferedAmountConsumeTimer; | 241 Timer<DOMWebSocket> m_bufferedAmountConsumeTimer; |
242 }; | 242 }; |
243 | 243 |
244 } // namespace blink | 244 } // namespace blink |
245 | 245 |
246 #endif // DOMWebSocket_h | 246 #endif // DOMWebSocket_h |
OLD | NEW |