| 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/renderer/pepper/host_var_tracker.h" |    5 #include "content/renderer/pepper/host_var_tracker.h" | 
|    6  |    6  | 
|    7 #include "base/logging.h" |    7 #include "base/logging.h" | 
|    8 #include "content/renderer/pepper/host_array_buffer_var.h" |    8 #include "content/renderer/pepper/host_array_buffer_var.h" | 
 |    9 #include "content/renderer/pepper/host_resource_var.h" | 
|    9 #include "content/renderer/pepper/npobject_var.h" |   10 #include "content/renderer/pepper/npobject_var.h" | 
|   10 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |   11 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 
|   11 #include "ppapi/c/pp_var.h" |   12 #include "ppapi/c/pp_var.h" | 
|   12  |   13  | 
|   13 using ppapi::ArrayBufferVar; |   14 using ppapi::ArrayBufferVar; | 
|   14 using ppapi::NPObjectVar; |   15 using ppapi::NPObjectVar; | 
|   15  |   16  | 
|   16 namespace content { |   17 namespace content { | 
|   17  |   18  | 
|   18 HostVarTracker::HostVarTracker() |   19 HostVarTracker::HostVarTracker() | 
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   95  |   96  | 
|   96 int HostVarTracker::GetLiveNPObjectVarsForInstance(PP_Instance instance) const { |   97 int HostVarTracker::GetLiveNPObjectVarsForInstance(PP_Instance instance) const { | 
|   97   CheckThreadingPreconditions(); |   98   CheckThreadingPreconditions(); | 
|   98  |   99  | 
|   99   InstanceMap::const_iterator found = instance_map_.find(instance); |  100   InstanceMap::const_iterator found = instance_map_.find(instance); | 
|  100   if (found == instance_map_.end()) |  101   if (found == instance_map_.end()) | 
|  101     return 0; |  102     return 0; | 
|  102   return static_cast<int>(found->second->size()); |  103   return static_cast<int>(found->second->size()); | 
|  103 } |  104 } | 
|  104  |  105  | 
 |  106 ppapi::ResourceVar* HostVarTracker::MakeResourceVar(PP_Resource pp_resource) { | 
 |  107   return new HostResourceVar(pp_resource); | 
 |  108 } | 
 |  109  | 
|  105 void HostVarTracker::DidDeleteInstance(PP_Instance instance) { |  110 void HostVarTracker::DidDeleteInstance(PP_Instance instance) { | 
|  106   CheckThreadingPreconditions(); |  111   CheckThreadingPreconditions(); | 
|  107  |  112  | 
|  108   InstanceMap::iterator found_instance = instance_map_.find(instance); |  113   InstanceMap::iterator found_instance = instance_map_.find(instance); | 
|  109   if (found_instance == instance_map_.end()) |  114   if (found_instance == instance_map_.end()) | 
|  110     return;  // Nothing to do. |  115     return;  // Nothing to do. | 
|  111   NPObjectToNPObjectVarMap* np_object_map = found_instance->second.get(); |  116   NPObjectToNPObjectVarMap* np_object_map = found_instance->second.get(); | 
|  112  |  117  | 
|  113   // Force delete all var references. ForceReleaseNPObject() will cause |  118   // Force delete all var references. ForceReleaseNPObject() will cause | 
|  114   // this object, and potentially others it references, to be removed from |  119   // this object, and potentially others it references, to be removed from | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  162   if (it->second.instance != instance) |  167   if (it->second.instance != instance) | 
|  163     return false; |  168     return false; | 
|  164  |  169  | 
|  165   *handle = it->second.handle; |  170   *handle = it->second.handle; | 
|  166   *size_in_bytes = it->second.size_in_bytes; |  171   *size_in_bytes = it->second.size_in_bytes; | 
|  167   shared_memory_map_.erase(it); |  172   shared_memory_map_.erase(it); | 
|  168   return true; |  173   return true; | 
|  169 } |  174 } | 
|  170  |  175  | 
|  171 }  // namespace content |  176 }  // namespace content | 
| OLD | NEW |