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

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

Issue 2834021: Revert 50667 - Add in support for internal pepper plugins into the PepperPlug... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
===================================================================
--- webkit/glue/plugins/pepper_plugin_module.cc (revision 50670)
+++ webkit/glue/plugins/pepper_plugin_module.cc (working copy)
@@ -31,6 +31,9 @@
#include "webkit/glue/plugins/pepper_resource_tracker.h"
#include "webkit/glue/plugins/pepper_var.h"
+typedef bool (*PPP_InitializeModuleFunc)(PP_Module, PPB_GetInterface);
+typedef void (*PPP_ShutdownModuleFunc)();
+
namespace pepper {
namespace {
@@ -155,9 +158,11 @@
} // namespace
-PluginModule::PluginModule()
- : initialized_(false),
- library_(NULL) {
+PluginModule::PluginModule(const FilePath& filename)
+ : filename_(filename),
+ initialized_(false),
+ library_(0),
+ ppp_get_interface_(NULL) {
GetMainThreadMessageLoop(); // Initialize the main thread message loop.
GetLivePluginSet()->insert(this);
}
@@ -169,34 +174,28 @@
GetLivePluginSet()->erase(this);
- if (entry_points_.shutdown_module)
- entry_points_.shutdown_module();
-
- if (library_)
+ if (library_) {
+ PPP_ShutdownModuleFunc shutdown_module =
+ reinterpret_cast<PPP_ShutdownModuleFunc>(
+ base::GetFunctionPointerFromNativeLibrary(library_,
+ "PPP_ShutdownModule"));
+ if (shutdown_module)
+ shutdown_module();
base::UnloadNativeLibrary(library_);
+ }
}
// static
scoped_refptr<PluginModule> PluginModule::CreateModule(
- const FilePath& path) {
+ const FilePath& filename) {
// FIXME(brettw) do uniquifying of the plugin here like the NPAPI one.
- scoped_refptr<PluginModule> lib(new PluginModule());
- if (!lib->InitFromFile(path))
- return NULL;
-
+ scoped_refptr<PluginModule> lib(new PluginModule(filename));
+ if (!lib->Load())
+ lib = 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;
-}
-
// static
PluginModule* PluginModule::FromPPModule(PP_Module module) {
PluginModule* lib = reinterpret_cast<PluginModule*>(module);
@@ -205,72 +204,40 @@
return lib;
}
-bool PluginModule::InitFromEntryPoints(const EntryPoints& entry_points) {
+bool PluginModule::Load() {
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;
-}
-bool PluginModule::InitFromFile(const FilePath& path) {
- if (initialized_)
- return true;
-
- base::NativeLibrary library = base::LoadNativeLibrary(path);
- if (!library)
+ library_ = base::LoadNativeLibrary(filename_);
+ if (!library_)
return false;
- 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 =
+ // Save the GetInterface function pointer for later.
+ ppp_get_interface_ =
reinterpret_cast<PPP_GetInterfaceFunc>(
- base::GetFunctionPointerFromNativeLibrary(library,
+ base::GetFunctionPointerFromNativeLibrary(library_,
"PPP_GetInterface"));
- if (!entry_points->get_interface) {
+ if (!ppp_get_interface_) {
LOG(WARNING) << "No PPP_GetInterface in plugin library";
return false;
}
- entry_points->initialize_module =
+ // Call the plugin initialize function.
+ PPP_InitializeModuleFunc initialize_module =
reinterpret_cast<PPP_InitializeModuleFunc>(
- base::GetFunctionPointerFromNativeLibrary(library,
+ base::GetFunctionPointerFromNativeLibrary(library_,
"PPP_InitializeModule"));
- if (!entry_points->initialize_module) {
+ if (!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;
}
@@ -297,9 +264,9 @@
}
const void* PluginModule::GetPluginInterface(const char* name) const {
- if (!entry_points_.get_interface)
+ if (!ppp_get_interface_)
return NULL;
- return entry_points_.get_interface(name);
+ return ppp_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