diff options
Diffstat (limited to 'webkit/support/webkit_support.cc')
-rw-r--r-- | webkit/support/webkit_support.cc | 26 |
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) { |