Change layout of app list items in experimental app list.
[chromium-blink-merge.git] / content / browser / startup_task_runner.h
blob80e5627803f38144c3bf616e54607239172987f3
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.
5 #ifndef CONTENT_BROWSER_STARTUP_TASK_RUNNER_H_
6 #define CONTENT_BROWSER_STARTUP_TASK_RUNNER_H_
8 #include <list>
10 #include "base/callback.h"
11 #include "base/single_thread_task_runner.h"
13 #include "build/build_config.h"
15 #include "content/public/browser/browser_main_runner.h"
17 namespace content {
19 // A startup task is a void function returning the status on completion.
20 // a status of > 0 indicates a failure, and that no further startup tasks should
21 // be run.
22 typedef base::Callback<int(void)> StartupTask;
24 // This class runs startup tasks. The tasks are either run immediately inline,
25 // or are queued one at a time on the UI thread's message loop. If the events
26 // are queued, UI events that are received during startup will be acted upon
27 // between startup tasks. The motivation for this is that, on targets where the
28 // UI is already started, it allows us to keep the UI responsive during startup.
30 // Note that this differs from a SingleThreadedTaskRunner in that there may be
31 // no opportunity to handle UI events between the tasks of a
32 // SingleThreadedTaskRunner.
34 class CONTENT_EXPORT StartupTaskRunner {
36 public:
37 // Constructor: Note that |startup_complete_callback| is optional. If it is
38 // not null it will be called once all the startup tasks have run.
39 StartupTaskRunner(base::Callback<void(int)> startup_complete_callback,
40 scoped_refptr<base::SingleThreadTaskRunner> proxy);
42 ~StartupTaskRunner();
44 // Add a task to the queue of startup tasks to be run.
45 void AddTask(StartupTask& callback);
47 // Start running the tasks asynchronously.
48 void StartRunningTasksAsync();
50 // Run all tasks, or all remaining tasks, synchronously
51 void RunAllTasksNow();
53 private:
54 friend class base::RefCounted<StartupTaskRunner>;
56 std::list<StartupTask> task_list_;
57 void WrappedTask();
59 base::Callback<void(int)> startup_complete_callback_;
60 scoped_refptr<base::SingleThreadTaskRunner> proxy_;
62 DISALLOW_COPY_AND_ASSIGN(StartupTaskRunner);
65 } // namespace content
66 #endif // CONTENT_BROWSER_STARTUP_TASK_RUNNER_H_