| 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/Optional.h" |
| 34 #include "core/dom/ActiveDOMObject.h" | 35 #include "core/dom/ActiveDOMObject.h" |
| 35 #include "core/events/EventListener.h" | 36 #include "core/events/EventListener.h" |
| 36 #include "modules/EventTargetModules.h" | 37 #include "modules/EventTargetModules.h" |
| 37 #include "modules/websockets/WebSocketChannel.h" | 38 #include "modules/websockets/WebSocketChannel.h" |
| 38 #include "modules/websockets/WebSocketChannelClient.h" | 39 #include "modules/websockets/WebSocketChannelClient.h" |
| 39 #include "platform/Timer.h" | 40 #include "platform/Timer.h" |
| 40 #include "platform/heap/Handle.h" | 41 #include "platform/heap/Handle.h" |
| 41 #include "platform/weborigin/KURL.h" | 42 #include "platform/weborigin/KURL.h" |
| 42 #include "wtf/Deque.h" | 43 #include "wtf/Deque.h" |
| 43 #include "wtf/Forward.h" | 44 #include "wtf/Forward.h" |
| 44 #include "wtf/text/AtomicStringHash.h" | 45 #include "wtf/text/AtomicStringHash.h" |
| 45 | 46 |
| 46 namespace blink { | 47 namespace blink { |
| 47 | 48 |
| 48 class Blob; | 49 class Blob; |
| 49 class ExceptionState; | 50 class ExceptionState; |
| 50 | 51 |
| 51 class DOMWebSocket : public RefCountedGarbageCollectedWillBeGarbageCollectedFina
lized<DOMWebSocket>, public EventTargetWithInlineData, public ActiveDOMObject, p
ublic WebSocketChannelClient { | 52 class DOMWebSocket : public RefCountedGarbageCollectedWillBeGarbageCollectedFina
lized<DOMWebSocket>, public EventTargetWithInlineData, public ActiveDOMObject, p
ublic WebSocketChannelClient { |
| 52 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<D
OMWebSocket>); | 53 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<D
OMWebSocket>); |
| 53 USING_GARBAGE_COLLECTED_MIXIN(DOMWebSocket); | 54 USING_GARBAGE_COLLECTED_MIXIN(DOMWebSocket); |
| 54 public: | 55 public: |
| 55 static const char* subprotocolSeperator(); | 56 static const char* subprotocolSeperator(); |
| 56 // DOMWebSocket instances must be used with a wrapper since this class's | 57 // DOMWebSocket instances must be used with a wrapper since this class's |
| 57 // lifetime management is designed assuming the V8 holds a ref on it while | 58 // lifetime management is designed assuming the V8 holds a ref on it while |
| 58 // hasPendingActivity() returns true. | 59 // hasPendingActivity() returns true. |
| 59 static DOMWebSocket* create(ExecutionContext*, const String& url, ExceptionS
tate&); | |
| 60 static DOMWebSocket* create(ExecutionContext*, const String& url, const Stri
ng& protocol, ExceptionState&); | 60 static DOMWebSocket* create(ExecutionContext*, const String& url, const Stri
ng& protocol, ExceptionState&); |
| 61 static DOMWebSocket* create(ExecutionContext*, const String& url, const Vect
or<String>& protocols, ExceptionState&); | 61 static DOMWebSocket* create(ExecutionContext*, const String& url, const Vect
or<String>& protocols, ExceptionState&); |
| 62 virtual ~DOMWebSocket(); | 62 virtual ~DOMWebSocket(); |
| 63 | 63 |
| 64 enum State { | 64 enum State { |
| 65 CONNECTING = 0, | 65 CONNECTING = 0, |
| 66 OPEN = 1, | 66 OPEN = 1, |
| 67 CLOSING = 2, | 67 CLOSING = 2, |
| 68 CLOSED = 3 | 68 CLOSED = 3 |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 void connect(const String& url, const Vector<String>& protocols, ExceptionSt
ate&); | 71 void connect(const String& url, const Vector<String>& protocols, ExceptionSt
ate&); |
| 72 | 72 |
| 73 void send(const String& message, ExceptionState&); | 73 void send(const String& message, ExceptionState&); |
| 74 void send(ArrayBuffer*, ExceptionState&); | 74 void send(ArrayBuffer*, ExceptionState&); |
| 75 void send(ArrayBufferView*, ExceptionState&); | 75 void send(ArrayBufferView*, ExceptionState&); |
| 76 void send(Blob*, ExceptionState&); | 76 void send(Blob*, ExceptionState&); |
| 77 | 77 |
| 78 // To distinguish close method call with the code parameter from one | 78 void close(Optional<unsigned short> code, const String& reason, ExceptionSta
te&); |
| 79 // without, we have these three signatures. Use of | |
| 80 // Optional=DefaultIsUndefined in the IDL file doesn't help for now since | |
| 81 // it's bound to a value of 0 which is indistinguishable from the case 0 | |
| 82 // is passed as code parameter. | |
| 83 void close(unsigned short code, const String& reason, ExceptionState&); | |
| 84 void close(ExceptionState&); | |
| 85 void close(unsigned short code, ExceptionState&); | |
| 86 | 79 |
| 87 const KURL& url() const; | 80 const KURL& url() const; |
| 88 State readyState() const; | 81 State readyState() const; |
| 89 unsigned long bufferedAmount() const; | 82 unsigned long bufferedAmount() const; |
| 90 | 83 |
| 91 String protocol() const; | 84 String protocol() const; |
| 92 String extensions() const; | 85 String extensions() const; |
| 93 | 86 |
| 94 String binaryType() const; | 87 String binaryType() const; |
| 95 void setBinaryType(const String&); | 88 void setBinaryType(const String&); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 String m_subprotocol; | 215 String m_subprotocol; |
| 223 String m_extensions; | 216 String m_extensions; |
| 224 | 217 |
| 225 Member<EventQueue> m_eventQueue; | 218 Member<EventQueue> m_eventQueue; |
| 226 Timer<DOMWebSocket> m_bufferedAmountConsumeTimer; | 219 Timer<DOMWebSocket> m_bufferedAmountConsumeTimer; |
| 227 }; | 220 }; |
| 228 | 221 |
| 229 } // namespace blink | 222 } // namespace blink |
| 230 | 223 |
| 231 #endif // DOMWebSocket_h | 224 #endif // DOMWebSocket_h |
| OLD | NEW |