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