Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: content/browser/renderer_host/websocket_dispatcher_host.cc

Issue 105833003: Fail WebSocket channel when handshake fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return SendOrDrop(new WebSocketMsg_NotifyStartOpeningHandshake( 131 return SendOrDrop(new WebSocketMsg_NotifyStartOpeningHandshake(
132 routing_id, request)); 132 routing_id, request));
133 } 133 }
134 134
135 WebSocketHostState WebSocketDispatcherHost::SendFinishOpeningHandshake( 135 WebSocketHostState WebSocketDispatcherHost::SendFinishOpeningHandshake(
136 int routing_id, const WebSocketHandshakeResponse& response) { 136 int routing_id, const WebSocketHandshakeResponse& response) {
137 return SendOrDrop(new WebSocketMsg_NotifyFinishOpeningHandshake( 137 return SendOrDrop(new WebSocketMsg_NotifyFinishOpeningHandshake(
138 routing_id, response)); 138 routing_id, response));
139 } 139 }
140 140
141 WebSocketHostState WebSocketDispatcherHost::NotifyFailure(
142 int routing_id,
143 const std::string& message) {
144 if (SendOrDrop(new WebSocketMsg_NotifyFailure(
145 routing_id, message)) == WEBSOCKET_HOST_DELETED) {
146 return WEBSOCKET_HOST_DELETED;
147 }
148 DeleteWebSocketHost(routing_id);
149 return WEBSOCKET_HOST_DELETED;
150 }
151
141 WebSocketHostState WebSocketDispatcherHost::DoDropChannel( 152 WebSocketHostState WebSocketDispatcherHost::DoDropChannel(
142 int routing_id, 153 int routing_id,
143 uint16 code, 154 uint16 code,
144 const std::string& reason) { 155 const std::string& reason) {
145 bool was_clean = true; 156 bool was_clean = true;
146 if (SendOrDrop( 157 if (SendOrDrop(
147 new WebSocketMsg_DropChannel(routing_id, was_clean, code, reason)) == 158 new WebSocketMsg_DropChannel(routing_id, was_clean, code, reason)) ==
148 WEBSOCKET_HOST_DELETED) 159 WEBSOCKET_HOST_DELETED)
149 return WEBSOCKET_HOST_DELETED; 160 return WEBSOCKET_HOST_DELETED;
150 DeleteWebSocketHost(routing_id); 161 DeleteWebSocketHost(routing_id);
151 return WEBSOCKET_HOST_DELETED; 162 return WEBSOCKET_HOST_DELETED;
152 } 163 }
153 164
154 WebSocketDispatcherHost::~WebSocketDispatcherHost() { 165 WebSocketDispatcherHost::~WebSocketDispatcherHost() {
155 STLDeleteContainerPairSecondPointers(hosts_.begin(), hosts_.end()); 166 STLDeleteContainerPairSecondPointers(hosts_.begin(), hosts_.end());
156 } 167 }
157 168
158 void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) { 169 void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) {
159 WebSocketHostTable::iterator it = hosts_.find(routing_id); 170 WebSocketHostTable::iterator it = hosts_.find(routing_id);
160 DCHECK(it != hosts_.end()); 171 DCHECK(it != hosts_.end());
161 delete it->second; 172 delete it->second;
162 hosts_.erase(it); 173 hosts_.erase(it);
163 } 174 }
164 175
165 } // namespace content 176 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/websocket_dispatcher_host.h ('k') | content/browser/renderer_host/websocket_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698