Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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 CONTENT_BROWSER_STARTUP_TASK_RUNNER_H_ | |
| 6 #define CONTENT_BROWSER_STARTUP_TASK_RUNNER_H_ | |
| 7 | |
| 8 #include <list> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/single_thread_task_runner.h" | |
| 13 | |
| 14 #include "build/build_config.h" | |
| 15 | |
| 16 // This class runs startup tasks.The tasks are either run immediately inline, | |
|
joth
2013/07/22 16:28:15
nit: space after stop.
aberent
2013/07/22 19:37:40
Done.
| |
| 17 // or are run one at a time on the UI thread's message loop. The motivation for | |
| 18 // this is that, on targets where the UI is already started, it allows us to | |
| 19 // keep the UI responsive during startup. | |
|
joth
2013/07/22 16:28:15
nit: I think comment block goes inside namespace i
aberent
2013/07/22 19:37:40
Done.
| |
| 20 | |
| 21 namespace content { | |
| 22 | |
| 23 class StartupTaskRunner : public base::RefCounted<StartupTaskRunner> { | |
|
joth
2013/07/22 16:28:15
remind me: why not using SequencedTaskRunner ?
cou
aberent
2013/07/22 19:37:40
I have extended the class comment with a note expl
| |
| 24 public: | |
| 25 class Observer { | |
| 26 public: | |
| 27 virtual ~Observer() {} | |
| 28 // Called when all tasks have been run | |
| 29 virtual void AllTasksRun() = 0; | |
|
joth
2013/07/22 16:28:15
same comment as the java observer
aberent
2013/07/22 19:37:40
Done.
| |
| 30 }; | |
| 31 | |
| 32 enum StartupMode { | |
| 33 IMMEDIATE, | |
| 34 INCREMENTAL | |
| 35 }; | |
| 36 | |
| 37 // Constructor: Note that the observer is optional. The code will check for | |
| 38 // a NULL observer before attempting to call observer functions. | |
| 39 StartupTaskRunner(StartupMode mode, Observer* observer); | |
| 40 | |
| 41 // Add a task to the queue of startup tasks to be run. | |
| 42 virtual void AddTask(base::Closure& callback); | |
| 43 | |
| 44 // Set the task runner to use to run the tasks | |
| 45 virtual void SetProxy( | |
| 46 const scoped_refptr<base::SingleThreadTaskRunner>& proxy); | |
| 47 | |
| 48 // Start running the tasks. | |
| 49 virtual void StartRunningTasks(); | |
| 50 | |
| 51 private: | |
| 52 | |
| 53 friend class base::RefCounted<StartupTaskRunner>; | |
| 54 virtual ~StartupTaskRunner() {}; | |
| 55 | |
| 56 std::list<base::Closure> task_list_; | |
| 57 void WrappedTask(); | |
| 58 | |
| 59 StartupMode startup_mode_; | |
| 60 Observer* observer_; | |
| 61 scoped_refptr<base::SingleThreadTaskRunner> proxy_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(StartupTaskRunner); | |
| 64 }; | |
| 65 | |
| 66 } // namespace content | |
| 67 #endif // CONTENT_BROWSER_STARTUP_TASK_RUNNER_H_ | |
| OLD | NEW |