Add an UMA stat to be able to see if the User pods are show on start screen,
[chromium-blink-merge.git] / content / child / scheduler / single_thread_idle_task_runner.h
blobb5281a57389139a8a33ea8e13cb8b1bf7c6e947b
1 // Copyright 2014 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.
5 #ifndef CONTENT_CHILD_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_
6 #define CONTENT_CHILD_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_
8 #include "base/bind.h"
9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/single_thread_task_runner.h"
12 #include "base/time/time.h"
14 namespace content {
16 // A SingleThreadIdleTaskRunner is a task runner for running idle tasks. Idle
17 // tasks have an unbound argument which is bound to a deadline
18 // (in base::TimeTicks) when they are run. The idle task is expected to
19 // complete by this deadline.
20 class SingleThreadIdleTaskRunner
21 : public base::RefCountedThreadSafe<SingleThreadIdleTaskRunner> {
22 public:
23 typedef base::Callback<void(base::TimeTicks)> IdleTask;
25 // NOTE Category strings must have application lifetime (statics or
26 // literals). They may not include " chars.
27 SingleThreadIdleTaskRunner(
28 scoped_refptr<base::SingleThreadTaskRunner> idle_priority_task_runner,
29 scoped_refptr<base::SingleThreadTaskRunner> after_wakeup_task_runner,
30 base::Callback<void(base::TimeTicks*)> deadline_supplier,
31 const char* tracing_category);
33 virtual void PostIdleTask(const tracked_objects::Location& from_here,
34 const IdleTask& idle_task);
36 virtual void PostNonNestableIdleTask(
37 const tracked_objects::Location& from_here,
38 const IdleTask& idle_task);
40 virtual void PostIdleTaskAfterWakeup(
41 const tracked_objects::Location& from_here,
42 const IdleTask& idle_task);
44 bool RunsTasksOnCurrentThread() const;
46 protected:
47 virtual ~SingleThreadIdleTaskRunner();
49 private:
50 friend class base::RefCountedThreadSafe<SingleThreadIdleTaskRunner>;
52 void RunTask(IdleTask idle_task);
54 scoped_refptr<base::SingleThreadTaskRunner> idle_priority_task_runner_;
55 scoped_refptr<base::SingleThreadTaskRunner> after_wakeup_task_runner_;
56 base::Callback<void(base::TimeTicks*)> deadline_supplier_;
57 const char* tracing_category_;
58 base::WeakPtr<SingleThreadIdleTaskRunner> weak_scheduler_ptr_;
59 base::WeakPtrFactory<SingleThreadIdleTaskRunner> weak_factory_;
60 DISALLOW_COPY_AND_ASSIGN(SingleThreadIdleTaskRunner);
63 } // namespace content
65 #endif // CONTENT_CHILD_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_