| 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/ppp_instance_proxy.h" | 5 #include "ppapi/proxy/ppp_instance_proxy.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ppapi/c/pp_var.h" | 9 #include "ppapi/c/pp_var.h" |
| 10 #include "ppapi/c/ppb_core.h" | 10 #include "ppapi/c/ppb_core.h" |
| 11 #include "ppapi/c/ppp_instance.h" | 11 #include "ppapi/c/ppp_instance.h" |
| 12 #include "ppapi/c/private/ppb_flash_fullscreen.h" | 12 #include "ppapi/c/private/ppb_flash_fullscreen.h" |
| 13 #include "ppapi/proxy/host_dispatcher.h" | 13 #include "ppapi/proxy/host_dispatcher.h" |
| 14 #include "ppapi/proxy/plugin_dispatcher.h" | 14 #include "ppapi/proxy/plugin_dispatcher.h" |
| 15 #include "ppapi/proxy/plugin_resource_tracker.h" | 15 #include "ppapi/proxy/plugin_resource_tracker.h" |
| 16 #include "ppapi/proxy/ppapi_messages.h" | 16 #include "ppapi/proxy/ppapi_messages.h" |
| 17 #include "ppapi/proxy/ppb_url_loader_proxy.h" | 17 #include "ppapi/proxy/ppb_url_loader_proxy.h" |
| 18 #include "ppapi/shared_impl/ppapi_globals.h" | |
| 19 | 18 |
| 20 namespace ppapi { | 19 namespace ppapi { |
| 21 namespace proxy { | 20 namespace proxy { |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 PP_Bool DidCreate(PP_Instance instance, | 24 PP_Bool DidCreate(PP_Instance instance, |
| 26 uint32_t argc, | 25 uint32_t argc, |
| 27 const char* argn[], | 26 const char* argn[], |
| 28 const char* argv[]) { | 27 const char* argv[]) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 *result = PP_FALSE; | 168 *result = PP_FALSE; |
| 170 if (argn.size() != argv.size()) | 169 if (argn.size() != argv.size()) |
| 171 return; | 170 return; |
| 172 | 171 |
| 173 // Set up the routing associating this new instance with the dispatcher we | 172 // Set up the routing associating this new instance with the dispatcher we |
| 174 // just got the message from. This must be done before calling into the | 173 // just got the message from. This must be done before calling into the |
| 175 // plugin so it can in turn call PPAPI functions. | 174 // plugin so it can in turn call PPAPI functions. |
| 176 PluginDispatcher* plugin_dispatcher = | 175 PluginDispatcher* plugin_dispatcher = |
| 177 static_cast<PluginDispatcher*>(dispatcher()); | 176 static_cast<PluginDispatcher*>(dispatcher()); |
| 178 plugin_dispatcher->DidCreateInstance(instance); | 177 plugin_dispatcher->DidCreateInstance(instance); |
| 179 PpapiGlobals::Get()->GetResourceTracker()->DidCreateInstance(instance); | 178 ppapi::TrackerBase::Get()->GetResourceTracker()->DidCreateInstance(instance); |
| 180 | 179 |
| 181 // Make sure the arrays always have at least one element so we can take the | 180 // Make sure the arrays always have at least one element so we can take the |
| 182 // address below. | 181 // address below. |
| 183 std::vector<const char*> argn_array( | 182 std::vector<const char*> argn_array( |
| 184 std::max(static_cast<size_t>(1), argn.size())); | 183 std::max(static_cast<size_t>(1), argn.size())); |
| 185 std::vector<const char*> argv_array( | 184 std::vector<const char*> argv_array( |
| 186 std::max(static_cast<size_t>(1), argn.size())); | 185 std::max(static_cast<size_t>(1), argn.size())); |
| 187 for (size_t i = 0; i < argn.size(); i++) { | 186 for (size_t i = 0; i < argn.size(); i++) { |
| 188 argn_array[i] = argn[i].c_str(); | 187 argn_array[i] = argn[i].c_str(); |
| 189 argv_array[i] = argv[i].c_str(); | 188 argv_array[i] = argv[i].c_str(); |
| 190 } | 189 } |
| 191 | 190 |
| 192 DCHECK(combined_interface_.get()); | 191 DCHECK(combined_interface_.get()); |
| 193 *result = combined_interface_->DidCreate(instance, | 192 *result = combined_interface_->DidCreate(instance, |
| 194 static_cast<uint32_t>(argn.size()), | 193 static_cast<uint32_t>(argn.size()), |
| 195 &argn_array[0], &argv_array[0]); | 194 &argn_array[0], &argv_array[0]); |
| 196 } | 195 } |
| 197 | 196 |
| 198 void PPP_Instance_Proxy::OnMsgDidDestroy(PP_Instance instance) { | 197 void PPP_Instance_Proxy::OnMsgDidDestroy(PP_Instance instance) { |
| 199 combined_interface_->DidDestroy(instance); | 198 combined_interface_->DidDestroy(instance); |
| 200 PpapiGlobals::Get()->GetResourceTracker()->DidDeleteInstance(instance); | 199 ppapi::TrackerBase::Get()->GetResourceTracker()->DidDeleteInstance(instance); |
| 201 static_cast<PluginDispatcher*>(dispatcher())->DidDestroyInstance(instance); | 200 static_cast<PluginDispatcher*>(dispatcher())->DidDestroyInstance(instance); |
| 202 } | 201 } |
| 203 | 202 |
| 204 void PPP_Instance_Proxy::OnMsgDidChangeView(PP_Instance instance, | 203 void PPP_Instance_Proxy::OnMsgDidChangeView(PP_Instance instance, |
| 205 const PP_Rect& position, | 204 const PP_Rect& position, |
| 206 const PP_Rect& clip, | 205 const PP_Rect& clip, |
| 207 PP_Bool fullscreen, | 206 PP_Bool fullscreen, |
| 208 PP_Bool flash_fullscreen) { | 207 PP_Bool flash_fullscreen) { |
| 209 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 208 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 210 if (!dispatcher) | 209 if (!dispatcher) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 229 PP_Resource plugin_loader = | 228 PP_Resource plugin_loader = |
| 230 PPB_URLLoader_Proxy::TrackPluginResource(url_loader); | 229 PPB_URLLoader_Proxy::TrackPluginResource(url_loader); |
| 231 *result = combined_interface_->HandleDocumentLoad(instance, plugin_loader); | 230 *result = combined_interface_->HandleDocumentLoad(instance, plugin_loader); |
| 232 | 231 |
| 233 // This balances the one reference that TrackPluginResource() initialized it | 232 // This balances the one reference that TrackPluginResource() initialized it |
| 234 // with. The plugin will normally take an additional reference which will keep | 233 // with. The plugin will normally take an additional reference which will keep |
| 235 // the resource alive in the plugin (and the one reference in the renderer | 234 // the resource alive in the plugin (and the one reference in the renderer |
| 236 // representing all plugin references). | 235 // representing all plugin references). |
| 237 // Once all references at the plugin side are released, the renderer side will | 236 // Once all references at the plugin side are released, the renderer side will |
| 238 // be notified and release the reference added in HandleDocumentLoad() above. | 237 // be notified and release the reference added in HandleDocumentLoad() above. |
| 239 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(plugin_loader); | 238 PluginResourceTracker::GetInstance()->ReleaseResource(plugin_loader); |
| 240 } | 239 } |
| 241 | 240 |
| 242 } // namespace proxy | 241 } // namespace proxy |
| 243 } // namespace ppapi | 242 } // namespace ppapi |
| OLD | NEW |