OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef COMPONENTS_HTML_VIEWER_WEB_SOCKET_HANDLE_IMPL_H_ | |
6 #define COMPONENTS_HTML_VIEWER_WEB_SOCKET_HANDLE_IMPL_H_ | |
7 | |
8 #include <stddef.h> | |
9 #include <stdint.h> | |
10 | |
11 #include "base/macros.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "mojo/message_pump/handle_watcher.h" | |
14 #include "mojo/services/network/public/interfaces/web_socket.mojom.h" | |
15 #include "third_party/WebKit/public/platform/modules/websockets/WebSocketHandle.
h" | |
16 | |
17 namespace mojo { | |
18 class WebSocketFactory; | |
19 class WebSocketWriteQueue; | |
20 } | |
21 | |
22 namespace html_viewer { | |
23 | |
24 class WebSocketClientImpl; | |
25 | |
26 // Implements WebSocketHandle by talking to the mojo WebSocket interface. | |
27 class WebSocketHandleImpl : public blink::WebSocketHandle { | |
28 public: | |
29 explicit WebSocketHandleImpl(mojo::WebSocketFactory* factory); | |
30 | |
31 private: | |
32 friend class WebSocketClientImpl; | |
33 | |
34 ~WebSocketHandleImpl() override; | |
35 | |
36 // blink::WebSocketHandle methods: | |
37 void connect(const blink::WebURL& url, | |
38 const blink::WebVector<blink::WebString>& protocols, | |
39 const blink::WebSecurityOrigin& origin, | |
40 blink::WebSocketHandleClient*) override; | |
41 void send(bool fin, MessageType, const char* data, size_t size) override; | |
42 void flowControl(int64_t quota) override; | |
43 void close(unsigned short code, const blink::WebString& reason) override; | |
44 | |
45 // Called when we finished writing to |send_stream_|. | |
46 void DidWriteToSendStream(bool fin, | |
47 WebSocketHandle::MessageType type, | |
48 uint32_t num_bytes, | |
49 const char* data); | |
50 | |
51 // Called when the socket is closed. | |
52 void Disconnect(); | |
53 | |
54 mojo::WebSocketPtr web_socket_; | |
55 scoped_ptr<WebSocketClientImpl> client_; | |
56 mojo::ScopedDataPipeProducerHandle send_stream_; | |
57 scoped_ptr<mojo::WebSocketWriteQueue> write_queue_; | |
58 // True if close() was called. | |
59 bool did_close_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(WebSocketHandleImpl); | |
62 }; | |
63 | |
64 } // namespace html_viewer | |
65 | |
66 #endif // COMPONENTS_HTML_VIEWER_WEB_SOCKET_HANDLE_IMPL_H_ | |
OLD | NEW |