summaryrefslogtreecommitdiffstats
path: root/webkit/support/webkit_support.cc
diff options
context:
space:
mode:
authormorrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 06:41:13 +0000
committermorrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 06:41:13 +0000
commit07f63c6bba7e33160fc54af7f2cf4cf207e0831b (patch)
treecea4aac3782d324a787a7f08fbc3113e841189dc /webkit/support/webkit_support.cc
parent1f06a56edde410253186f4b6b5cdfe516f0bb4ff (diff)
downloadchromium_src-07f63c6bba7e33160fc54af7f2cf4cf207e0831b.zip
chromium_src-07f63c6bba7e33160fc54af7f2cf4cf207e0831b.tar.gz
chromium_src-07f63c6bba7e33160fc54af7f2cf4cf207e0831b.tar.bz2
Add webkit_support::TaskAdaptor to make tasks have the desttructor.
BUG=73675 TEST=none Review URL: http://codereview.chromium.org/6602006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/support/webkit_support.cc')
-rw-r--r--webkit/support/webkit_support.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc
index 9e850f4..2d994af 100644
--- a/webkit/support/webkit_support.cc
+++ b/webkit/support/webkit_support.cc
@@ -17,6 +17,7 @@
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/process_util.h"
+#include "base/ref_counted.h"
#include "base/string_piece.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
@@ -190,6 +191,26 @@ class WebKitClientMessageLoopImpl
MessageLoop* message_loop_;
};
+// An wrapper object for giving TaskAdaptor ref-countability,
+// which NewRunnableMethod() requires.
+class TaskAdaptorHolder : public CancelableTask {
+ public:
+ explicit TaskAdaptorHolder(webkit_support::TaskAdaptor* adaptor)
+ : adaptor_(adaptor) {
+ }
+
+ virtual void Run() {
+ adaptor_->Run();
+ }
+
+ virtual void Cancel() {
+ adaptor_.reset();
+ }
+
+ private:
+ scoped_ptr<webkit_support::TaskAdaptor> adaptor_;
+};
+
} // namespace
namespace webkit_support {
@@ -371,6 +392,11 @@ void PostDelayedTask(void (*func)(void*), void* context, int64 delay_ms) {
FROM_HERE, NewRunnableFunction(func, context), delay_ms);
}
+void PostDelayedTask(TaskAdaptor* task, int64 delay_ms) {
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, new TaskAdaptorHolder(task), delay_ms);
+}
+
// Wrappers for FilePath and file_util
WebString GetAbsoluteWebStringFromUTF8Path(const std::string& utf8_path) {