[EFL] Use Eina_Module API instead of dlopen in PluginPackageEfl
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jun 2012 20:56:29 +0000 (20:56 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jun 2012 20:56:29 +0000 (20:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89972

Patch by Christophe Dumez <christophe.dumez@intel.com> on 2012-06-28
Reviewed by Antonio Gomes.

Use convenience helpers in Eina_Module to load plugins instead
of POSIX dlopen().

No new tests, behavior has not changed.

* platform/FileSystem.h:
(WebCore):
* platform/efl/FileSystemEfl.cpp:
(WebCore::unloadModule):
* plugins/efl/PluginPackageEfl.cpp:
(WebCore::PluginPackage::load):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121467 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/FileSystem.h
Source/WebCore/platform/efl/FileSystemEfl.cpp
Source/WebCore/plugins/efl/PluginPackageEfl.cpp

index f0fa796..3c6e08f 100644 (file)
@@ -1,3 +1,22 @@
+2012-06-28  Christophe Dumez  <christophe.dumez@intel.com>
+
+        [EFL] Use Eina_Module API instead of dlopen in PluginPackageEfl
+        https://bugs.webkit.org/show_bug.cgi?id=89972
+
+        Reviewed by Antonio Gomes.
+
+        Use convenience helpers in Eina_Module to load plugins instead
+        of POSIX dlopen().
+
+        No new tests, behavior has not changed.
+
+        * platform/FileSystem.h:
+        (WebCore):
+        * platform/efl/FileSystemEfl.cpp:
+        (WebCore::unloadModule):
+        * plugins/efl/PluginPackageEfl.cpp:
+        (WebCore::PluginPackage::load):
+
 2012-06-28  Jocelyn Turcotte  <turcotte.j@gmail.com>
 
         [Qt] Fix TextureMapper rendering of GraphicsSurface on Mac
index b3c259a..a6b3a67 100644 (file)
@@ -71,6 +71,10 @@ typedef struct _GFileIOStream GFileIOStream;
 typedef struct _GModule GModule;
 #endif
 
+#if PLATFORM(EFL)
+typedef struct _Eina_Module Eina_Module;
+#endif
+
 namespace WebCore {
 
 // PlatformModule
@@ -78,6 +82,8 @@ namespace WebCore {
 typedef HMODULE PlatformModule;
 #elif PLATFORM(GTK)
 typedef GModule* PlatformModule;
+#elif PLATFORM(EFL)
+typedef Eina_Module* PlatformModule;
 #elif PLATFORM(QT)
 #if defined(Q_WS_MAC)
 typedef CFBundleRef PlatformModule;
index c6bff15..0caae89 100644 (file)
@@ -70,7 +70,7 @@ bool unloadModule(PlatformModule module)
     // caution, closing handle will make memory vanish and any remaining
     // timer, idler, threads or any other left-over will crash,
     // maybe just ignore this is a safer solution?
-    return !dlclose(module);
+    return eina_module_free(module);
 }
 
 String homeDirectoryPath()
index 7b950d3..5753ed7 100644 (file)
@@ -111,33 +111,33 @@ uint16_t PluginPackage::NPVersion() const
 
 bool PluginPackage::load()
 {
-    char* errmsg;
-
     if (m_isLoaded) {
-        m_loadCount++;
+        ++m_loadCount;
         return true;
     }
 
-    m_module = dlopen(m_path.utf8().data(), RTLD_LAZY | RTLD_LOCAL);
-    if ((errmsg = dlerror())) {
-        EINA_LOG_WARN("%s not loaded: %s", m_path.utf8().data(), errmsg);
+    m_module = eina_module_new(m_path.utf8().data());
+    if (!m_module) {
+        EINA_LOG_WARN("%s not loaded: eina_module_new() failed", m_path.utf8().data());
+        return false;
+    }
+    if (!eina_module_load(m_module)) {
+        const char* errorMessage = eina_error_msg_get(eina_error_get());
+        EINA_LOG_WARN("%s not loaded: %s", m_path.utf8().data(), errorMessage ? errorMessage : "None");
         return false;
     }
 
     m_isLoaded = true;
 
-    NP_InitializeFuncPtr initialize;
-    NPError err;
-
-    initialize = reinterpret_cast<NP_InitializeFuncPtr>(dlsym(m_module, "NP_Initialize"));
-    if ((errmsg = dlerror())) {
-        EINA_LOG_ERR("Could not get symbol NP_Initialize: %s", errmsg);
+    NP_InitializeFuncPtr initialize = reinterpret_cast<NP_InitializeFuncPtr>(eina_module_symbol_get(m_module, "NP_Initialize"));
+    if (!initialize) {
+        EINA_LOG_ERR("Could not get symbol NP_Initialize");
         goto abort;
     }
 
-    m_NPP_Shutdown = reinterpret_cast<NPP_ShutdownProcPtr>(dlsym(m_module, "NP_Shutdown"));
-    if ((errmsg = dlerror())) {
-        EINA_LOG_ERR("Could not get symbol NP_Shutdown: %s", errmsg);
+    m_NPP_Shutdown = reinterpret_cast<NPP_ShutdownProcPtr>(eina_module_symbol_get(m_module, "NP_Shutdown"));
+    if (!m_NPP_Shutdown) {
+        EINA_LOG_ERR("Could not get symbol NP_Shutdown");
         goto abort;
     }
 
@@ -147,14 +147,14 @@ bool PluginPackage::load()
     initializeBrowserFuncs();
 
 #if defined(XP_UNIX)
-    err = initialize(&m_browserFuncs, &m_pluginFuncs);
+    NPError err = initialize(&m_browserFuncs, &m_pluginFuncs);
 #else
-    err = initialize(&m_browserFuncs);
+    NPError err = initialize(&m_browserFuncs);
 #endif
     if (err != NPERR_NO_ERROR)
         goto abort;
 
-    m_loadCount++;
+    ++m_loadCount;
     return true;
 
 abort: