summaryrefslogtreecommitdiffstats
path: root/content/child/worker_thread_task_runner.h
blob: 54b9ea0bc984348ceb38032f4700f16b5d925ebf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_CHILD_WORKER_THREAD_TASK_RUNNER_H_
#define CONTENT_CHILD_WORKER_THREAD_TASK_RUNNER_H_

#include "base/task_runner.h"

namespace content {

// A task runner that runs tasks on a single webkit worker thread which
// is managed by WorkerTaskRunner.
// Note that this implementation ignores the delay duration for PostDelayedTask
// and have it behave the same as PostTask.
class WorkerThreadTaskRunner : public base::TaskRunner {
 public:
  explicit WorkerThreadTaskRunner(int worker_thread_id);

  // Gets the WorkerThreadTaskRunner for the current worker thread.
  // This returns non-null value only when it is called on a worker thread.
  static scoped_refptr<WorkerThreadTaskRunner> current();

  // TaskRunner overrides.
  virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
                               const base::Closure& task,
                               base::TimeDelta delay) OVERRIDE;
  virtual bool RunsTasksOnCurrentThread() const OVERRIDE;

 protected:
  virtual ~WorkerThreadTaskRunner();

 private:
  const int worker_thread_id_;
};

}  // namespace content

#endif  // CONTENT_CHILD_WORKER_THREAD_TASK_RUNNER_H_