Add ICU message format support
[chromium-blink-merge.git] / mojo / services / network / web_socket_impl.h
blob0f26fff9a5e9bba84ef42b69d77270ff8bc17060
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/strong_binding.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 WebSocket {
24 public:
25 WebSocketImpl(NetworkContext* context,
26 scoped_ptr<mojo::AppRefCount> app_refcount,
27 InterfaceRequest<WebSocket> request);
28 ~WebSocketImpl() override;
30 private:
31 // WebSocket methods:
32 void Connect(const String& url,
33 Array<String> protocols,
34 const String& origin,
35 ScopedDataPipeConsumerHandle send_stream,
36 WebSocketClientPtr client) override;
37 void Send(bool fin, WebSocket::MessageType type, uint32_t num_bytes) override;
38 void FlowControl(int64_t quota) override;
39 void Close(uint16_t code, const String& reason) override;
41 // Called with the data to send once it has been read from |send_stream_|.
42 void DidReadFromSendStream(bool fin,
43 WebSocket::MessageType type,
44 uint32_t num_bytes,
45 const char* data);
47 // The channel we use to send events to the network.
48 scoped_ptr<net::WebSocketChannel> channel_;
49 ScopedDataPipeConsumerHandle send_stream_;
50 scoped_ptr<WebSocketReadQueue> read_queue_;
51 NetworkContext* context_;
52 scoped_ptr<mojo::AppRefCount> app_refcount_;
53 StrongBinding<WebSocket> binding_;
56 } // namespace mojo
58 #endif // MOJO_SERVICES_NETWORK_WEB_SOCKET_IMPL_H_