Chromium Code Reviews| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 // WebSocket extensions through to the renderer to make it visible to | 62 // WebSocket extensions through to the renderer to make it visible to |
| 63 // Javascript. | 63 // Javascript. |
| 64 virtual void OnAddChannelResponse( | 64 virtual void OnAddChannelResponse( |
| 65 bool fail, | 65 bool fail, |
| 66 const std::string& selected_subprotocol) OVERRIDE; | 66 const std::string& selected_subprotocol) OVERRIDE; |
| 67 virtual void OnDataFrame(bool fin, | 67 virtual void OnDataFrame(bool fin, |
| 68 WebSocketMessageType type, | 68 WebSocketMessageType type, |
| 69 const std::vector<char>& data) OVERRIDE; | 69 const std::vector<char>& data) OVERRIDE; |
| 70 virtual void OnClosingHandshake() OVERRIDE; | 70 virtual void OnClosingHandshake() OVERRIDE; |
| 71 virtual void OnFlowControl(int64 quota) OVERRIDE; | 71 virtual void OnFlowControl(int64 quota) OVERRIDE; |
| 72 virtual void OnDropChannel(uint16 code, | 72 virtual void OnDropChannel(bool fail, |
| 73 uint16 code, | |
| 73 const std::string& reason) OVERRIDE; | 74 const std::string& reason) OVERRIDE; |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 WebSocketDispatcherHost* const dispatcher_; | 77 WebSocketDispatcherHost* const dispatcher_; |
| 77 const int routing_id_; | 78 const int routing_id_; |
| 78 | 79 |
| 79 DISALLOW_COPY_AND_ASSIGN(WebSocketEventHandler); | 80 DISALLOW_COPY_AND_ASSIGN(WebSocketEventHandler); |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 WebSocketEventHandler::WebSocketEventHandler( | 83 WebSocketEventHandler::WebSocketEventHandler( |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 106 void WebSocketEventHandler::OnClosingHandshake() { | 107 void WebSocketEventHandler::OnClosingHandshake() { |
| 107 dispatcher_->SendClosing(routing_id_); | 108 dispatcher_->SendClosing(routing_id_); |
| 108 // |this| may have been deleted here. | 109 // |this| may have been deleted here. |
| 109 } | 110 } |
| 110 | 111 |
| 111 void WebSocketEventHandler::OnFlowControl(int64 quota) { | 112 void WebSocketEventHandler::OnFlowControl(int64 quota) { |
| 112 dispatcher_->SendFlowControl(routing_id_, quota); | 113 dispatcher_->SendFlowControl(routing_id_, quota); |
| 113 // |this| may have been deleted here. | 114 // |this| may have been deleted here. |
| 114 } | 115 } |
| 115 | 116 |
| 116 void WebSocketEventHandler::OnDropChannel(uint16 code, | 117 void WebSocketEventHandler::OnDropChannel(bool fail, |
| 118 uint16 code, | |
| 117 const std::string& reason) { | 119 const std::string& reason) { |
| 118 dispatcher_->DoDropChannel(routing_id_, code, reason); | 120 dispatcher_->DoDropChannel(routing_id_, fail, code, reason); |
| 119 // |this| has been deleted here. | 121 // |this| has been deleted here. |
| 120 } | 122 } |
| 121 | 123 |
| 122 } // namespace | 124 } // namespace |
| 123 | 125 |
| 124 WebSocketHost::WebSocketHost(int routing_id, | 126 WebSocketHost::WebSocketHost(int routing_id, |
| 125 WebSocketDispatcherHost* dispatcher, | 127 WebSocketDispatcherHost* dispatcher, |
| 126 net::URLRequestContext* url_request_context) { | 128 net::URLRequestContext* url_request_context) { |
| 127 DVLOG(1) << "WebSocketHost: created routing_id= " << routing_id; | 129 DVLOG(1) << "WebSocketHost: created routing_id= " << routing_id; |
| 128 scoped_ptr<net::WebSocketEventInterface> event_interface( | 130 scoped_ptr<net::WebSocketEventInterface> event_interface( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 channel_->SendFrame(fin, MessageTypeToOpCode(type), data); | 170 channel_->SendFrame(fin, MessageTypeToOpCode(type), data); |
| 169 } | 171 } |
| 170 | 172 |
| 171 void WebSocketHost::OnFlowControl(int64 quota) { | 173 void WebSocketHost::OnFlowControl(int64 quota) { |
| 172 DVLOG(3) << "WebSocketHost::OnFlowControl" | 174 DVLOG(3) << "WebSocketHost::OnFlowControl" |
| 173 << " routing_id= " << routing_id_ << " quota= " << quota; | 175 << " routing_id= " << routing_id_ << " quota= " << quota; |
| 174 | 176 |
| 175 channel_->SendFlowControl(quota); | 177 channel_->SendFlowControl(quota); |
| 176 } | 178 } |
| 177 | 179 |
| 178 void WebSocketHost::OnDropChannel(uint16 code, const std::string& reason) { | 180 void WebSocketHost::OnDropChannel(bool fail, |
| 181 uint16 code, | |
| 182 const std::string& reason) { | |
| 179 DVLOG(3) << "WebSocketDispatcherHost::OnDropChannel" | 183 DVLOG(3) << "WebSocketDispatcherHost::OnDropChannel" |
| 180 << " routing_id= " << routing_id_ << " code= " << code | 184 << " routing_id= " << routing_id_ << " fail = " << fail |
| 181 << " reason= " << reason; | 185 << " code= " << code << " reason= " << reason; |
| 182 | 186 |
| 187 // TODO(yhirano): Use |fail| appropriately. | |
|
Adam Rice
2013/10/23 03:18:06
We should just delete the WebSocketChannel if |fai
yhirano
2013/10/23 05:42:23
Will do in a future CL.
| |
| 183 channel_->StartClosingHandshake(code, reason); | 188 channel_->StartClosingHandshake(code, reason); |
| 184 } | 189 } |
| 185 | 190 |
| 186 | 191 |
| 187 } // namespace content | 192 } // namespace content |
| OLD | NEW |