OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/np_channel_base.h" | 5 #include "content/common/np_channel_base.h" |
6 | 6 |
7 #include <stack> | 7 #include <stack> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 } | 246 } |
247 | 247 |
248 bool NPChannelBase::OnControlMessageReceived(const IPC::Message& msg) { | 248 bool NPChannelBase::OnControlMessageReceived(const IPC::Message& msg) { |
249 NOTREACHED() << | 249 NOTREACHED() << |
250 "should override in subclass if you care about control messages"; | 250 "should override in subclass if you care about control messages"; |
251 return false; | 251 return false; |
252 } | 252 } |
253 | 253 |
254 void NPChannelBase::OnChannelError() { | 254 void NPChannelBase::OnChannelError() { |
255 channel_valid_ = false; | 255 channel_valid_ = false; |
| 256 |
| 257 // TODO(shess): http://crbug.com/97285 |
| 258 // Once an error is seen on a channel, remap the channel to prevent |
| 259 // it from being vended again. Keep the channel in the map so |
| 260 // RemoveRoute() can clean things up correctly. |
| 261 for (ChannelMap::iterator iter = g_channels.Get().begin(); |
| 262 iter != g_channels.Get().end(); ++iter) { |
| 263 if (iter->second == this) { |
| 264 // Insert new element before invalidating |iter|. |
| 265 g_channels.Get()[iter->first + "-error"] = iter->second; |
| 266 g_channels.Get().erase(iter); |
| 267 break; |
| 268 } |
| 269 } |
256 } | 270 } |
257 | 271 |
258 NPObject* NPChannelBase::GetExistingNPObjectProxy(int route_id) { | 272 NPObject* NPChannelBase::GetExistingNPObjectProxy(int route_id) { |
259 ProxyMap::iterator iter = proxy_map_.find(route_id); | 273 ProxyMap::iterator iter = proxy_map_.find(route_id); |
260 return iter != proxy_map_.end() ? iter->second : NULL; | 274 return iter != proxy_map_.end() ? iter->second : NULL; |
261 } | 275 } |
262 | 276 |
263 int NPChannelBase::GetExistingRouteForNPObjectStub(NPObject* npobject) { | 277 int NPChannelBase::GetExistingRouteForNPObjectStub(NPObject* npobject) { |
264 StubMap::iterator iter = stub_map_.find(npobject); | 278 StubMap::iterator iter = stub_map_.find(npobject); |
265 return iter != stub_map_.end() ? iter->second : MSG_ROUTING_NONE; | 279 return iter != stub_map_.end() ? iter->second : MSG_ROUTING_NONE; |
(...skipping 12 matching lines...) Expand all Loading... |
278 | 292 |
279 void NPChannelBase::RemoveMappingForNPObjectStub(int route_id, | 293 void NPChannelBase::RemoveMappingForNPObjectStub(int route_id, |
280 NPObject* object) { | 294 NPObject* object) { |
281 DCHECK(object != NULL); | 295 DCHECK(object != NULL); |
282 stub_map_.erase(object); | 296 stub_map_.erase(object); |
283 } | 297 } |
284 | 298 |
285 void NPChannelBase::RemoveMappingForNPObjectProxy(int route_id) { | 299 void NPChannelBase::RemoveMappingForNPObjectProxy(int route_id) { |
286 proxy_map_.erase(route_id); | 300 proxy_map_.erase(route_id); |
287 } | 301 } |
OLD | NEW |