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