OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/renderer_host/websocket_host.h" | 5 #include "content/browser/renderer_host/websocket_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "content/browser/renderer_host/websocket_dispatcher_host.h" | 9 #include "content/browser/renderer_host/websocket_dispatcher_host.h" |
10 #include "content/common/websocket_messages.h" | 10 #include "content/common/websocket_messages.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 virtual ChannelState OnAddChannelResponse( | 85 virtual ChannelState OnAddChannelResponse( |
86 bool fail, | 86 bool fail, |
87 const std::string& selected_subprotocol) OVERRIDE; | 87 const std::string& selected_subprotocol) OVERRIDE; |
88 virtual ChannelState OnDataFrame(bool fin, | 88 virtual ChannelState OnDataFrame(bool fin, |
89 WebSocketMessageType type, | 89 WebSocketMessageType type, |
90 const std::vector<char>& data) OVERRIDE; | 90 const std::vector<char>& data) OVERRIDE; |
91 virtual ChannelState OnClosingHandshake() OVERRIDE; | 91 virtual ChannelState OnClosingHandshake() OVERRIDE; |
92 virtual ChannelState OnFlowControl(int64 quota) OVERRIDE; | 92 virtual ChannelState OnFlowControl(int64 quota) OVERRIDE; |
93 virtual ChannelState OnDropChannel(uint16 code, | 93 virtual ChannelState OnDropChannel(uint16 code, |
94 const std::string& reason) OVERRIDE; | 94 const std::string& reason) OVERRIDE; |
| 95 virtual ChannelState OnFailChannel(const std::string& message) OVERRIDE; |
95 | 96 |
96 private: | 97 private: |
97 WebSocketDispatcherHost* const dispatcher_; | 98 WebSocketDispatcherHost* const dispatcher_; |
98 const int routing_id_; | 99 const int routing_id_; |
99 | 100 |
100 DISALLOW_COPY_AND_ASSIGN(WebSocketEventHandler); | 101 DISALLOW_COPY_AND_ASSIGN(WebSocketEventHandler); |
101 }; | 102 }; |
102 | 103 |
103 WebSocketEventHandler::WebSocketEventHandler( | 104 WebSocketEventHandler::WebSocketEventHandler( |
104 WebSocketDispatcherHost* dispatcher, | 105 WebSocketDispatcherHost* dispatcher, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } | 144 } |
144 | 145 |
145 ChannelState WebSocketEventHandler::OnDropChannel(uint16 code, | 146 ChannelState WebSocketEventHandler::OnDropChannel(uint16 code, |
146 const std::string& reason) { | 147 const std::string& reason) { |
147 DVLOG(3) << "WebSocketEventHandler::OnDropChannel" | 148 DVLOG(3) << "WebSocketEventHandler::OnDropChannel" |
148 << " routing_id=" << routing_id_ << " code=" << code | 149 << " routing_id=" << routing_id_ << " code=" << code |
149 << " reason=\"" << reason << "\""; | 150 << " reason=\"" << reason << "\""; |
150 return StateCast(dispatcher_->DoDropChannel(routing_id_, code, reason)); | 151 return StateCast(dispatcher_->DoDropChannel(routing_id_, code, reason)); |
151 } | 152 } |
152 | 153 |
| 154 ChannelState WebSocketEventHandler::OnFailChannel(const std::string& message) { |
| 155 DVLOG(3) << "WebSocketEventHandler::OnFailChannel" |
| 156 << " routing_id=" << routing_id_ |
| 157 << " message=\"" << message << "\""; |
| 158 return StateCast(dispatcher_->NotifyFailure(routing_id_, message)); |
| 159 } |
| 160 |
153 } // namespace | 161 } // namespace |
154 | 162 |
155 WebSocketHost::WebSocketHost(int routing_id, | 163 WebSocketHost::WebSocketHost(int routing_id, |
156 WebSocketDispatcherHost* dispatcher, | 164 WebSocketDispatcherHost* dispatcher, |
157 net::URLRequestContext* url_request_context) | 165 net::URLRequestContext* url_request_context) |
158 : routing_id_(routing_id) { | 166 : routing_id_(routing_id) { |
159 DVLOG(1) << "WebSocketHost: created routing_id=" << routing_id; | 167 DVLOG(1) << "WebSocketHost: created routing_id=" << routing_id; |
160 scoped_ptr<net::WebSocketEventInterface> event_interface( | 168 scoped_ptr<net::WebSocketEventInterface> event_interface( |
161 new WebSocketEventHandler(dispatcher, routing_id)); | 169 new WebSocketEventHandler(dispatcher, routing_id)); |
162 channel_.reset( | 170 channel_.reset( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 DVLOG(3) << "WebSocketHost::OnDropChannel" | 222 DVLOG(3) << "WebSocketHost::OnDropChannel" |
215 << " routing_id=" << routing_id_ << " was_clean=" << was_clean | 223 << " routing_id=" << routing_id_ << " was_clean=" << was_clean |
216 << " code=" << code << " reason=\"" << reason << "\""; | 224 << " code=" << code << " reason=\"" << reason << "\""; |
217 | 225 |
218 // TODO(yhirano): Handle |was_clean| appropriately. | 226 // TODO(yhirano): Handle |was_clean| appropriately. |
219 channel_->StartClosingHandshake(code, reason); | 227 channel_->StartClosingHandshake(code, reason); |
220 } | 228 } |
221 | 229 |
222 | 230 |
223 } // namespace content | 231 } // namespace content |
OLD | NEW |