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