Home | History | Annotate | Download | only in shell
      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/memory/scoped_ptr.h"
      9 #include "base/message_loop/message_loop_proxy.h"
     10 #include "base/threading/thread.h"
     11 
     12 namespace mojo {
     13 namespace shell {
     14 
     15 // A context object that contains the common task runners for the shell
     16 class TaskRunners {
     17  public:
     18   explicit TaskRunners(base::SingleThreadTaskRunner* ui_runner);
     19   ~TaskRunners();
     20 
     21   base::SingleThreadTaskRunner* ui_runner() const {
     22     return ui_runner_.get();
     23   }
     24 
     25   base::SingleThreadTaskRunner* io_runner() const {
     26     return io_thread_->message_loop_proxy();
     27   }
     28 
     29   base::SingleThreadTaskRunner* file_runner() const {
     30     return file_thread_->message_loop_proxy();
     31   }
     32 
     33   base::MessageLoopProxy* cache_runner() const {
     34     return cache_thread_->message_loop_proxy();
     35   }
     36 
     37  private:
     38   // TODO(beng): should this be named shell_runner_?
     39   scoped_refptr<base::SingleThreadTaskRunner> ui_runner_;
     40   scoped_ptr<base::Thread> cache_thread_;
     41   scoped_ptr<base::Thread> io_thread_;
     42   scoped_ptr<base::Thread> file_thread_;
     43 
     44   DISALLOW_COPY_AND_ASSIGN(TaskRunners);
     45 };
     46 
     47 }  // namespace shell
     48 }  // namespace mojo
     49 
     50 #endif  // MOJO_SHELL_TASK_RUNNERS_H_
     51