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

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

Issue 390773002: [WebSocket] Send a close frame when the renderer process is gone. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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 #include <vector>
8 9
9 #include "base/callback.h" 10 #include "base/callback.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/stl_util.h" 12 #include "base/stl_util.h"
12 #include "content/browser/child_process_security_policy_impl.h" 13 #include "content/browser/child_process_security_policy_impl.h"
13 #include "content/browser/renderer_host/websocket_host.h" 14 #include "content/browser/renderer_host/websocket_host.h"
14 #include "content/common/websocket_messages.h" 15 #include "content/common/websocket_messages.h"
15 16
16 namespace content { 17 namespace content {
17 18
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 const std::string& reason) { 172 const std::string& reason) {
172 if (SendOrDrop( 173 if (SendOrDrop(
173 new WebSocketMsg_DropChannel(routing_id, was_clean, code, reason)) == 174 new WebSocketMsg_DropChannel(routing_id, was_clean, code, reason)) ==
174 WEBSOCKET_HOST_DELETED) 175 WEBSOCKET_HOST_DELETED)
175 return WEBSOCKET_HOST_DELETED; 176 return WEBSOCKET_HOST_DELETED;
176 DeleteWebSocketHost(routing_id); 177 DeleteWebSocketHost(routing_id);
177 return WEBSOCKET_HOST_DELETED; 178 return WEBSOCKET_HOST_DELETED;
178 } 179 }
179 180
180 WebSocketDispatcherHost::~WebSocketDispatcherHost() { 181 WebSocketDispatcherHost::~WebSocketDispatcherHost() {
182 std::vector<WebSocketHost*> hosts;
183 for (base::hash_map<int, WebSocketHost*>::const_iterator i = hosts_.begin();
184 i != hosts_.end(); ++i) {
185 // In order to avoid changing the container while iterating, we copy
186 // the hosts.
187 hosts.push_back(i->second);
188 }
189
190 for (size_t i = 0; i < hosts.size(); ++i) {
191 // Note that some calls to GoAway could fail. In that case hosts[i] will be
192 // deleted and removed from |hosts_| in |DoDropChannel|.
193 hosts[i]->GoAway();
194 hosts[i] = NULL;
195 }
196
181 STLDeleteContainerPairSecondPointers(hosts_.begin(), hosts_.end()); 197 STLDeleteContainerPairSecondPointers(hosts_.begin(), hosts_.end());
182 } 198 }
183 199
184 void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) { 200 void WebSocketDispatcherHost::DeleteWebSocketHost(int routing_id) {
185 WebSocketHostTable::iterator it = hosts_.find(routing_id); 201 WebSocketHostTable::iterator it = hosts_.find(routing_id);
186 DCHECK(it != hosts_.end()); 202 DCHECK(it != hosts_.end());
187 delete it->second; 203 delete it->second;
188 hosts_.erase(it); 204 hosts_.erase(it);
189 } 205 }
190 206
191 } // namespace content 207 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698