summaryrefslogtreecommitdiffstats
path: root/cc/base/thread_impl.h
blob: 064c8bfa95f3f22a691b307fcce7aba170f3f929 (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
40
41
42
43
// 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.

#ifndef CC_BASE_THREAD_IMPL_H_
#define CC_BASE_THREAD_IMPL_H_

#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop_proxy.h"
#include "cc/base/cc_export.h"
#include "cc/base/thread.h"

namespace cc {

// Implements cc::Thread in terms of base::MessageLoopProxy.
class CC_EXPORT ThreadImpl : public Thread {
 public:
  // Creates a ThreadImpl wrapping the current thread.
  static scoped_ptr<cc::Thread> CreateForCurrentThread();

  // Creates a Thread wrapping a non-current thread.
  static scoped_ptr<cc::Thread> CreateForDifferentThread(
      scoped_refptr<base::MessageLoopProxy> thread);

  virtual ~ThreadImpl();

  virtual void PostTask(base::Closure cb) OVERRIDE;
  virtual void PostDelayedTask(base::Closure cb, base::TimeDelta delay)
      OVERRIDE;
  virtual bool BelongsToCurrentThread() const OVERRIDE;

 private:
  explicit ThreadImpl(scoped_refptr<base::MessageLoopProxy> thread);

  scoped_refptr<base::MessageLoopProxy> thread_;

  DISALLOW_COPY_AND_ASSIGN(ThreadImpl);
};

}  // namespace cc

#endif  // CC_BASE_THREAD_IMPL_H_