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.
5 #ifndef MOJO_SERVICES_NETWORK_WEB_SOCKET_IMPL_H_
6 #define MOJO_SERVICES_NETWORK_WEB_SOCKET_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "mojo/services/network/public/interfaces/web_socket.mojom.h"
10 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
13 class WebSocketChannel
;
18 class WebSocketReadQueue
;
20 // Forms a bridge between the WebSocket mojo interface and the net::WebSocket
22 class WebSocketImpl
: public InterfaceImpl
<WebSocket
> {
24 explicit WebSocketImpl(NetworkContext
* context
);
25 ~WebSocketImpl() override
;
29 void Connect(const String
& url
,
30 Array
<String
> protocols
,
32 ScopedDataPipeConsumerHandle send_stream
,
33 WebSocketClientPtr client
) override
;
34 void Send(bool fin
, WebSocket::MessageType type
, uint32_t num_bytes
) override
;
35 void FlowControl(int64_t quota
) override
;
36 void Close(uint16_t code
, const String
& reason
) override
;
38 // Called with the data to send once it has been read from |send_stream_|.
39 void DidReadFromSendStream(bool fin
,
40 WebSocket::MessageType type
,
44 // The channel we use to send events to the network.
45 scoped_ptr
<net::WebSocketChannel
> channel_
;
46 ScopedDataPipeConsumerHandle send_stream_
;
47 scoped_ptr
<WebSocketReadQueue
> read_queue_
;
48 NetworkContext
* context_
;
53 #endif // MOJO_SERVICES_NETWORK_WEB_SOCKET_IMPL_H_