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 "ppapi/host/ppapi_host.h" | 5 #include "ppapi/host/ppapi_host.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/host/host_factory.h" | 9 #include "ppapi/host/host_factory.h" |
10 #include "ppapi/host/host_message_context.h" | 10 #include "ppapi/host/host_message_context.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 resources_[params.pp_resource()] = | 246 resources_[params.pp_resource()] = |
247 linked_ptr<ResourceHost>(resource_host.release()); | 247 linked_ptr<ResourceHost>(resource_host.release()); |
248 } | 248 } |
249 | 249 |
250 void PpapiHost::OnHostMsgAttachToPendingHost(PP_Resource pp_resource, | 250 void PpapiHost::OnHostMsgAttachToPendingHost(PP_Resource pp_resource, |
251 int pending_host_id) { | 251 int pending_host_id) { |
252 PendingHostResourceMap::iterator found = | 252 PendingHostResourceMap::iterator found = |
253 pending_resource_hosts_.find(pending_host_id); | 253 pending_resource_hosts_.find(pending_host_id); |
254 if (found == pending_resource_hosts_.end()) { | 254 if (found == pending_resource_hosts_.end()) { |
255 // Plugin sent a bad ID. | 255 // Plugin sent a bad ID. |
256 NOTREACHED(); | 256 //NOTREACHED(); |
raymes
2014/10/09 22:04:42
Was this getting hit?
dmichael (off chromium)
2014/10/09 22:45:37
Ah, good catch. It *was* getting hit; that was the
| |
257 return; | 257 return; |
258 } | 258 } |
259 found->second->SetPPResourceForPendingHost(pp_resource); | 259 found->second->SetPPResourceForPendingHost(pp_resource); |
260 resources_[pp_resource] = found->second; | 260 resources_[pp_resource] = found->second; |
261 pending_resource_hosts_.erase(found); | 261 pending_resource_hosts_.erase(found); |
262 } | 262 } |
263 | 263 |
264 void PpapiHost::OnHostMsgResourceDestroyed(PP_Resource resource) { | 264 void PpapiHost::OnHostMsgResourceDestroyed(PP_Resource resource) { |
265 ResourceMap::iterator found = resources_.find(resource); | 265 ResourceMap::iterator found = resources_.find(resource); |
266 if (found == resources_.end()) { | 266 if (found == resources_.end()) { |
267 NOTREACHED(); | 267 NOTREACHED(); |
268 return; | 268 return; |
269 } | 269 } |
270 // Invoking the HostResource destructor might result in looking up the | 270 // Invoking the HostResource destructor might result in looking up the |
271 // PP_Resource in resources_. std::map is not well specified as to whether the | 271 // PP_Resource in resources_. std::map is not well specified as to whether the |
272 // element will be there or not. Therefore, we delay destruction of the | 272 // element will be there or not. Therefore, we delay destruction of the |
273 // HostResource until after we've made sure the map no longer contains | 273 // HostResource until after we've made sure the map no longer contains |
274 // |resource|. | 274 // |resource|. |
275 linked_ptr<ResourceHost> delete_at_end_of_scope(found->second); | 275 linked_ptr<ResourceHost> delete_at_end_of_scope(found->second); |
276 resources_.erase(found); | 276 resources_.erase(found); |
277 } | 277 } |
278 | 278 |
279 ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) const { | 279 ResourceHost* PpapiHost::GetResourceHost(PP_Resource resource) const { |
280 ResourceMap::const_iterator found = resources_.find(resource); | 280 ResourceMap::const_iterator found = resources_.find(resource); |
281 return found == resources_.end() ? NULL : found->second.get(); | 281 return found == resources_.end() ? NULL : found->second.get(); |
282 } | 282 } |
283 | 283 |
284 } // namespace host | 284 } // namespace host |
285 } // namespace ppapi | 285 } // namespace ppapi |
OLD | NEW |