Chromium Code Reviews| 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 | 51 |
| 52 // 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. |
| 53 String subprotocol() const; | 53 String subprotocol() const; |
| 54 void setSubprotocol(const String&); | 54 void setSubprotocol(const String&); |
| 55 String extensions() const; | 55 String extensions() const; |
| 56 void setExtensions(const String&); | 56 void setExtensions(const String&); |
| 57 | 57 |
| 58 void clearClient(); | 58 void clearClient(); |
| 59 | 59 |
| 60 void didConnect(); | 60 void didConnect(); |
| 61 void didReceiveMessage(const String& message); | 61 void didReceiveMessage(const String& message); |
| 62 void didReceiveBinaryData(PassOwnPtr<Vector<char> >); | 62 void didReceiveBinaryData(PassOwnPtr<Vector<char> >); |
| 63 void didUpdateBufferedAmount(unsigned long bufferedAmount); | 63 void didUpdateBufferedAmount(unsigned long bufferedAmount); |
| 64 void didStartClosingHandshake(); | 64 void didStartClosingHandshake(); |
| 65 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); |
| 66 void didReceiveMessageError(); | 66 void didReceiveMessageError(); |
| 67 | 67 |
| 68 void suspend(); | 68 void suspend(); |
| 69 void resume(); | 69 void resume(); |
| 70 | 70 |
| 71 void trace(Visitor*) { } | |
| 72 | |
| 71 private: | 73 private: |
| 72 ThreadableWebSocketChannelClientWrapper(WebSocketChannelClient*); | 74 ThreadableWebSocketChannelClientWrapper(WebSocketChannelClient*); |
| 73 | 75 |
| 74 void processPendingTasks(); | 76 void processPendingTasks(); |
| 75 | 77 |
| 76 static void didConnectCallback(ExecutionContext*, PassRefPtr<ThreadableWebSo cketChannelClientWrapper>); | 78 static void didConnectCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<Thr eadableWebSocketChannelClientWrapper>); |
| 77 static void didReceiveMessageCallback(ExecutionContext*, PassRefPtr<Threadab leWebSocketChannelClientWrapper>, const String& message); | 79 static void didReceiveMessageCallback(ExecutionContext*, PassRefPtrWillBeRaw Ptr<ThreadableWebSocketChannelClientWrapper>, const String& message); |
| 78 static void didReceiveBinaryDataCallback(ExecutionContext*, PassRefPtr<Threa dableWebSocketChannelClientWrapper>, PassOwnPtr<Vector<char> >); | 80 static void didReceiveBinaryDataCallback(ExecutionContext*, PassRefPtrWillBe RawPtr<ThreadableWebSocketChannelClientWrapper>, PassOwnPtr<Vector<char> >); |
| 79 static void didUpdateBufferedAmountCallback(ExecutionContext*, PassRefPtr<Th readableWebSocketChannelClientWrapper>, unsigned long bufferedAmount); | 81 static void didUpdateBufferedAmountCallback(ExecutionContext*, PassRefPtrWil lBeRawPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long bufferedAmount ); |
| 80 static void didStartClosingHandshakeCallback(ExecutionContext*, PassRefPtr<T hreadableWebSocketChannelClientWrapper>); | 82 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); | 83 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>); | 84 static void didReceiveMessageErrorCallback(ExecutionContext*, PassRefPtrWill BeRawPtr<ThreadableWebSocketChannelClientWrapper>); |
| 83 | 85 |
| 84 WebSocketChannelClient* m_client; | 86 WebSocketChannelClient* m_client; |
|
haraken
2014/05/07 07:45:16
This raw pointer is safe because it's explicitly c
| |
| 85 // ThreadSafeRefCounted must not have String member variables. | 87 // ThreadSafeRefCounted must not have String member variables. |
| 86 Vector<UChar> m_subprotocol; | 88 Vector<UChar> m_subprotocol; |
| 87 Vector<UChar> m_extensions; | 89 Vector<UChar> m_extensions; |
| 88 bool m_suspended; | 90 bool m_suspended; |
| 89 Vector<OwnPtr<ExecutionContextTask> > m_pendingTasks; | 91 Vector<OwnPtr<ExecutionContextTask> > m_pendingTasks; |
| 90 }; | 92 }; |
| 91 | 93 |
| 92 } // namespace WebCore | 94 } // namespace WebCore |
| 93 | 95 |
| 94 #endif // ThreadableWebSocketChannelClientWrapper_h | 96 #endif // ThreadableWebSocketChannelClientWrapper_h |
| OLD | NEW |