Index: content/browser/renderer_host/websocket_dispatcher_host.cc |
diff --git a/content/browser/renderer_host/websocket_dispatcher_host.cc b/content/browser/renderer_host/websocket_dispatcher_host.cc |
index 902664e909762ebd96dff94cb909cf0802ffd916..3774887a7eb25311bb3a5ef58f76b6ad0bce6ee7 100644 |
--- a/content/browser/renderer_host/websocket_dispatcher_host.cc |
+++ b/content/browser/renderer_host/websocket_dispatcher_host.cc |
@@ -14,6 +14,12 @@ |
namespace content { |
+namespace { |
+ |
+typedef WebSocketDispatcherHost::WebSocketHostState WebSocketHostState; |
jochen (gone - plz use gerrit)
2013/10/23 14:01:28
I find this a bit confusing
Adam Rice
2013/10/24 02:22:23
It's just to avoid having WebSocketDispatcherHost:
|
+ |
+} // namespace |
+ |
WebSocketDispatcherHost::WebSocketDispatcherHost( |
const GetRequestContextCallback& get_context_callback) |
: get_context_callback_(get_context_callback), |
@@ -73,45 +79,59 @@ WebSocketHost* WebSocketDispatcherHost::GetHost(int routing_id) const { |
return it == hosts_.end() ? NULL : it->second; |
} |
-void WebSocketDispatcherHost::SendOrDrop(IPC::Message* message) { |
+WebSocketHostState WebSocketDispatcherHost::SendOrDrop(IPC::Message* message) { |
if (!Send(message)) { |
DVLOG(1) << "Sending of message type " << message->type() |
<< " failed. Dropping channel."; |
DeleteWebSocketHost(message->routing_id()); |
+ return WEBSOCKET_HOST_DELETED; |
} |
+ return WEBSOCKET_HOST_ALIVE; |
} |
-void WebSocketDispatcherHost::SendAddChannelResponse( |
+WebSocketHostState WebSocketDispatcherHost::SendAddChannelResponse( |
int routing_id, |
bool fail, |
const std::string& selected_protocol, |
const std::string& extensions) { |
- SendOrDrop(new WebSocketMsg_AddChannelResponse( |
- routing_id, fail, selected_protocol, extensions)); |
- if (fail) |
+ if (SendOrDrop(new WebSocketMsg_AddChannelResponse( |
+ routing_id, fail, selected_protocol, extensions)) == |
+ WEBSOCKET_HOST_DELETED) |
+ return WEBSOCKET_HOST_DELETED; |
+ if (fail) { |
DeleteWebSocketHost(routing_id); |
+ return WEBSOCKET_HOST_DELETED; |
+ } |
+ return WEBSOCKET_HOST_ALIVE; |
} |
-void WebSocketDispatcherHost::SendFrame(int routing_id, |
- bool fin, |
- WebSocketMessageType type, |
- const std::vector<char>& data) { |
- SendOrDrop(new WebSocketMsg_SendFrame(routing_id, fin, type, data)); |
+WebSocketHostState WebSocketDispatcherHost::SendFrame( |
+ int routing_id, |
+ bool fin, |
+ WebSocketMessageType type, |
+ const std::vector<char>& data) { |
+ return SendOrDrop(new WebSocketMsg_SendFrame(routing_id, fin, type, data)); |
} |
-void WebSocketDispatcherHost::SendFlowControl(int routing_id, int64 quota) { |
- SendOrDrop(new WebSocketMsg_FlowControl(routing_id, quota)); |
+WebSocketHostState WebSocketDispatcherHost::SendFlowControl(int routing_id, |
+ int64 quota) { |
+ return SendOrDrop(new WebSocketMsg_FlowControl(routing_id, quota)); |
} |
-void WebSocketDispatcherHost::SendClosing(int routing_id) { |
+WebSocketHostState WebSocketDispatcherHost::SendClosing(int routing_id) { |
// TODO(ricea): Implement the SendClosing IPC. |
+ return WEBSOCKET_HOST_ALIVE; |
} |
-void WebSocketDispatcherHost::DoDropChannel(int routing_id, |
- uint16 code, |
- const std::string& reason) { |
- SendOrDrop(new WebSocketMsg_DropChannel(routing_id, code, reason)); |
+WebSocketHostState WebSocketDispatcherHost::DoDropChannel( |
+ int routing_id, |
+ uint16 code, |
+ const std::string& reason) { |
+ if (SendOrDrop(new WebSocketMsg_DropChannel(routing_id, code, reason)) == |
+ WEBSOCKET_HOST_DELETED) |
+ return WEBSOCKET_HOST_DELETED; |
DeleteWebSocketHost(routing_id); |
+ return WEBSOCKET_HOST_DELETED; |
} |
WebSocketDispatcherHost::~WebSocketDispatcherHost() { |
@@ -120,10 +140,9 @@ WebSocketDispatcherHost::~WebSocketDispatcherHost() { |
void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) { |
WebSocketHostTable::iterator it = hosts_.find(routing_id); |
- if (it != hosts_.end()) { |
- delete it->second; |
- hosts_.erase(it); |
- } |
+ DCHECK(it != hosts_.end()); |
+ delete it->second; |
+ hosts_.erase(it); |
} |
} // namespace content |