Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1843)

Unified Diff: Source/web/WebSocketChannelClientProxy.h

Issue 419973007: Decouple WebSocketChannelClient from WebSocketImpl (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/web/WebSocketImpl.h » ('j') | Source/web/WebSocketImpl.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebSocketChannelClientProxy.h
diff --git a/Source/web/WebSocketImpl.h b/Source/web/WebSocketChannelClientProxy.h
similarity index 52%
copy from Source/web/WebSocketImpl.h
copy to Source/web/WebSocketChannelClientProxy.h
index 08481864a81311c5a7dec7f8e1f8bbd528a9ae18..a7bb69771370322d88088a79fdaf6760374e1c80 100644
--- a/Source/web/WebSocketImpl.h
+++ b/Source/web/WebSocketChannelClientProxy.h
@@ -28,68 +28,72 @@
* 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"
yhirano 2014/08/04 01:05:53 No need to include WebSocketClient.h
haraken 2014/08/04 01:21:57 We need to include WebSocketClient.h for ClosingHa
yhirano 2014/08/04 01:48:28 ClosingHandshakeCompletionStatus used in this head
haraken 2014/08/04 02:34:17 You're right. Removed WebSocketClient.h from inclu
+#include "web/WebSocketImpl.h"
#include "wtf/OwnPtr.h"
yhirano 2014/08/04 01:05:53 PassOwnPtr.h instead of OwnPtr.h
haraken 2014/08/04 01:21:57 Done.
#include "wtf/RefPtr.h"
yhirano 2014/08/04 01:05:52 No need to include RefPtr.h
haraken 2014/08/04 01:21:57 Done.
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
namespace blink { class WebSocketChannel; }
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,
yhirano 2014/08/04 01:05:52 Please wrap comments in 80 columns.
haraken 2014/08/04 01:21:57 Done.
+// 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
+ {
+ m_impl->didClose(status, code, reason);
yhirano 2014/08/04 01:05:52 Clearing m_impl would be good. WebSocketImpl* imp
haraken 2014/08/04 01:21:57 Done.
+ }
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
« no previous file with comments | « no previous file | Source/web/WebSocketImpl.h » ('j') | Source/web/WebSocketImpl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698