| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WebSocketChannelClientProxy_h | 5 #ifndef WebPepperSocketChannelClientProxy_h |
| 6 #define WebSocketChannelClientProxy_h | 6 #define WebPepperSocketChannelClientProxy_h |
| 7 | 7 |
| 8 #include "modules/websockets/WebSocketChannelClient.h" | 8 #include "modules/websockets/WebSocketChannelClient.h" |
| 9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
| 10 #include "web/WebSocketImpl.h" | 10 #include "web/WebPepperSocketImpl.h" |
| 11 #include "wtf/PassOwnPtr.h" | 11 #include "wtf/PassOwnPtr.h" |
| 12 #include "wtf/Vector.h" | 12 #include "wtf/Vector.h" |
| 13 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
| 14 #include <stdint.h> | 14 #include <stdint.h> |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 // Ideally we want to simply make WebSocketImpl inherit from | 18 // Ideally we want to simply make WebPepperSocketImpl inherit from |
| 19 // WebSocketChannelClient, but we cannot do that because WebSocketChannelClient | 19 // WebPepperSocketChannelClient, but we cannot do that because |
| 20 // needs to be on Oilpan's heap whereas WebSocketImpl cannot be on Oilpan's | 20 // WebSocketChannelClient needs to be on Oilpan's heap whereas |
| 21 // heap. Thus we need to introduce a proxy class to decouple WebSocketImpl | 21 // WebPepperSocketImpl cannot be on Oilpan's heap. Thus we need to introduce a |
| 22 // from WebSocketChannelClient. | 22 // proxy class to decouple WebPepperSocketImpl from WebSocketChannelClient. |
| 23 class WebSocketChannelClientProxy final : public GarbageCollectedFinalized<WebSo
cketChannelClientProxy>, public WebSocketChannelClient { | 23 class WebPepperSocketChannelClientProxy final : public GarbageCollectedFinalized
<WebPepperSocketChannelClientProxy>, public WebSocketChannelClient { |
| 24 USING_GARBAGE_COLLECTED_MIXIN(WebSocketChannelClientProxy) | 24 USING_GARBAGE_COLLECTED_MIXIN(WebPepperSocketChannelClientProxy) |
| 25 public: | 25 public: |
| 26 static WebSocketChannelClientProxy* create(WebSocketImpl* impl) | 26 static WebPepperSocketChannelClientProxy* create(WebPepperSocketImpl* impl) |
| 27 { | 27 { |
| 28 return new WebSocketChannelClientProxy(impl); | 28 return new WebPepperSocketChannelClientProxy(impl); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void didConnect(const String& subprotocol, const String& extensions) overrid
e | 31 void didConnect(const String& subprotocol, const String& extensions) overrid
e |
| 32 { | 32 { |
| 33 m_impl->didConnect(subprotocol, extensions); | 33 m_impl->didConnect(subprotocol, extensions); |
| 34 } | 34 } |
| 35 void didReceiveTextMessage(const String& payload) override | 35 void didReceiveTextMessage(const String& payload) override |
| 36 { | 36 { |
| 37 m_impl->didReceiveTextMessage(payload); | 37 m_impl->didReceiveTextMessage(payload); |
| 38 } | 38 } |
| 39 void didReceiveBinaryMessage(PassOwnPtr<Vector<char>> payload) override | 39 void didReceiveBinaryMessage(PassOwnPtr<Vector<char>> payload) override |
| 40 { | 40 { |
| 41 m_impl->didReceiveBinaryMessage(payload); | 41 m_impl->didReceiveBinaryMessage(payload); |
| 42 } | 42 } |
| 43 void didError() override | 43 void didError() override |
| 44 { | 44 { |
| 45 m_impl->didError(); | 45 m_impl->didError(); |
| 46 } | 46 } |
| 47 void didConsumeBufferedAmount(uint64_t consumed) override | 47 void didConsumeBufferedAmount(uint64_t consumed) override |
| 48 { | 48 { |
| 49 m_impl->didConsumeBufferedAmount(consumed); | 49 m_impl->didConsumeBufferedAmount(consumed); |
| 50 } | 50 } |
| 51 void didStartClosingHandshake() override | 51 void didStartClosingHandshake() override |
| 52 { | 52 { |
| 53 m_impl->didStartClosingHandshake(); | 53 m_impl->didStartClosingHandshake(); |
| 54 } | 54 } |
| 55 void didClose(ClosingHandshakeCompletionStatus status, unsigned short code,
const String& reason) override | 55 void didClose(ClosingHandshakeCompletionStatus status, unsigned short code,
const String& reason) override |
| 56 { | 56 { |
| 57 WebSocketImpl* impl = m_impl; | 57 WebPepperSocketImpl* impl = m_impl; |
| 58 m_impl = nullptr; | 58 m_impl = nullptr; |
| 59 impl->didClose(status, code, reason); | 59 impl->didClose(status, code, reason); |
| 60 } | 60 } |
| 61 | 61 |
| 62 DEFINE_INLINE_VIRTUAL_TRACE() | 62 DEFINE_INLINE_VIRTUAL_TRACE() |
| 63 { | 63 { |
| 64 WebSocketChannelClient::trace(visitor); | 64 WebSocketChannelClient::trace(visitor); |
| 65 } | 65 } |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 explicit WebSocketChannelClientProxy(WebSocketImpl* impl) | 68 explicit WebPepperSocketChannelClientProxy(WebPepperSocketImpl* impl) |
| 69 : m_impl(impl) | 69 : m_impl(impl) |
| 70 { | 70 { |
| 71 } | 71 } |
| 72 | 72 |
| 73 WebSocketImpl* m_impl; | 73 WebPepperSocketImpl* m_impl; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 } // namespace blink | 76 } // namespace blink |
| 77 | 77 |
| 78 #endif // WebSocketChannelClientProxy_h | 78 #endif // WebPepperSocketChannelClientProxy_h |
| OLD | NEW |