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