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 ThreadableWebSocketChannelClientWrapper_h | 31 #ifndef ThreadableWebSocketChannelClientWrapper_h |
32 #define ThreadableWebSocketChannelClientWrapper_h | 32 #define ThreadableWebSocketChannelClientWrapper_h |
33 | 33 |
| 34 #include "core/dom/ExecutionContextTask.h" |
| 35 #include "modules/websockets/WebSocketChannel.h" |
34 #include "modules/websockets/WebSocketChannelClient.h" | 36 #include "modules/websockets/WebSocketChannelClient.h" |
35 #include "platform/heap/Handle.h" | |
36 #include "wtf/Forward.h" | 37 #include "wtf/Forward.h" |
| 38 #include "wtf/OwnPtr.h" |
37 #include "wtf/PassOwnPtr.h" | 39 #include "wtf/PassOwnPtr.h" |
38 #include "wtf/ThreadSafeRefCounted.h" | 40 #include "wtf/ThreadSafeRefCounted.h" |
39 #include "wtf/Vector.h" | 41 #include "wtf/Vector.h" |
40 | 42 |
41 namespace WebCore { | 43 namespace WebCore { |
42 | 44 |
43 class ThreadableWebSocketChannelClientWrapper : public ThreadSafeRefCountedWillB
eGarbageCollected<ThreadableWebSocketChannelClientWrapper> { | 45 class ExecutionContext; |
| 46 class WebSocketChannelClient; |
| 47 |
| 48 class ThreadableWebSocketChannelClientWrapper : public ThreadSafeRefCountedWillB
eGarbageCollectedFinalized<ThreadableWebSocketChannelClientWrapper> { |
44 public: | 49 public: |
45 static PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> creat
e(WebSocketChannelClient*); | 50 static PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> creat
e(WebSocketChannelClient*); |
| 51 ~ThreadableWebSocketChannelClientWrapper(); |
46 | 52 |
47 void clearClient(); | 53 void clearClient(); |
48 | 54 |
49 void didConnect(const String& subprotocol, const String& extensions); | 55 void didConnect(const String& subprotocol, const String& extensions); |
50 void didReceiveMessage(const String& message); | 56 void didReceiveMessage(const String& message); |
51 void didReceiveBinaryData(PassOwnPtr<Vector<char> >); | 57 void didReceiveBinaryData(PassOwnPtr<Vector<char> >); |
52 void didConsumeBufferedAmount(unsigned long); | 58 void didConsumeBufferedAmount(unsigned long); |
53 void didStartClosingHandshake(); | 59 void didStartClosingHandshake(); |
54 void didClose(WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsi
gned short code, const String& reason); | 60 void didClose(WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsi
gned short code, const String& reason); |
55 void didReceiveMessageError(); | 61 void didReceiveMessageError(); |
56 | 62 |
| 63 void suspend(); |
| 64 void resume(); |
| 65 |
57 void trace(Visitor*) { } | 66 void trace(Visitor*) { } |
58 | 67 |
59 private: | 68 private: |
60 ThreadableWebSocketChannelClientWrapper(WebSocketChannelClient*); | 69 ThreadableWebSocketChannelClientWrapper(WebSocketChannelClient*); |
61 | 70 |
| 71 void processPendingTasks(); |
| 72 |
| 73 static void didConnectCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<Thr
eadableWebSocketChannelClientWrapper>, const String& subprotocol, const String&
extensions); |
| 74 static void didReceiveMessageCallback(ExecutionContext*, PassRefPtrWillBeRaw
Ptr<ThreadableWebSocketChannelClientWrapper>, const String& message); |
| 75 static void didReceiveBinaryDataCallback(ExecutionContext*, PassRefPtrWillBe
RawPtr<ThreadableWebSocketChannelClientWrapper>, PassOwnPtr<Vector<char> >); |
| 76 static void didConsumeBufferedAmountCallback(ExecutionContext*, PassRefPtrWi
llBeRawPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long); |
| 77 static void didStartClosingHandshakeCallback(ExecutionContext*, PassRefPtrWi
llBeRawPtr<ThreadableWebSocketChannelClientWrapper>); |
| 78 static void didCloseCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<Threa
dableWebSocketChannelClientWrapper>, WebSocketChannelClient::ClosingHandshakeCom
pletionStatus, unsigned short code, const String& reason); |
| 79 static void didReceiveMessageErrorCallback(ExecutionContext*, PassRefPtrWill
BeRawPtr<ThreadableWebSocketChannelClientWrapper>); |
| 80 |
62 WebSocketChannelClient* m_client; | 81 WebSocketChannelClient* m_client; |
| 82 bool m_suspended; |
| 83 Vector<OwnPtr<ExecutionContextTask> > m_pendingTasks; |
63 }; | 84 }; |
64 | 85 |
65 } // namespace WebCore | 86 } // namespace WebCore |
66 | 87 |
67 #endif // ThreadableWebSocketChannelClientWrapper_h | 88 #endif // ThreadableWebSocketChannelClientWrapper_h |
OLD | NEW |