Introduce about flags for chrome hosted mode
[chromium-blink-merge.git] / mojo / services / network / web_socket_impl.h
blob5e8f61f555ad0ab1268e33075daa56665319cd91
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/application/public/cpp/app_lifetime_helper.h"
10 #include "mojo/services/network/public/interfaces/web_socket.mojom.h"
11 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
13 namespace net {
14 class WebSocketChannel;
15 } // namespace net
17 namespace mojo {
18 class NetworkContext;
19 class WebSocketReadQueue;
21 // Forms a bridge between the WebSocket mojo interface and the net::WebSocket
22 // implementation.
23 class WebSocketImpl : public InterfaceImpl<WebSocket> {
24 public:
25 WebSocketImpl(NetworkContext* context,
26 scoped_ptr<mojo::AppRefCount> app_refcount);
27 ~WebSocketImpl() override;
29 private:
30 // WebSocket methods:
31 void Connect(const String& url,
32 Array<String> protocols,
33 const String& origin,
34 ScopedDataPipeConsumerHandle send_stream,
35 WebSocketClientPtr client) override;
36 void Send(bool fin, WebSocket::MessageType type, uint32_t num_bytes) override;
37 void FlowControl(int64_t quota) override;
38 void Close(uint16_t code, const String& reason) override;
40 // Called with the data to send once it has been read from |send_stream_|.
41 void DidReadFromSendStream(bool fin,
42 WebSocket::MessageType type,
43 uint32_t num_bytes,
44 const char* data);
46 // The channel we use to send events to the network.
47 scoped_ptr<net::WebSocketChannel> channel_;
48 ScopedDataPipeConsumerHandle send_stream_;
49 scoped_ptr<WebSocketReadQueue> read_queue_;
50 NetworkContext* context_;
51 scoped_ptr<mojo::AppRefCount> app_refcount_;
54 } // namespace mojo
56 #endif // MOJO_SERVICES_NETWORK_WEB_SOCKET_IMPL_H_