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