Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1510)

Unified Diff: content/public/common/startup_task_runner.h

Issue 19957002: Run the later parts of startup as UI thread tasks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Run the later parts of startup as UI thread tasks - minor comment fixes Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/common/startup_task_runner.h
diff --git a/content/public/common/startup_task_runner.h b/content/public/common/startup_task_runner.h
new file mode 100644
index 0000000000000000000000000000000000000000..3a186cdda6e79305d70526c8531e0c10c096d64a
--- /dev/null
+++ b/content/public/common/startup_task_runner.h
@@ -0,0 +1,67 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_STARTUP_TASK_RUNNER_H_
+#define CONTENT_BROWSER_STARTUP_TASK_RUNNER_H_
+
+#include <list>
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/single_thread_task_runner.h"
+
+#include "build/build_config.h"
+
+// 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.
+// or are run one at a time on the UI thread's message loop. The motivation for
+// this is that, on targets where the UI is already started, it allows us to
+// 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.
+
+namespace content {
+
+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
+ public:
+ class Observer {
+ public:
+ virtual ~Observer() {}
+ // Called when all tasks have been run
+ 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.
+ };
+
+ enum StartupMode {
+ IMMEDIATE,
+ INCREMENTAL
+ };
+
+ // Constructor: Note that the observer is optional. The code will check for
+ // a NULL observer before attempting to call observer functions.
+ StartupTaskRunner(StartupMode mode, Observer* observer);
+
+ // Add a task to the queue of startup tasks to be run.
+ virtual void AddTask(base::Closure& callback);
+
+ // Set the task runner to use to run the tasks
+ virtual void SetProxy(
+ const scoped_refptr<base::SingleThreadTaskRunner>& proxy);
+
+ // Start running the tasks.
+ virtual void StartRunningTasks();
+
+ private:
+
+ friend class base::RefCounted<StartupTaskRunner>;
+ virtual ~StartupTaskRunner() {};
+
+ std::list<base::Closure> task_list_;
+ void WrappedTask();
+
+ StartupMode startup_mode_;
+ Observer* observer_;
+ scoped_refptr<base::SingleThreadTaskRunner> proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(StartupTaskRunner);
+};
+
+} // namespace content
+#endif // CONTENT_BROWSER_STARTUP_TASK_RUNNER_H_

Powered by Google App Engine
This is Rietveld 408576698