Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: webkit/plugins/ppapi/plugin_module.cc

Issue 19744007: Create a public API around webkit::ppapi::PluginInstance and use it in chrome. After this, webkit/p… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "webkit/plugins/ppapi/plugin_module.h" 5 #include "webkit/plugins/ppapi/plugin_module.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 #include "ppapi/shared_impl/ppb_opengles2_shared.h" 116 #include "ppapi/shared_impl/ppb_opengles2_shared.h"
117 #include "ppapi/shared_impl/ppb_var_shared.h" 117 #include "ppapi/shared_impl/ppb_var_shared.h"
118 #include "ppapi/shared_impl/time_conversion.h" 118 #include "ppapi/shared_impl/time_conversion.h"
119 #include "ppapi/thunk/enter.h" 119 #include "ppapi/thunk/enter.h"
120 #include "ppapi/thunk/ppb_graphics_2d_api.h" 120 #include "ppapi/thunk/ppb_graphics_2d_api.h"
121 #include "ppapi/thunk/thunk.h" 121 #include "ppapi/thunk/thunk.h"
122 #include "webkit/plugins/plugin_switches.h" 122 #include "webkit/plugins/plugin_switches.h"
123 #include "webkit/plugins/ppapi/common.h" 123 #include "webkit/plugins/ppapi/common.h"
124 #include "webkit/plugins/ppapi/host_globals.h" 124 #include "webkit/plugins/ppapi/host_globals.h"
125 #include "webkit/plugins/ppapi/ppapi_interface_factory.h" 125 #include "webkit/plugins/ppapi/ppapi_interface_factory.h"
126 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 126 #include "webkit/plugins/ppapi/ppapi_plugin_instance_impl.h"
127 #include "webkit/plugins/ppapi/ppb_gpu_blacklist_private_impl.h" 127 #include "webkit/plugins/ppapi/ppb_gpu_blacklist_private_impl.h"
128 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 128 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
129 #include "webkit/plugins/ppapi/ppb_proxy_impl.h" 129 #include "webkit/plugins/ppapi/ppb_proxy_impl.h"
130 #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h" 130 #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h"
131 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" 131 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h"
132 #include "webkit/plugins/ppapi/ppb_var_deprecated_impl.h" 132 #include "webkit/plugins/ppapi/ppb_var_deprecated_impl.h"
133 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" 133 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
134 134
135 using ppapi::InputEventData; 135 using ppapi::InputEventData;
136 using ppapi::PpapiGlobals; 136 using ppapi::PpapiGlobals;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) { 232 uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) {
233 return HostGlobals::Get()->GetResourceTracker()->GetLiveObjectsForInstance( 233 return HostGlobals::Get()->GetResourceTracker()->GetLiveObjectsForInstance(
234 instance_id); 234 instance_id);
235 } 235 }
236 236
237 PP_Bool IsOutOfProcess() { 237 PP_Bool IsOutOfProcess() {
238 return PP_FALSE; 238 return PP_FALSE;
239 } 239 }
240 240
241 void SimulateInputEvent(PP_Instance instance, PP_Resource input_event) { 241 void SimulateInputEvent(PP_Instance instance, PP_Resource input_event) {
242 PluginInstance* plugin_instance = host_globals->GetInstance(instance); 242 PluginInstanceImpl* plugin_instance = host_globals->GetInstance(instance);
243 if (!plugin_instance) 243 if (!plugin_instance)
244 return; 244 return;
245 245
246 EnterResource<PPB_InputEvent_API> enter(input_event, false); 246 EnterResource<PPB_InputEvent_API> enter(input_event, false);
247 if (enter.failed()) 247 if (enter.failed())
248 return; 248 return;
249 249
250 const InputEventData& input_event_data = enter.object()->GetInputEventData(); 250 const InputEventData& input_event_data = enter.object()->GetInputEventData();
251 plugin_instance->SimulateInputEvent(input_event_data); 251 plugin_instance->SimulateInputEvent(input_event_data);
252 } 252 }
253 253
254 PP_Var GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) { 254 PP_Var GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) {
255 PluginInstance* plugin_instance = host_globals->GetInstance(instance); 255 PluginInstanceImpl* plugin_instance = host_globals->GetInstance(instance);
256 if (!plugin_instance) 256 if (!plugin_instance)
257 return PP_MakeUndefined(); 257 return PP_MakeUndefined();
258 return plugin_instance->GetDocumentURL(instance, components); 258 return plugin_instance->GetDocumentURL(instance, components);
259 } 259 }
260 260
261 uint32_t GetLiveVars(PP_Var live_vars[], uint32_t array_size) { 261 uint32_t GetLiveVars(PP_Var live_vars[], uint32_t array_size) {
262 std::vector<PP_Var> vars = 262 std::vector<PP_Var> vars =
263 PpapiGlobals::Get()->GetVarTracker()->GetLiveVars(); 263 PpapiGlobals::Get()->GetVarTracker()->GetLiveVars();
264 for (size_t i = 0u; 264 for (size_t i = 0u;
265 i < std::min(static_cast<size_t>(array_size), vars.size()); 265 i < std::min(static_cast<size_t>(array_size), vars.size());
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 // plugin in the usual sense, so it isn't tracked by the browser. 486 // plugin in the usual sense, so it isn't tracked by the browser.
487 scoped_refptr<PluginModule> external_plugin_module( 487 scoped_refptr<PluginModule> external_plugin_module(
488 new PluginModule(name_, 488 new PluginModule(name_,
489 path_, 489 path_,
490 NULL, // no lifetime_delegate 490 NULL, // no lifetime_delegate
491 permissions_)); 491 permissions_));
492 return external_plugin_module; 492 return external_plugin_module;
493 } 493 }
494 494
495 PP_ExternalPluginResult PluginModule::InitAsProxiedExternalPlugin( 495 PP_ExternalPluginResult PluginModule::InitAsProxiedExternalPlugin(
496 PluginInstance* instance) { 496 PluginInstanceImpl* instance) {
497 DCHECK(out_of_process_proxy_.get()); 497 DCHECK(out_of_process_proxy_.get());
498 // InitAsProxied (for the trusted/out-of-process case) initializes only the 498 // InitAsProxied (for the trusted/out-of-process case) initializes only the
499 // module, and one or more instances are added later. In this case, the 499 // module, and one or more instances are added later. In this case, the
500 // PluginInstance was already created as in-process, so we missed the proxy 500 // PluginInstance was already created as in-process, so we missed the proxy
501 // AddInstance step and must do it now. 501 // AddInstance step and must do it now.
502 out_of_process_proxy_->AddInstance(instance->pp_instance()); 502 out_of_process_proxy_->AddInstance(instance->pp_instance());
503 // For external plugins, we need to tell the instance to reset itself as 503 // For external plugins, we need to tell the instance to reset itself as
504 // proxied. This will clear cached interface pointers and send DidCreate (etc) 504 // proxied. This will clear cached interface pointers and send DidCreate (etc)
505 // to the plugin side of the proxy. 505 // to the plugin side of the proxy.
506 return instance->ResetAsProxied(this); 506 return instance->ResetAsProxied(this);
(...skipping 23 matching lines...) Expand all
530 // static 530 // static
531 PluginModule::GetInterfaceFunc PluginModule::GetLocalGetInterfaceFunc() { 531 PluginModule::GetInterfaceFunc PluginModule::GetLocalGetInterfaceFunc() {
532 return &GetInterface; 532 return &GetInterface;
533 } 533 }
534 534
535 // static 535 // static
536 bool PluginModule::SupportsInterface(const char* name) { 536 bool PluginModule::SupportsInterface(const char* name) {
537 return !!InternalGetInterface(name); 537 return !!InternalGetInterface(name);
538 } 538 }
539 539
540 PluginInstance* PluginModule::CreateInstance( 540 PluginInstanceImpl* PluginModule::CreateInstance(
541 PluginDelegate* delegate, 541 PluginDelegate* delegate,
542 content::RenderView* render_view, 542 content::RenderView* render_view,
543 WebKit::WebPluginContainer* container, 543 WebKit::WebPluginContainer* container,
544 const GURL& plugin_url) { 544 const GURL& plugin_url) {
545 PluginInstance* instance = PluginInstance::Create(delegate, render_view, this, 545 PluginInstanceImpl* instance = PluginInstanceImpl::Create(
546 container, plugin_url); 546 delegate, render_view, this, container, plugin_url);
547 if (!instance) { 547 if (!instance) {
548 LOG(WARNING) << "Plugin doesn't support instance interface, failing."; 548 LOG(WARNING) << "Plugin doesn't support instance interface, failing.";
549 return NULL; 549 return NULL;
550 } 550 }
551 if (out_of_process_proxy_) 551 if (out_of_process_proxy_)
552 out_of_process_proxy_->AddInstance(instance->pp_instance()); 552 out_of_process_proxy_->AddInstance(instance->pp_instance());
553 return instance; 553 return instance;
554 } 554 }
555 555
556 PluginInstance* PluginModule::GetSomeInstance() const { 556 PluginInstanceImpl* PluginModule::GetSomeInstance() const {
557 // This will generally crash later if there is not actually any instance to 557 // This will generally crash later if there is not actually any instance to
558 // return, so we force a crash now to make bugs easier to track down. 558 // return, so we force a crash now to make bugs easier to track down.
559 CHECK(!instances_.empty()); 559 CHECK(!instances_.empty());
560 return *instances_.begin(); 560 return *instances_.begin();
561 } 561 }
562 562
563 const void* PluginModule::GetPluginInterface(const char* name) const { 563 const void* PluginModule::GetPluginInterface(const char* name) const {
564 if (out_of_process_proxy_) 564 if (out_of_process_proxy_)
565 return out_of_process_proxy_->GetProxiedInterface(name); 565 return out_of_process_proxy_->GetProxiedInterface(name);
566 566
567 // In-process plugins. 567 // In-process plugins.
568 if (!entry_points_.get_interface) 568 if (!entry_points_.get_interface)
569 return NULL; 569 return NULL;
570 return entry_points_.get_interface(name); 570 return entry_points_.get_interface(name);
571 } 571 }
572 572
573 void PluginModule::InstanceCreated(PluginInstance* instance) { 573 void PluginModule::InstanceCreated(PluginInstanceImpl* instance) {
574 instances_.insert(instance); 574 instances_.insert(instance);
575 } 575 }
576 576
577 void PluginModule::InstanceDeleted(PluginInstance* instance) { 577 void PluginModule::InstanceDeleted(PluginInstanceImpl* instance) {
578 if (out_of_process_proxy_) 578 if (out_of_process_proxy_)
579 out_of_process_proxy_->RemoveInstance(instance->pp_instance()); 579 out_of_process_proxy_->RemoveInstance(instance->pp_instance());
580 instances_.erase(instance); 580 instances_.erase(instance);
581 } 581 }
582 582
583 scoped_refptr< ::ppapi::CallbackTracker> PluginModule::GetCallbackTracker() { 583 scoped_refptr< ::ppapi::CallbackTracker> PluginModule::GetCallbackTracker() {
584 return callback_tracker_; 584 return callback_tracker_;
585 } 585 }
586 586
587 void PluginModule::PluginCrashed() { 587 void PluginModule::PluginCrashed() {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 int retval = entry_points.initialize_module(pp_module(), &GetInterface); 630 int retval = entry_points.initialize_module(pp_module(), &GetInterface);
631 if (retval != 0) { 631 if (retval != 0) {
632 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; 632 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval;
633 return false; 633 return false;
634 } 634 }
635 return true; 635 return true;
636 } 636 }
637 637
638 } // namespace ppapi 638 } // namespace ppapi
639 } // namespace webkit 639 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698