Index: Source/web/WebSocketChannelClientProxy.h |
diff --git a/Source/web/WebSocketImpl.h b/Source/web/WebSocketChannelClientProxy.h |
similarity index 50% |
copy from Source/web/WebSocketImpl.h |
copy to Source/web/WebSocketChannelClientProxy.h |
index 08481864a81311c5a7dec7f8e1f8bbd528a9ae18..d2832afe39a93a8648247ae41a32da597efa7b42 100644 |
--- a/Source/web/WebSocketImpl.h |
+++ b/Source/web/WebSocketChannelClientProxy.h |
@@ -28,68 +28,73 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef WebSocketImpl_h |
-#define WebSocketImpl_h |
+#ifndef WebSocketChannelClientProxy_h |
+#define WebSocketChannelClientProxy_h |
#include "modules/websockets/WebSocketChannelClient.h" |
#include "platform/heap/Handle.h" |
-#include "public/platform/WebCommon.h" |
-#include "public/platform/WebString.h" |
-#include "public/web/WebSocket.h" |
-#include "public/web/WebSocketClient.h" |
-#include "wtf/OwnPtr.h" |
-#include "wtf/RefPtr.h" |
+#include "web/WebSocketImpl.h" |
+#include "wtf/PassOwnPtr.h" |
+#include "wtf/Vector.h" |
+#include "wtf/text/WTFString.h" |
namespace blink { class WebSocketChannel; } |
tyoshino (SeeGerritForStatus)
2014/08/04 03:36:07
remove
haraken
2014/08/04 05:54:33
Done.
|
namespace blink { |
-class WebDocument; |
-class WebURL; |
- |
-class WebSocketImpl FINAL : public NoBaseWillBeGarbageCollectedFinalized<WebSocketImpl>, public WebSocket, public blink::WebSocketChannelClient { |
- WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebSocketImpl) |
+// Ideally we want to simply make WebSocketImpl inherit from |
+// WebSocketChannelClient, but we cannot do that because WebSocketChannelClient |
+// needs to be on Oilpan's heap whereas WebSocketImpl cannot be on Oilpan's |
+// heap. Thus we need to introduce a proxy class to decouple WebSocketImpl |
+// from WebSocketChannelClient. |
+class WebSocketChannelClientProxy FINAL : public NoBaseWillBeGarbageCollectedFinalized<WebSocketChannelClientProxy>, public blink::WebSocketChannelClient { |
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebSocketChannelClientProxy) |
public: |
- WebSocketImpl(const WebDocument&, WebSocketClient*); |
- virtual ~WebSocketImpl(); |
- |
- bool isNull() const { return !m_private; } |
- |
- virtual BinaryType binaryType() const OVERRIDE; |
- virtual bool setBinaryType(BinaryType) OVERRIDE; |
- virtual void connect(const WebURL&, const WebString& protocol) OVERRIDE; |
- virtual WebString subprotocol() OVERRIDE; |
- virtual WebString extensions() OVERRIDE; |
- virtual bool sendText(const WebString&) OVERRIDE; |
- virtual bool sendArrayBuffer(const WebArrayBuffer&) OVERRIDE; |
- virtual unsigned long bufferedAmount() const OVERRIDE; |
- virtual void close(int code, const WebString& reason) OVERRIDE; |
- virtual void fail(const WebString& reason) OVERRIDE; |
- virtual void disconnect() OVERRIDE; |
+ static PassOwnPtrWillBeRawPtr<WebSocketChannelClientProxy> create(WebSocketImpl* impl) |
+ { |
+ return adoptPtrWillBeNoop(new WebSocketChannelClientProxy(impl)); |
+ } |
- // WebSocketChannelClient |
- virtual void didConnect(const String& subprotocol, const String& extensions) OVERRIDE; |
- virtual void didReceiveMessage(const String& message) OVERRIDE; |
- virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData) OVERRIDE; |
- virtual void didReceiveMessageError() OVERRIDE; |
- virtual void didConsumeBufferedAmount(unsigned long consumed) OVERRIDE; |
- virtual void didStartClosingHandshake() OVERRIDE; |
- virtual void didClose(ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) OVERRIDE; |
- |
- virtual void trace(blink::Visitor*) OVERRIDE; |
+ virtual void didConnect(const String& subprotocol, const String& extensions) OVERRIDE |
+ { |
+ m_impl->didConnect(subprotocol, extensions); |
+ } |
+ virtual void didReceiveMessage(const String& message) OVERRIDE |
+ { |
+ m_impl->didReceiveMessage(message); |
+ } |
+ virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData) OVERRIDE |
+ { |
+ m_impl->didReceiveBinaryData(binaryData); |
+ } |
+ virtual void didReceiveMessageError() OVERRIDE |
+ { |
+ m_impl->didReceiveMessageError(); |
+ } |
+ virtual void didConsumeBufferedAmount(unsigned long consumed) OVERRIDE |
+ { |
+ m_impl->didConsumeBufferedAmount(consumed); |
+ } |
+ virtual void didStartClosingHandshake() OVERRIDE |
+ { |
+ m_impl->didStartClosingHandshake(); |
+ } |
+ virtual void didClose(ClosingHandshakeCompletionStatus status, unsigned short code, const String& reason) OVERRIDE |
+ { |
+ WebSocketImpl* impl = m_impl; |
+ m_impl = nullptr; |
+ impl->didClose(status, code, reason); |
+ } |
private: |
- RefPtrWillBeMember<blink::WebSocketChannel> m_private; |
- WebSocketClient* m_client; |
- BinaryType m_binaryType; |
- WebString m_subprotocol; |
- WebString m_extensions; |
- bool m_isClosingOrClosed; |
- // m_bufferedAmount includes m_bufferedAmountAfterClose. |
- unsigned long m_bufferedAmount; |
- unsigned long m_bufferedAmountAfterClose; |
+ explicit WebSocketChannelClientProxy(WebSocketImpl* impl) |
+ : m_impl(impl) |
+ { |
+ } |
+ |
+ WebSocketImpl* m_impl; |
}; |
} // namespace blink |
-#endif // WebWebSocketChannelImpl_h |
+#endif // WebSocketChannelClientProxy_h |