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 27 matching lines...) Expand all Loading... |
38 #include "wtf/OwnPtr.h" | 38 #include "wtf/OwnPtr.h" |
39 #include "wtf/PassOwnPtr.h" | 39 #include "wtf/PassOwnPtr.h" |
40 #include "wtf/ThreadSafeRefCounted.h" | 40 #include "wtf/ThreadSafeRefCounted.h" |
41 #include "wtf/Vector.h" | 41 #include "wtf/Vector.h" |
42 | 42 |
43 namespace WebCore { | 43 namespace WebCore { |
44 | 44 |
45 class ExecutionContext; | 45 class ExecutionContext; |
46 class WebSocketChannelClient; | 46 class WebSocketChannelClient; |
47 | 47 |
48 class ThreadableWebSocketChannelClientWrapper : public ThreadSafeRefCountedWillB
eGarbageCollectedFinalized<ThreadableWebSocketChannelClientWrapper> { | 48 class ThreadableWebSocketChannelClientWrapper : public ThreadSafeRefCounted<Thre
adableWebSocketChannelClientWrapper> { |
49 public: | 49 public: |
50 static PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> creat
e(WebSocketChannelClient*); | 50 static PassRefPtr<ThreadableWebSocketChannelClientWrapper> create(WebSocketC
hannelClient*); |
51 ~ThreadableWebSocketChannelClientWrapper(); | |
52 | 51 |
53 // Subprotocol and extensions will be available when didConnect() callback i
s invoked. | 52 // Subprotocol and extensions will be available when didConnect() callback i
s invoked. |
54 String subprotocol() const; | 53 String subprotocol() const; |
55 void setSubprotocol(const String&); | 54 void setSubprotocol(const String&); |
56 String extensions() const; | 55 String extensions() const; |
57 void setExtensions(const String&); | 56 void setExtensions(const String&); |
58 | 57 |
59 void clearClient(); | 58 void clearClient(); |
60 | 59 |
61 void didConnect(); | 60 void didConnect(); |
62 void didReceiveMessage(const String& message); | 61 void didReceiveMessage(const String& message); |
63 void didReceiveBinaryData(PassOwnPtr<Vector<char> >); | 62 void didReceiveBinaryData(PassOwnPtr<Vector<char> >); |
64 void didUpdateBufferedAmount(unsigned long bufferedAmount); | 63 void didUpdateBufferedAmount(unsigned long bufferedAmount); |
65 void didStartClosingHandshake(); | 64 void didStartClosingHandshake(); |
66 void didClose(unsigned long unhandledBufferedAmount, WebSocketChannelClient:
:ClosingHandshakeCompletionStatus, unsigned short code, const String& reason); | 65 void didClose(unsigned long unhandledBufferedAmount, WebSocketChannelClient:
:ClosingHandshakeCompletionStatus, unsigned short code, const String& reason); |
67 void didReceiveMessageError(); | 66 void didReceiveMessageError(); |
68 | 67 |
69 void suspend(); | 68 void suspend(); |
70 void resume(); | 69 void resume(); |
71 | 70 |
72 void trace(Visitor*) { } | |
73 | |
74 private: | 71 private: |
75 ThreadableWebSocketChannelClientWrapper(WebSocketChannelClient*); | 72 ThreadableWebSocketChannelClientWrapper(WebSocketChannelClient*); |
76 | 73 |
77 void processPendingTasks(); | 74 void processPendingTasks(); |
78 | 75 |
79 static void didConnectCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<Thr
eadableWebSocketChannelClientWrapper>); | 76 static void didConnectCallback(ExecutionContext*, PassRefPtr<ThreadableWebSo
cketChannelClientWrapper>); |
80 static void didReceiveMessageCallback(ExecutionContext*, PassRefPtrWillBeRaw
Ptr<ThreadableWebSocketChannelClientWrapper>, const String& message); | 77 static void didReceiveMessageCallback(ExecutionContext*, PassRefPtr<Threadab
leWebSocketChannelClientWrapper>, const String& message); |
81 static void didReceiveBinaryDataCallback(ExecutionContext*, PassRefPtrWillBe
RawPtr<ThreadableWebSocketChannelClientWrapper>, PassOwnPtr<Vector<char> >); | 78 static void didReceiveBinaryDataCallback(ExecutionContext*, PassRefPtr<Threa
dableWebSocketChannelClientWrapper>, PassOwnPtr<Vector<char> >); |
82 static void didUpdateBufferedAmountCallback(ExecutionContext*, PassRefPtrWil
lBeRawPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long bufferedAmount
); | 79 static void didUpdateBufferedAmountCallback(ExecutionContext*, PassRefPtr<Th
readableWebSocketChannelClientWrapper>, unsigned long bufferedAmount); |
83 static void didStartClosingHandshakeCallback(ExecutionContext*, PassRefPtrWi
llBeRawPtr<ThreadableWebSocketChannelClientWrapper>); | 80 static void didStartClosingHandshakeCallback(ExecutionContext*, PassRefPtr<T
hreadableWebSocketChannelClientWrapper>); |
84 static void didCloseCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<Threa
dableWebSocketChannelClientWrapper>, unsigned long unhandledBufferedAmount, WebS
ocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const
String& reason); | 81 static void didCloseCallback(ExecutionContext*, PassRefPtr<ThreadableWebSock
etChannelClientWrapper>, unsigned long unhandledBufferedAmount, WebSocketChannel
Client::ClosingHandshakeCompletionStatus, unsigned short code, const String& rea
son); |
85 static void didReceiveMessageErrorCallback(ExecutionContext*, PassRefPtrWill
BeRawPtr<ThreadableWebSocketChannelClientWrapper>); | 82 static void didReceiveMessageErrorCallback(ExecutionContext*, PassRefPtr<Thr
eadableWebSocketChannelClientWrapper>); |
86 | 83 |
87 WebSocketChannelClient* m_client; | 84 WebSocketChannelClient* m_client; |
88 // ThreadSafeRefCounted must not have String member variables. | 85 // ThreadSafeRefCounted must not have String member variables. |
89 Vector<UChar> m_subprotocol; | 86 Vector<UChar> m_subprotocol; |
90 Vector<UChar> m_extensions; | 87 Vector<UChar> m_extensions; |
91 bool m_suspended; | 88 bool m_suspended; |
92 Vector<OwnPtr<ExecutionContextTask> > m_pendingTasks; | 89 Vector<OwnPtr<ExecutionContextTask> > m_pendingTasks; |
93 }; | 90 }; |
94 | 91 |
95 } // namespace WebCore | 92 } // namespace WebCore |
96 | 93 |
97 #endif // ThreadableWebSocketChannelClientWrapper_h | 94 #endif // ThreadableWebSocketChannelClientWrapper_h |
OLD | NEW |