| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/host_var_tracker.h" | 5 #include "webkit/plugins/ppapi/host_var_tracker.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/c/pp_var.h" | 8 #include "ppapi/c/pp_var.h" |
| 9 #include "webkit/plugins/ppapi/host_array_buffer_var.h" |
| 9 #include "webkit/plugins/ppapi/npobject_var.h" | 10 #include "webkit/plugins/ppapi/npobject_var.h" |
| 10 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 11 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 11 | 12 |
| 13 using ppapi::ArrayBufferVar; |
| 12 using ppapi::NPObjectVar; | 14 using ppapi::NPObjectVar; |
| 13 | 15 |
| 14 namespace webkit { | 16 namespace webkit { |
| 15 namespace ppapi { | 17 namespace ppapi { |
| 16 | 18 |
| 17 HostVarTracker::HostVarTracker() { | 19 HostVarTracker::HostVarTracker() { |
| 18 } | 20 } |
| 19 | 21 |
| 20 HostVarTracker::~HostVarTracker() { | 22 HostVarTracker::~HostVarTracker() { |
| 21 } | 23 } |
| 22 | 24 |
| 25 ArrayBufferVar* HostVarTracker::CreateArrayBuffer(uint32 size_in_bytes) { |
| 26 return new HostArrayBufferVar(size_in_bytes); |
| 27 } |
| 28 |
| 23 void HostVarTracker::AddNPObjectVar(NPObjectVar* object_var) { | 29 void HostVarTracker::AddNPObjectVar(NPObjectVar* object_var) { |
| 24 InstanceMap::iterator found_instance = instance_map_.find( | 30 InstanceMap::iterator found_instance = instance_map_.find( |
| 25 object_var->pp_instance()); | 31 object_var->pp_instance()); |
| 26 if (found_instance == instance_map_.end()) { | 32 if (found_instance == instance_map_.end()) { |
| 27 // Lazily create the instance map. | 33 // Lazily create the instance map. |
| 28 DCHECK(object_var->pp_instance() != 0); | 34 DCHECK(object_var->pp_instance() != 0); |
| 29 found_instance = instance_map_.insert(std::make_pair( | 35 found_instance = instance_map_.insert(std::make_pair( |
| 30 object_var->pp_instance(), | 36 object_var->pp_instance(), |
| 31 linked_ptr<NPObjectToNPObjectVarMap>(new NPObjectToNPObjectVarMap))). | 37 linked_ptr<NPObjectToNPObjectVarMap>(new NPObjectToNPObjectVarMap))). |
| 32 first; | 38 first; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 np_object_map->erase(current->first); | 109 np_object_map->erase(current->first); |
| 104 } | 110 } |
| 105 | 111 |
| 106 // Remove the record for this instance since it should be empty. | 112 // Remove the record for this instance since it should be empty. |
| 107 DCHECK(np_object_map->empty()); | 113 DCHECK(np_object_map->empty()); |
| 108 instance_map_.erase(found_instance); | 114 instance_map_.erase(found_instance); |
| 109 } | 115 } |
| 110 | 116 |
| 111 } // namespace ppapi | 117 } // namespace ppapi |
| 112 } // namespace webkit | 118 } // namespace webkit |
| OLD | NEW |