1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BASE_MESSAGE_LOOP_MESSAGE_LOOP_PROXY_IMPL_H_
6#define BASE_MESSAGE_LOOP_MESSAGE_LOOP_PROXY_IMPL_H_
7
8#include "base/base_export.h"
9#include "base/memory/ref_counted.h"
10#include "base/message_loop/message_loop_proxy.h"
11#include "base/pending_task.h"
12#include "base/threading/platform_thread.h"
13
14namespace base {
15namespace internal {
16
17class IncomingTaskQueue;
18
19// A stock implementation of MessageLoopProxy that is created and managed by a
20// MessageLoop. For now a MessageLoopProxyImpl can only be created as part of a
21// MessageLoop.
22class BASE_EXPORT MessageLoopProxyImpl : public MessageLoopProxy {
23 public:
24  explicit MessageLoopProxyImpl(
25      scoped_refptr<IncomingTaskQueue> incoming_queue);
26
27  // MessageLoopProxy implementation
28  virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
29                               const base::Closure& task,
30                               base::TimeDelta delay) OVERRIDE;
31  virtual bool PostNonNestableDelayedTask(
32      const tracked_objects::Location& from_here,
33      const base::Closure& task,
34      base::TimeDelta delay) OVERRIDE;
35  virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
36
37 private:
38  friend class RefCountedThreadSafe<MessageLoopProxyImpl>;
39  virtual ~MessageLoopProxyImpl();
40
41  // THe incoming queue receiving all posted tasks.
42  scoped_refptr<IncomingTaskQueue> incoming_queue_;
43
44  // ID of the thread |this| was created on.
45  PlatformThreadId valid_thread_id_;
46
47  DISALLOW_COPY_AND_ASSIGN(MessageLoopProxyImpl);
48};
49
50}  // namespace internal
51}  // namespace base
52
53#endif  // BASE_MESSAGE_LOOP_MESSAGE_LOOP_PROXY_IMPL_H_
54