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 <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
| |
7 #include <string> | 8 #include <string> |
9 #include <vector> | |
8 | 10 |
9 #include "base/callback.h" | 11 #include "base/callback.h" |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
12 #include "content/browser/child_process_security_policy_impl.h" | 14 #include "content/browser/child_process_security_policy_impl.h" |
13 #include "content/browser/renderer_host/websocket_host.h" | 15 #include "content/browser/renderer_host/websocket_host.h" |
14 #include "content/common/websocket_messages.h" | 16 #include "content/common/websocket_messages.h" |
15 | 17 |
16 namespace content { | 18 namespace content { |
17 | 19 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 const std::string& reason) { | 173 const std::string& reason) { |
172 if (SendOrDrop( | 174 if (SendOrDrop( |
173 new WebSocketMsg_DropChannel(routing_id, was_clean, code, reason)) == | 175 new WebSocketMsg_DropChannel(routing_id, was_clean, code, reason)) == |
174 WEBSOCKET_HOST_DELETED) | 176 WEBSOCKET_HOST_DELETED) |
175 return WEBSOCKET_HOST_DELETED; | 177 return WEBSOCKET_HOST_DELETED; |
176 DeleteWebSocketHost(routing_id); | 178 DeleteWebSocketHost(routing_id); |
177 return WEBSOCKET_HOST_DELETED; | 179 return WEBSOCKET_HOST_DELETED; |
178 } | 180 } |
179 | 181 |
180 WebSocketDispatcherHost::~WebSocketDispatcherHost() { | 182 WebSocketDispatcherHost::~WebSocketDispatcherHost() { |
183 std::vector<WebSocketHost*> hosts; | |
184 for (base::hash_map<int, WebSocketHost*>::const_iterator i = hosts_.begin(); | |
185 i != hosts_.end(); ++i) { | |
186 // 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.
| |
187 hosts.push_back(i->second); | |
188 } | |
189 | |
190 for (size_t i = 0; i < hosts.size(); ++i) { | |
191 // 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.
| |
192 // deleted and removed 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 |
OLD | NEW |