summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-28 16:56:38 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-28 16:56:38 +0000
commit3ff5f35aa4b4e6dd82ba60d9d248e9a4cd3da44e (patch)
treeb82f8558bdd9762d66aa7eaaa6f883ef91ff95b1 /webkit
parent125a48a1d40b94453e9282f71b16127c1b8643af (diff)
downloadchromium_src-3ff5f35aa4b4e6dd82ba60d9d248e9a4cd3da44e.zip
chromium_src-3ff5f35aa4b4e6dd82ba60d9d248e9a4cd3da44e.tar.gz
chromium_src-3ff5f35aa4b4e6dd82ba60d9d248e9a4cd3da44e.tar.bz2
Remove custom Task implementations in webkit/
BUG=none TEST=trybots Review URL: http://codereview.chromium.org/8695010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111711 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/plugins/npapi/plugin_lib.cc71
-rw-r--r--webkit/plugins/npapi/test/plugin_thread_async_call_test.cc18
2 files changed, 32 insertions, 57 deletions
diff --git a/webkit/plugins/npapi/plugin_lib.cc b/webkit/plugins/npapi/plugin_lib.cc
index f333f8e..ed01426 100644
--- a/webkit/plugins/npapi/plugin_lib.cc
+++ b/webkit/plugins/npapi/plugin_lib.cc
@@ -4,6 +4,7 @@
#include "webkit/plugins/npapi/plugin_lib.h"
+#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/metrics/stats_counters.h"
@@ -268,48 +269,31 @@ bool PluginLib::Load() {
return rv;
}
-// This class implements delayed NP_Shutdown and FreeLibrary on the plugin dll.
-class FreePluginLibraryTask : public Task {
- public:
- FreePluginLibraryTask(const FilePath& path,
- base::NativeLibrary library,
- NP_ShutdownFunc shutdown_func)
- : path_(path),
- library_(library),
- NP_Shutdown_(shutdown_func) {
- }
-
- ~FreePluginLibraryTask() {}
-
- void Run() {
- if (NP_Shutdown_) {
- // Don't call NP_Shutdown if the library has been reloaded since this task
- // was posted.
- bool reloaded = false;
- if (g_loaded_libs) {
- for (size_t i = 0; i < g_loaded_libs->size(); ++i) {
- if ((*g_loaded_libs)[i]->plugin_info().path == path_)
- reloaded = true;
- }
+// This is a helper to help perform a delayed NP_Shutdown and FreeLibrary on the
+// plugin dll.
+void FreePluginLibraryHelper(const FilePath& path,
+ base::NativeLibrary library,
+ NP_ShutdownFunc shutdown_func) {
+ if (shutdown_func) {
+ // Don't call NP_Shutdown if the library has been reloaded since this task
+ // was posted.
+ bool reloaded = false;
+ if (g_loaded_libs) {
+ for (size_t i = 0; i < g_loaded_libs->size(); ++i) {
+ if ((*g_loaded_libs)[i]->plugin_info().path == path)
+ reloaded = true;
}
- if (!reloaded)
- NP_Shutdown_();
- }
-
- if (library_) {
- // Always call base::UnloadNativeLibrary so that the system reference
- // count is decremented.
- base::UnloadNativeLibrary(library_);
- library_ = NULL;
}
+ if (!reloaded)
+ shutdown_func();
}
- private:
- FilePath path_;
- base::NativeLibrary library_;
- NP_ShutdownFunc NP_Shutdown_;
- DISALLOW_COPY_AND_ASSIGN(FreePluginLibraryTask);
-};
+ if (library) {
+ // Always call base::UnloadNativeLibrary so that the system reference
+ // count is decremented.
+ base::UnloadNativeLibrary(library);
+ }
+}
void PluginLib::Unload() {
if (!internal_ && library_) {
@@ -325,14 +309,15 @@ void PluginLib::Unload() {
#endif
*/
if (!defer_unload_) {
- FreePluginLibraryTask* free_library_task =
- new FreePluginLibraryTask(web_plugin_info_.path,
- skip_unload_ ? NULL : library_,
- entry_points_.np_shutdown);
LOG_IF(ERROR, PluginList::DebugPluginLoading())
<< "Scheduling delayed unload for plugin "
<< web_plugin_info_.path.value();
- MessageLoop::current()->PostTask(FROM_HERE, free_library_task);
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&FreePluginLibraryHelper,
+ web_plugin_info_.path,
+ skip_unload_ ? NULL : library_,
+ entry_points_.np_shutdown));
} else {
Shutdown();
if (!skip_unload_) {
diff --git a/webkit/plugins/npapi/test/plugin_thread_async_call_test.cc b/webkit/plugins/npapi/test/plugin_thread_async_call_test.cc
index ecf8759..cab4411 100644
--- a/webkit/plugins/npapi/test/plugin_thread_async_call_test.cc
+++ b/webkit/plugins/npapi/test/plugin_thread_async_call_test.cc
@@ -7,6 +7,7 @@
#include "webkit/plugins/npapi/test/plugin_thread_async_call_test.h"
+#include "base/bind.h"
#include "base/message_loop.h"
#include "base/string_util.h"
#include "base/threading/thread.h"
@@ -26,19 +27,6 @@ void OnCallSucceededHelper(void* data) {
static_cast<PluginThreadAsyncCallTest*>(data)->OnCallSucceeded();
}
-class AsyncCallTask : public Task {
- public:
- AsyncCallTask(PluginThreadAsyncCallTest* test_class)
- : test_class_(test_class) {}
-
- void Run() {
- test_class_->AsyncCall();
- }
-
- private:
- PluginThreadAsyncCallTest* test_class_;
-};
-
void OnCallFailed(void* data) {
g_long_lived_instance->SetError("Async callback invoked after NPP_Destroy");
}
@@ -84,7 +72,9 @@ NPError PluginThreadAsyncCallTest::New(
at_exit_manager_ = new base::ShadowingAtExitManager();
base::Thread random_thread("random_thread");
random_thread.Start();
- random_thread.message_loop()->PostTask(FROM_HERE, new AsyncCallTask(this));
+ random_thread.message_loop()->PostTask(
+ FROM_HERE, base::Bind(&PluginThreadAsyncCallTest::AsyncCall,
+ base::Unretained(this)));
}
return NPERR_NO_ERROR;