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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
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 2af2f0814c80a10755b4c0f318e88ac872666444..c86d63a94c2d5546376801e45fd8c26c71fed1bf 100644
--- a/content/browser/renderer_host/websocket_dispatcher_host.cc
+++ b/content/browser/renderer_host/websocket_dispatcher_host.cc
@@ -4,7 +4,9 @@
#include "content/browser/renderer_host/websocket_dispatcher_host.h"
+#include <hash_map>
Adam Rice 2014/07/14 05:41:50 I think the lint warning that tells you to include
yhirano 2014/07/14 09:27:20 Thanks, done
#include <string>
+#include <vector>
#include "base/callback.h"
#include "base/logging.h"
@@ -178,6 +180,20 @@ WebSocketHostState WebSocketDispatcherHost::DoDropChannel(
}
WebSocketDispatcherHost::~WebSocketDispatcherHost() {
+ std::vector<WebSocketHost*> hosts;
+ for (base::hash_map<int, WebSocketHost*>::const_iterator i = hosts_.begin();
+ i != hosts_.end(); ++i) {
+ // In order to avoid changing a container while iterating, we copy hosts.
Adam Rice 2014/07/14 05:41:49 s/a container/the container/ s/copy hosts/copy the
yhirano 2014/07/14 09:27:20 Done.
+ hosts.push_back(i->second);
+ }
+
+ for (size_t i = 0; i < hosts.size(); ++i) {
+ // Note that some GoAway could fail. In that case hosts[i] will be
Adam Rice 2014/07/14 05:41:49 s/some GoAway/some calls to GoAway/
yhirano 2014/07/14 09:27:20 Done.
+ // deleted and removed in |DoDropChannel|.
+ hosts[i]->GoAway();
+ hosts[i] = NULL;
+ }
+
STLDeleteContainerPairSecondPointers(hosts_.begin(), hosts_.end());
}

Powered by Google App Engine
This is Rietveld 408576698