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

Side by Side 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, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/web/WebSocketImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WebSocketChannelClientProxy_h
6 #define WebSocketChannelClientProxy_h
7
8 #include "modules/websockets/WebSocketChannelClient.h"
9 #include "platform/heap/Handle.h"
10 #include "web/WebSocketImpl.h"
11 #include "wtf/PassOwnPtr.h"
12 #include "wtf/Vector.h"
13 #include "wtf/text/WTFString.h"
14
15 namespace blink {
16
17 // Ideally we want to simply make WebSocketImpl inherit from
18 // WebSocketChannelClient, but we cannot do that because WebSocketChannelClient
19 // needs to be on Oilpan's heap whereas WebSocketImpl cannot be on Oilpan's
20 // heap. Thus we need to introduce a proxy class to decouple WebSocketImpl
21 // from WebSocketChannelClient.
22 class WebSocketChannelClientProxy FINAL : public NoBaseWillBeGarbageCollectedFin alized<WebSocketChannelClientProxy>, public blink::WebSocketChannelClient {
23 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebSocketChannelClientProxy)
24 public:
25 static PassOwnPtrWillBeRawPtr<WebSocketChannelClientProxy> create(WebSocketI mpl* impl)
26 {
27 return adoptPtrWillBeNoop(new WebSocketChannelClientProxy(impl));
28 }
29
30 virtual void didConnect(const String& subprotocol, const String& extensions) OVERRIDE
31 {
32 m_impl->didConnect(subprotocol, extensions);
33 }
34 virtual void didReceiveMessage(const String& message) OVERRIDE
35 {
36 m_impl->didReceiveMessage(message);
37 }
38 virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData) OVER RIDE
39 {
40 m_impl->didReceiveBinaryData(binaryData);
41 }
42 virtual void didReceiveMessageError() OVERRIDE
43 {
44 m_impl->didReceiveMessageError();
45 }
46 virtual void didConsumeBufferedAmount(unsigned long consumed) OVERRIDE
47 {
48 m_impl->didConsumeBufferedAmount(consumed);
49 }
50 virtual void didStartClosingHandshake() OVERRIDE
51 {
52 m_impl->didStartClosingHandshake();
53 }
54 virtual void didClose(ClosingHandshakeCompletionStatus status, unsigned shor t code, const String& reason) OVERRIDE
55 {
56 WebSocketImpl* impl = m_impl;
57 m_impl = nullptr;
58 impl->didClose(status, code, reason);
59 }
60
61 private:
62 explicit WebSocketChannelClientProxy(WebSocketImpl* impl)
63 : m_impl(impl)
64 {
65 }
66
67 WebSocketImpl* m_impl;
68 };
69
70 } // namespace blink
71
72 #endif // WebSocketChannelClientProxy_h
OLDNEW
« no previous file with comments | « no previous file | Source/web/WebSocketImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698