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