| 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_dispatcher_host.h" | 5 #include "content/browser/renderer_host/websocket_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 return host->OnMessageReceived(message, message_was_ok); | 77 return host->OnMessageReceived(message, message_was_ok); |
| 78 } | 78 } |
| 79 | 79 |
| 80 WebSocketHost* WebSocketDispatcherHost::GetHost(int routing_id) const { | 80 WebSocketHost* WebSocketDispatcherHost::GetHost(int routing_id) const { |
| 81 WebSocketHostTable::const_iterator it = hosts_.find(routing_id); | 81 WebSocketHostTable::const_iterator it = hosts_.find(routing_id); |
| 82 return it == hosts_.end() ? NULL : it->second; | 82 return it == hosts_.end() ? NULL : it->second; |
| 83 } | 83 } |
| 84 | 84 |
| 85 WebSocketHostState WebSocketDispatcherHost::SendOrDrop(IPC::Message* message) { | 85 WebSocketHostState WebSocketDispatcherHost::SendOrDrop(IPC::Message* message) { |
| 86 const uint32 message_type = message->type(); |
| 87 const int32 message_routing_id = message->routing_id(); |
| 86 if (!Send(message)) { | 88 if (!Send(message)) { |
| 87 DVLOG(1) << "Sending of message type " << message->type() | 89 message = NULL; |
| 90 DVLOG(1) << "Sending of message type " << message_type |
| 88 << " failed. Dropping channel."; | 91 << " failed. Dropping channel."; |
| 89 DeleteWebSocketHost(message->routing_id()); | 92 DeleteWebSocketHost(message_routing_id); |
| 90 return WEBSOCKET_HOST_DELETED; | 93 return WEBSOCKET_HOST_DELETED; |
| 91 } | 94 } |
| 92 return WEBSOCKET_HOST_ALIVE; | 95 return WEBSOCKET_HOST_ALIVE; |
| 93 } | 96 } |
| 94 | 97 |
| 95 WebSocketHostState WebSocketDispatcherHost::SendAddChannelResponse( | 98 WebSocketHostState WebSocketDispatcherHost::SendAddChannelResponse( |
| 96 int routing_id, | 99 int routing_id, |
| 97 bool fail, | 100 bool fail, |
| 98 const std::string& selected_protocol, | 101 const std::string& selected_protocol, |
| 99 const std::string& extensions) { | 102 const std::string& extensions) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 170 } |
| 168 | 171 |
| 169 void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) { | 172 void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) { |
| 170 WebSocketHostTable::iterator it = hosts_.find(routing_id); | 173 WebSocketHostTable::iterator it = hosts_.find(routing_id); |
| 171 DCHECK(it != hosts_.end()); | 174 DCHECK(it != hosts_.end()); |
| 172 delete it->second; | 175 delete it->second; |
| 173 hosts_.erase(it); | 176 hosts_.erase(it); |
| 174 } | 177 } |
| 175 | 178 |
| 176 } // namespace content | 179 } // namespace content |
| OLD | NEW |