summaryrefslogtreecommitdiffstats
path: root/cc/base/thread_impl.cc
blob: 8e779cbf9d853f9c40a1dccd33c61c9569533570 (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 2011 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 "cc/base/thread_impl.h"

#include "base/message_loop.h"

namespace cc {

scoped_ptr<Thread> ThreadImpl::CreateForCurrentThread() {
  return scoped_ptr<Thread>(
      new ThreadImpl(base::MessageLoopProxy::current())).Pass();
}

scoped_ptr<Thread> ThreadImpl::CreateForDifferentThread(
    scoped_refptr<base::MessageLoopProxy> thread) {
  return scoped_ptr<Thread>(new ThreadImpl(thread)).Pass();
}

ThreadImpl::~ThreadImpl() {}

void ThreadImpl::PostTask(base::Closure cb) {
  thread_->PostTask(FROM_HERE, cb);
}

void ThreadImpl::PostDelayedTask(base::Closure cb, base::TimeDelta delay) {
  thread_->PostDelayedTask(FROM_HERE, cb, delay);
}

bool ThreadImpl::BelongsToCurrentThread() const {
  return thread_->BelongsToCurrentThread();
}

ThreadImpl::ThreadImpl(scoped_refptr<base::MessageLoopProxy> thread)
    : thread_(thread) {}

}  // namespace cc