diff options
Diffstat (limited to 'webkit/quota')
-rw-r--r-- | webkit/quota/quota_task.cc | 12 | ||||
-rw-r--r-- | webkit/quota/quota_task.h | 14 |
2 files changed, 22 insertions, 4 deletions
diff --git a/webkit/quota/quota_task.cc b/webkit/quota/quota_task.cc index 78a8b36..1f25ddf 100644 --- a/webkit/quota/quota_task.cc +++ b/webkit/quota/quota_task.cc @@ -67,9 +67,17 @@ void QuotaThreadTask::Run() { void QuotaThreadTask::CallRunOnTargetThread() { DCHECK(target_message_loop_->BelongsToCurrentThread()); + if (RunOnTargetThreadAsync()) + original_message_loop()->PostTask( + FROM_HERE, NewRunnableMethod(this, &QuotaThreadTask::CallCompleted)); +} + +bool QuotaThreadTask::RunOnTargetThreadAsync() { RunOnTargetThread(); - original_message_loop()->PostTask( - FROM_HERE, NewRunnableMethod(this, &QuotaThreadTask::CallCompleted)); + return true; +} + +void QuotaThreadTask::RunOnTargetThread() { } // QuotaTaskObserver ------------------------------------------------------- diff --git a/webkit/quota/quota_task.h b/webkit/quota/quota_task.h index 860ec0d..6b56593 100644 --- a/webkit/quota/quota_task.h +++ b/webkit/quota/quota_task.h @@ -66,8 +66,18 @@ class QuotaThreadTask : public QuotaTask, protected: virtual ~QuotaThreadTask(); - // Called on the target message loop. - virtual void RunOnTargetThread() = 0; + // One of the following Run methods should be overriden for execution + // on the target thread. + + // A task to invoke the CallCompleted() method on the original thread will + // be scheduled immediately upon return from RunOnTargetThread(). + virtual void RunOnTargetThread(); + + // A task to invoke the CallCompleted() method on the original thread will + // only be scheduled if RunOnTargetThreadAsync returns true. If false is + // returned, the derived class should schedule a task to do so upon actual + // completion. + virtual bool RunOnTargetThreadAsync(); virtual void Run() OVERRIDE; scoped_refptr<base::MessageLoopProxy> target_message_loop() const { |