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 MOJO_SERVICES_NETWORK_WEB_SOCKET_IMPL_H_ | 5 #ifndef MOJO_SERVICES_NETWORK_WEB_SOCKET_IMPL_H_ |
6 #define MOJO_SERVICES_NETWORK_WEB_SOCKET_IMPL_H_ | 6 #define MOJO_SERVICES_NETWORK_WEB_SOCKET_IMPL_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | |
9 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
10 #include "mojo/public/cpp/bindings/interface_impl.h" | 9 #include "mojo/public/cpp/bindings/interface_impl.h" |
11 #include "mojo/services/public/interfaces/network/web_socket.mojom.h" | 10 #include "mojo/services/public/interfaces/network/web_socket.mojom.h" |
12 | 11 |
13 namespace net { | 12 namespace net { |
14 class WebSocketChannel; | 13 class WebSocketChannel; |
15 } // namespace net | 14 } // namespace net |
16 | 15 |
17 namespace mojo { | 16 namespace mojo { |
18 class NetworkContext; | 17 class NetworkContext; |
19 class WebSocketReadQueue; | 18 class WebSocketReadQueue; |
20 | 19 |
21 // Forms a bridge between the WebSocket mojo interface and the net::WebSocket | 20 // Forms a bridge between the WebSocket mojo interface and the net::WebSocket |
22 // implementation. | 21 // implementation. |
23 class WebSocketImpl : public InterfaceImpl<WebSocket> { | 22 class WebSocketImpl : public InterfaceImpl<WebSocket> { |
24 public: | 23 public: |
25 explicit WebSocketImpl(NetworkContext* context); | 24 explicit WebSocketImpl(NetworkContext* context); |
26 virtual ~WebSocketImpl(); | 25 virtual ~WebSocketImpl(); |
27 | 26 |
28 private: | 27 private: |
29 // WebSocket methods: | 28 // WebSocket methods: |
30 virtual void Connect(const String& url, | 29 virtual void Connect(const String& url, |
31 Array<String> protocols, | 30 Array<String> protocols, |
32 const String& origin, | 31 const String& origin, |
33 ScopedDataPipeConsumerHandle send_stream, | 32 ScopedDataPipeConsumerHandle send_stream, |
34 WebSocketClientPtr client) OVERRIDE; | 33 WebSocketClientPtr client) override; |
35 virtual void Send(bool fin, | 34 virtual void Send(bool fin, |
36 WebSocket::MessageType type, | 35 WebSocket::MessageType type, |
37 uint32_t num_bytes) OVERRIDE; | 36 uint32_t num_bytes) override; |
38 virtual void FlowControl(int64_t quota) OVERRIDE; | 37 virtual void FlowControl(int64_t quota) override; |
39 virtual void Close(uint16_t code, const String& reason) OVERRIDE; | 38 virtual void Close(uint16_t code, const String& reason) override; |
40 | 39 |
41 // Called with the data to send once it has been read from |send_stream_|. | 40 // Called with the data to send once it has been read from |send_stream_|. |
42 void DidReadFromSendStream(bool fin, | 41 void DidReadFromSendStream(bool fin, |
43 WebSocket::MessageType type, | 42 WebSocket::MessageType type, |
44 uint32_t num_bytes, | 43 uint32_t num_bytes, |
45 const char* data); | 44 const char* data); |
46 | 45 |
47 // The channel we use to send events to the network. | 46 // The channel we use to send events to the network. |
48 scoped_ptr<net::WebSocketChannel> channel_; | 47 scoped_ptr<net::WebSocketChannel> channel_; |
49 ScopedDataPipeConsumerHandle send_stream_; | 48 ScopedDataPipeConsumerHandle send_stream_; |
50 scoped_ptr<WebSocketReadQueue> read_queue_; | 49 scoped_ptr<WebSocketReadQueue> read_queue_; |
51 NetworkContext* context_; | 50 NetworkContext* context_; |
52 }; | 51 }; |
53 | 52 |
54 } // namespace mojo | 53 } // namespace mojo |
55 | 54 |
56 #endif // MOJO_SERVICES_NETWORK_WEB_SOCKET_IMPL_H_ | 55 #endif // MOJO_SERVICES_NETWORK_WEB_SOCKET_IMPL_H_ |
OLD | NEW |