| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #ifndef ThreadableWebSocketChannelClientWrapper_h | 31 #ifndef ThreadableWebSocketChannelClientWrapper_h |
| 32 #define ThreadableWebSocketChannelClientWrapper_h | 32 #define ThreadableWebSocketChannelClientWrapper_h |
| 33 | 33 |
| 34 #if ENABLE(WEB_SOCKETS) && ENABLE(WORKERS) | 34 #if ENABLE(WEB_SOCKETS) && ENABLE(WORKERS) |
| 35 | 35 |
| 36 #include "PlatformString.h" | 36 #include "PlatformString.h" |
| 37 #include "ScriptExecutionContext.h" | 37 #include "ScriptExecutionContext.h" |
| 38 #include "ThreadableWebSocketChannel.h" | 38 #include "ThreadableWebSocketChannel.h" |
| 39 #include "WebSocketChannelClient.h" | 39 #include "WebSocketChannelClient.h" |
| 40 #include "WorkerThreadableWebSocketChannel.h" |
| 40 #include <wtf/Forward.h> | 41 #include <wtf/Forward.h> |
| 41 #include <wtf/OwnPtr.h> | 42 #include <wtf/OwnPtr.h> |
| 42 #include <wtf/PassOwnPtr.h> | 43 #include <wtf/PassOwnPtr.h> |
| 43 #include <wtf/Threading.h> | 44 #include <wtf/Threading.h> |
| 44 #include <wtf/Vector.h> | 45 #include <wtf/Vector.h> |
| 45 | 46 |
| 46 namespace WebCore { | 47 namespace WebCore { |
| 47 | 48 |
| 48 class ScriptExecutionContext; | 49 class ScriptExecutionContext; |
| 49 class WebSocketChannelClient; | 50 class WebSocketChannelClient; |
| 50 | 51 |
| 51 class ThreadableWebSocketChannelClientWrapper : public ThreadSafeRefCounted<Thre
adableWebSocketChannelClientWrapper> { | 52 class ThreadableWebSocketChannelClientWrapper : public ThreadSafeRefCounted<Thre
adableWebSocketChannelClientWrapper> { |
| 52 public: | 53 public: |
| 53 static PassRefPtr<ThreadableWebSocketChannelClientWrapper> create(ScriptExec
utionContext*, WebSocketChannelClient*); | 54 static PassRefPtr<ThreadableWebSocketChannelClientWrapper> create(ScriptExec
utionContext*, WebSocketChannelClient*); |
| 54 | 55 |
| 55 void clearSyncMethodDone(); | 56 void clearSyncMethodDone(); |
| 56 void setSyncMethodDone(); | 57 void setSyncMethodDone(); |
| 57 bool syncMethodDone() const; | 58 bool syncMethodDone() const; |
| 58 | 59 |
| 60 WorkerThreadableWebSocketChannel::Peer* peer() const; |
| 61 void didCreateWebSocketChannel(WorkerThreadableWebSocketChannel::Peer*, bool
useHixie76Protocol); |
| 62 void clearPeer(); |
| 63 |
| 59 // The value of useHixie76Protocol flag is cachable; this value is saved aft
er WebSocketChannel (on the main | 64 // The value of useHixie76Protocol flag is cachable; this value is saved aft
er WebSocketChannel (on the main |
| 60 // thread) is constructed. | 65 // thread) is constructed. |
| 61 bool useHixie76Protocol() const; | 66 bool useHixie76Protocol() const; |
| 62 void setUseHixie76Protocol(bool); | |
| 63 | 67 |
| 64 // Subprotocol and extensions are cached too. Will be available when didConn
ect() callback is invoked. | 68 // Subprotocol and extensions are cached too. Will be available when didConn
ect() callback is invoked. |
| 65 String subprotocol() const; | 69 String subprotocol() const; |
| 66 void setSubprotocol(const String&); | 70 void setSubprotocol(const String&); |
| 67 String extensions() const; | 71 String extensions() const; |
| 68 void setExtensions(const String&); | 72 void setExtensions(const String&); |
| 69 | 73 |
| 70 ThreadableWebSocketChannel::SendResult sendRequestResult() const; | 74 ThreadableWebSocketChannel::SendResult sendRequestResult() const; |
| 71 void setSendRequestResult(ThreadableWebSocketChannel::SendResult); | 75 void setSendRequestResult(ThreadableWebSocketChannel::SendResult); |
| 72 | 76 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 93 static void didConnectCallback(ScriptExecutionContext*, PassRefPtr<Threadabl
eWebSocketChannelClientWrapper>); | 97 static void didConnectCallback(ScriptExecutionContext*, PassRefPtr<Threadabl
eWebSocketChannelClientWrapper>); |
| 94 static void didReceiveMessageCallback(ScriptExecutionContext*, PassRefPtr<Th
readableWebSocketChannelClientWrapper>, const String& message); | 98 static void didReceiveMessageCallback(ScriptExecutionContext*, PassRefPtr<Th
readableWebSocketChannelClientWrapper>, const String& message); |
| 95 static void didReceiveBinaryDataCallback(ScriptExecutionContext*, PassRefPtr
<ThreadableWebSocketChannelClientWrapper>, PassOwnPtr<Vector<char> >); | 99 static void didReceiveBinaryDataCallback(ScriptExecutionContext*, PassRefPtr
<ThreadableWebSocketChannelClientWrapper>, PassOwnPtr<Vector<char> >); |
| 96 static void didUpdateBufferedAmountCallback(ScriptExecutionContext*, PassRef
Ptr<ThreadableWebSocketChannelClientWrapper>, unsigned long bufferedAmount); | 100 static void didUpdateBufferedAmountCallback(ScriptExecutionContext*, PassRef
Ptr<ThreadableWebSocketChannelClientWrapper>, unsigned long bufferedAmount); |
| 97 static void didStartClosingHandshakeCallback(ScriptExecutionContext*, PassRe
fPtr<ThreadableWebSocketChannelClientWrapper>); | 101 static void didStartClosingHandshakeCallback(ScriptExecutionContext*, PassRe
fPtr<ThreadableWebSocketChannelClientWrapper>); |
| 98 static void didCloseCallback(ScriptExecutionContext*, PassRefPtr<ThreadableW
ebSocketChannelClientWrapper>, unsigned long unhandledBufferedAmount, WebSocketC
hannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const Strin
g& reason); | 102 static void didCloseCallback(ScriptExecutionContext*, PassRefPtr<ThreadableW
ebSocketChannelClientWrapper>, unsigned long unhandledBufferedAmount, WebSocketC
hannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const Strin
g& reason); |
| 99 static void processPendingTasksCallback(ScriptExecutionContext*, PassRefPtr<
ThreadableWebSocketChannelClientWrapper>); | 103 static void processPendingTasksCallback(ScriptExecutionContext*, PassRefPtr<
ThreadableWebSocketChannelClientWrapper>); |
| 100 | 104 |
| 101 ScriptExecutionContext* m_context; | 105 ScriptExecutionContext* m_context; |
| 102 WebSocketChannelClient* m_client; | 106 WebSocketChannelClient* m_client; |
| 107 WorkerThreadableWebSocketChannel::Peer* m_peer; |
| 103 bool m_syncMethodDone; | 108 bool m_syncMethodDone; |
| 104 bool m_useHixie76Protocol; | 109 bool m_useHixie76Protocol; |
| 105 // ThreadSafeRefCounted must not have String member variables. | 110 // ThreadSafeRefCounted must not have String member variables. |
| 106 Vector<UChar> m_subprotocol; | 111 Vector<UChar> m_subprotocol; |
| 107 Vector<UChar> m_extensions; | 112 Vector<UChar> m_extensions; |
| 108 ThreadableWebSocketChannel::SendResult m_sendRequestResult; | 113 ThreadableWebSocketChannel::SendResult m_sendRequestResult; |
| 109 unsigned long m_bufferedAmount; | 114 unsigned long m_bufferedAmount; |
| 110 bool m_suspended; | 115 bool m_suspended; |
| 111 Vector<OwnPtr<ScriptExecutionContext::Task> > m_pendingTasks; | 116 Vector<OwnPtr<ScriptExecutionContext::Task> > m_pendingTasks; |
| 112 }; | 117 }; |
| 113 | 118 |
| 114 } // namespace WebCore | 119 } // namespace WebCore |
| 115 | 120 |
| 116 #endif // ENABLE(WEB_SOCKETS) | 121 #endif // ENABLE(WEB_SOCKETS) |
| 117 | 122 |
| 118 #endif // ThreadableWebSocketChannelClientWrapper_h | 123 #endif // ThreadableWebSocketChannelClientWrapper_h |
| OLD | NEW |