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 #include "mojo/services/network/web_socket_impl.h" | 5 #include "mojo/services/network/web_socket_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "mojo/common/handle_watcher.h" | 9 #include "mojo/common/handle_watcher.h" |
10 #include "mojo/services/network/network_context.h" | 10 #include "mojo/services/network/network_context.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 WebSocketEventHandler(WebSocketClientPtr client) | 65 WebSocketEventHandler(WebSocketClientPtr client) |
66 : client_(client.Pass()) { | 66 : client_(client.Pass()) { |
67 } | 67 } |
68 virtual ~WebSocketEventHandler() {} | 68 virtual ~WebSocketEventHandler() {} |
69 | 69 |
70 private: | 70 private: |
71 // net::WebSocketEventInterface methods: | 71 // net::WebSocketEventInterface methods: |
72 virtual ChannelState OnAddChannelResponse( | 72 virtual ChannelState OnAddChannelResponse( |
73 bool fail, | 73 bool fail, |
74 const std::string& selected_subprotocol, | 74 const std::string& selected_subprotocol, |
75 const std::string& extensions) OVERRIDE; | 75 const std::string& extensions) override; |
76 virtual ChannelState OnDataFrame(bool fin, | 76 virtual ChannelState OnDataFrame(bool fin, |
77 WebSocketMessageType type, | 77 WebSocketMessageType type, |
78 const std::vector<char>& data) OVERRIDE; | 78 const std::vector<char>& data) override; |
79 virtual ChannelState OnClosingHandshake() OVERRIDE; | 79 virtual ChannelState OnClosingHandshake() override; |
80 virtual ChannelState OnFlowControl(int64 quota) OVERRIDE; | 80 virtual ChannelState OnFlowControl(int64 quota) override; |
81 virtual ChannelState OnDropChannel(bool was_clean, | 81 virtual ChannelState OnDropChannel(bool was_clean, |
82 uint16 code, | 82 uint16 code, |
83 const std::string& reason) OVERRIDE; | 83 const std::string& reason) override; |
84 virtual ChannelState OnFailChannel(const std::string& message) OVERRIDE; | 84 virtual ChannelState OnFailChannel(const std::string& message) override; |
85 virtual ChannelState OnStartOpeningHandshake( | 85 virtual ChannelState OnStartOpeningHandshake( |
86 scoped_ptr<net::WebSocketHandshakeRequestInfo> request) OVERRIDE; | 86 scoped_ptr<net::WebSocketHandshakeRequestInfo> request) override; |
87 virtual ChannelState OnFinishOpeningHandshake( | 87 virtual ChannelState OnFinishOpeningHandshake( |
88 scoped_ptr<net::WebSocketHandshakeResponseInfo> response) OVERRIDE; | 88 scoped_ptr<net::WebSocketHandshakeResponseInfo> response) override; |
89 virtual ChannelState OnSSLCertificateError( | 89 virtual ChannelState OnSSLCertificateError( |
90 scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks, | 90 scoped_ptr<net::WebSocketEventInterface::SSLErrorCallbacks> callbacks, |
91 const GURL& url, | 91 const GURL& url, |
92 const net::SSLInfo& ssl_info, | 92 const net::SSLInfo& ssl_info, |
93 bool fatal) OVERRIDE; | 93 bool fatal) override; |
94 | 94 |
95 // Called once we've written to |receive_stream_|. | 95 // Called once we've written to |receive_stream_|. |
96 void DidWriteToReceiveStream(bool fin, | 96 void DidWriteToReceiveStream(bool fin, |
97 net::WebSocketFrameHeader::OpCode type, | 97 net::WebSocketFrameHeader::OpCode type, |
98 uint32_t num_bytes, | 98 uint32_t num_bytes, |
99 const char* buffer); | 99 const char* buffer); |
100 WebSocketClientPtr client_; | 100 WebSocketClientPtr client_; |
101 ScopedDataPipeProducerHandle receive_stream_; | 101 ScopedDataPipeProducerHandle receive_stream_; |
102 scoped_ptr<WebSocketWriteQueue> write_queue_; | 102 scoped_ptr<WebSocketWriteQueue> write_queue_; |
103 | 103 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 uint32_t num_bytes, | 230 uint32_t num_bytes, |
231 const char* data) { | 231 const char* data) { |
232 std::vector<char> buffer(num_bytes); | 232 std::vector<char> buffer(num_bytes); |
233 memcpy(&buffer[0], data, num_bytes); | 233 memcpy(&buffer[0], data, num_bytes); |
234 DCHECK(channel_); | 234 DCHECK(channel_); |
235 channel_->SendFrame( | 235 channel_->SendFrame( |
236 fin, ConvertTo<net::WebSocketFrameHeader::OpCode>(type), buffer); | 236 fin, ConvertTo<net::WebSocketFrameHeader::OpCode>(type), buffer); |
237 } | 237 } |
238 | 238 |
239 } // namespace mojo | 239 } // namespace mojo |
OLD | NEW |