summaryrefslogtreecommitdiffstats
path: root/content/child/worker_thread_task_runner.cc
blob: 8e5b2e75a4e4266e77be471b53bed5361fe17cf8 (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
// 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.

#include "content/child/worker_thread_task_runner.h"

#include "base/logging.h"
#include "content/child/worker_task_runner.h"

namespace content {

WorkerThreadTaskRunner::WorkerThreadTaskRunner(int worker_thread_id)
    : worker_thread_id_(worker_thread_id) {
}

scoped_refptr<WorkerThreadTaskRunner> WorkerThreadTaskRunner::current() {
  int worker_thread_id = WorkerTaskRunner::Instance()->CurrentWorkerId();
  if (!worker_thread_id)
    return scoped_refptr<WorkerThreadTaskRunner>();
  return make_scoped_refptr(new WorkerThreadTaskRunner(worker_thread_id));
}

bool WorkerThreadTaskRunner::PostDelayedTask(
    const tracked_objects::Location& /* from_here */,
    const base::Closure& task,
    base::TimeDelta delay) {
  // Currently non-zero delay is not supported.
  DCHECK(!delay.ToInternalValue());
  return WorkerTaskRunner::Instance()->PostTask(worker_thread_id_, task);
}

bool WorkerThreadTaskRunner::RunsTasksOnCurrentThread() const {
  return worker_thread_id_ == WorkerTaskRunner::Instance()->CurrentWorkerId();
}

WorkerThreadTaskRunner::~WorkerThreadTaskRunner() {}

}  // namespace content