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 "ppapi/proxy/plugin_resource_tracker.h" | 5 #include "ppapi/proxy/plugin_resource_tracker.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "ppapi/proxy/plugin_dispatcher.h" | 9 #include "ppapi/proxy/plugin_dispatcher.h" |
10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 ::ppapi::FunctionGroupBase* PluginResourceTracker::GetFunctionAPI( | 133 ::ppapi::FunctionGroupBase* PluginResourceTracker::GetFunctionAPI( |
134 PP_Instance inst, | 134 PP_Instance inst, |
135 pp::proxy::InterfaceID id) { | 135 pp::proxy::InterfaceID id) { |
136 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(inst); | 136 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(inst); |
137 if (dispatcher) | 137 if (dispatcher) |
138 return dispatcher->GetFunctionAPI(id); | 138 return dispatcher->GetFunctionAPI(id); |
139 return NULL; | 139 return NULL; |
140 } | 140 } |
141 | 141 |
142 PP_Instance PluginResourceTracker::GetInstanceForResource( | |
143 PP_Resource resource) { | |
144 ResourceMap::iterator found = resource_map_.find(resource); | |
145 if (found == resource_map_.end()) | |
146 return 0; | |
147 return found->second.resource->instance(); | |
148 } | |
149 | |
150 void PluginResourceTracker::ReleasePluginResourceRef( | 142 void PluginResourceTracker::ReleasePluginResourceRef( |
151 const PP_Resource& resource, | 143 const PP_Resource& resource, |
152 bool notify_browser_on_release) { | 144 bool notify_browser_on_release) { |
153 ResourceMap::iterator found = resource_map_.find(resource); | 145 ResourceMap::iterator found = resource_map_.find(resource); |
154 if (found == resource_map_.end()) | 146 if (found == resource_map_.end()) |
155 return; | 147 return; |
156 found->second.ref_count--; | 148 found->second.ref_count--; |
157 if (found->second.ref_count == 0) { | 149 if (found->second.ref_count == 0) { |
158 // Keep a reference while removing in case the destructor ends up | 150 // Keep a reference while removing in case the destructor ends up |
159 // re-entering. That way, when the destructor is called, it's out of the | 151 // re-entering. That way, when the destructor is called, it's out of the |
(...skipping 14 matching lines...) Expand all Loading... |
174 // tell the host about. | 166 // tell the host about. |
175 if (notify_browser_on_release && dispatcher && !host_resource.is_null()) { | 167 if (notify_browser_on_release && dispatcher && !host_resource.is_null()) { |
176 dispatcher->Send(new PpapiHostMsg_PPBCore_ReleaseResource( | 168 dispatcher->Send(new PpapiHostMsg_PPBCore_ReleaseResource( |
177 INTERFACE_ID_PPB_CORE, host_resource)); | 169 INTERFACE_ID_PPB_CORE, host_resource)); |
178 } | 170 } |
179 } | 171 } |
180 } | 172 } |
181 | 173 |
182 } // namespace proxy | 174 } // namespace proxy |
183 } // namespace pp | 175 } // namespace pp |
OLD | NEW |