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