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