task_runners.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
1// Copyright 2013 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 MOJO_SHELL_TASK_RUNNERS_H_
6#define MOJO_SHELL_TASK_RUNNERS_H_
7
8#include "base/macros.h"
9#include "base/memory/ref_counted.h"
10#include "base/memory/scoped_ptr.h"
11#include "base/message_loop/message_loop_proxy.h"
12#include "base/threading/thread.h"
13
14namespace base {
15class SequencedWorkerPool;
16}
17
18namespace mojo {
19namespace shell {
20
21// A context object that contains the common task runners for the shell's main
22// process.
23class TaskRunners {
24 public:
25  explicit TaskRunners(base::SingleThreadTaskRunner* ui_runner);
26  ~TaskRunners();
27
28  base::SingleThreadTaskRunner* ui_runner() const {
29    return ui_runner_.get();
30  }
31
32  base::SingleThreadTaskRunner* io_runner() const {
33    return io_thread_->message_loop_proxy();
34  }
35
36  base::SequencedWorkerPool* blocking_pool() const {
37    return blocking_pool_.get();
38  }
39
40 private:
41  // TODO(beng): should this be named shell_runner_?
42  scoped_refptr<base::SingleThreadTaskRunner> ui_runner_;
43  scoped_ptr<base::Thread> io_thread_;
44
45  scoped_refptr<base::SequencedWorkerPool> blocking_pool_;
46
47  DISALLOW_COPY_AND_ASSIGN(TaskRunners);
48};
49
50}  // namespace shell
51}  // namespace mojo
52
53#endif  // MOJO_SHELL_TASK_RUNNERS_H_
54