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

Unified Diff: webkit/glue/plugins/pepper_plugin_module.cc

Issue 2843018: Add in support for internal pepper plugins into the PepperPluginRegistry and pepper::PluginModule. (Closed) Base URL: git://codf21.jail.google.com/chromium.git
Patch Set: Add new entrypoint to match ToT ppapi Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/plugins/pepper_plugin_module.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/plugins/pepper_plugin_module.cc
diff --git a/webkit/glue/plugins/pepper_plugin_module.cc b/webkit/glue/plugins/pepper_plugin_module.cc
index 3f5d767cf20989d9d74721d78b9574dace6fba20..4bb5ea11d127804130f09fdd0b5ee06ec210d264 100644
--- a/webkit/glue/plugins/pepper_plugin_module.cc
+++ b/webkit/glue/plugins/pepper_plugin_module.cc
@@ -44,9 +44,6 @@
#include "webkit/glue/plugins/pepper_url_response_info.h"
#include "webkit/glue/plugins/pepper_var.h"
-typedef bool (*PPP_InitializeModuleFunc)(PP_Module, PPB_GetInterface);
-typedef void (*PPP_ShutdownModuleFunc)();
-
namespace pepper {
namespace {
@@ -187,11 +184,9 @@ const void* GetInterface(const char* name) {
} // namespace
-PluginModule::PluginModule(const FilePath& filename)
- : filename_(filename),
- initialized_(false),
- library_(0),
- ppp_get_interface_(NULL) {
+PluginModule::PluginModule()
+ : initialized_(false),
+ library_(NULL) {
GetMainThreadMessageLoop(); // Initialize the main thread message loop.
GetLivePluginSet()->insert(this);
}
@@ -203,25 +198,31 @@ PluginModule::~PluginModule() {
GetLivePluginSet()->erase(this);
- if (library_) {
- PPP_ShutdownModuleFunc shutdown_module =
- reinterpret_cast<PPP_ShutdownModuleFunc>(
- base::GetFunctionPointerFromNativeLibrary(library_,
- "PPP_ShutdownModule"));
- if (shutdown_module)
- shutdown_module();
+ if (entry_points_.shutdown_module)
+ entry_points_.shutdown_module();
+
+ if (library_)
base::UnloadNativeLibrary(library_);
- }
}
// static
scoped_refptr<PluginModule> PluginModule::CreateModule(
- const FilePath& filename) {
+ const FilePath& path) {
// FIXME(brettw) do uniquifying of the plugin here like the NPAPI one.
- scoped_refptr<PluginModule> lib(new PluginModule(filename));
- if (!lib->Load())
- lib = NULL;
+ scoped_refptr<PluginModule> lib(new PluginModule());
+ if (!lib->InitFromFile(path))
+ return NULL;
+
+ return lib;
+}
+
+scoped_refptr<PluginModule> PluginModule::CreateInternalModule(
+ EntryPoints entry_points) {
+ scoped_refptr<PluginModule> lib(new PluginModule());
+ if (!lib->InitFromEntryPoints(entry_points))
+ return NULL;
+
return lib;
}
@@ -233,39 +234,71 @@ PluginModule* PluginModule::FromPPModule(PP_Module module) {
return lib;
}
-bool PluginModule::Load() {
+bool PluginModule::InitFromEntryPoints(const EntryPoints& entry_points) {
if (initialized_)
return true;
+
+ // Attempt to run the initialization funciton.
+ int retval = entry_points.initialize_module(GetPPModule(), &GetInterface);
+ if (retval != 0) {
+ LOG(WARNING) << "PPP_InitializeModule returned failure " << retval;
+ return false;
+ }
+
+ entry_points_ = entry_points;
initialized_ = true;
+ return true;
+}
- library_ = base::LoadNativeLibrary(filename_);
- if (!library_)
+bool PluginModule::InitFromFile(const FilePath& path) {
+ if (initialized_)
+ return true;
+
+ base::NativeLibrary library = base::LoadNativeLibrary(path);
+ if (!library)
return false;
- // Save the GetInterface function pointer for later.
- ppp_get_interface_ =
+ EntryPoints entry_points;
+ if (!LoadEntryPoints(library, &entry_points) ||
+ !InitFromEntryPoints(entry_points)) {
+ base::UnloadNativeLibrary(library);
+ return false;
+ }
+
+ // We let InitFromEntryPoints() handle setting the all the internal state
+ // of the object other than the |library_| reference.
+ library_ = library;
+ return true;
+}
+
+// static
+bool PluginModule::LoadEntryPoints(const base::NativeLibrary& library,
+ EntryPoints* entry_points) {
+
+ entry_points->get_interface =
reinterpret_cast<PPP_GetInterfaceFunc>(
- base::GetFunctionPointerFromNativeLibrary(library_,
+ base::GetFunctionPointerFromNativeLibrary(library,
"PPP_GetInterface"));
- if (!ppp_get_interface_) {
+ if (!entry_points->get_interface) {
LOG(WARNING) << "No PPP_GetInterface in plugin library";
return false;
}
- // Call the plugin initialize function.
- PPP_InitializeModuleFunc initialize_module =
+ entry_points->initialize_module =
reinterpret_cast<PPP_InitializeModuleFunc>(
- base::GetFunctionPointerFromNativeLibrary(library_,
+ base::GetFunctionPointerFromNativeLibrary(library,
"PPP_InitializeModule"));
- if (!initialize_module) {
+ if (!entry_points->initialize_module) {
LOG(WARNING) << "No PPP_InitializeModule in plugin library";
return false;
}
- int retval = initialize_module(GetPPModule(), &GetInterface);
- if (retval != 0) {
- LOG(WARNING) << "PPP_InitializeModule returned failure " << retval;
- return false;
- }
+
+ // It's okay for PPP_ShutdownModule to not be defined and shutdown_module to
+ // be NULL.
+ entry_points->shutdown_module =
+ reinterpret_cast<PPP_ShutdownModuleFunc>(
+ base::GetFunctionPointerFromNativeLibrary(library,
+ "PPP_ShutdownModule"));
return true;
}
@@ -293,9 +326,9 @@ PluginInstance* PluginModule::GetSomeInstance() const {
}
const void* PluginModule::GetPluginInterface(const char* name) const {
- if (!ppp_get_interface_)
+ if (!entry_points_.get_interface)
return NULL;
- return ppp_get_interface_(name);
+ return entry_points_.get_interface(name);
}
void PluginModule::InstanceCreated(PluginInstance* instance) {
« no previous file with comments | « webkit/glue/plugins/pepper_plugin_module.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698