summaryrefslogtreecommitdiffstats
path: root/chrome/browser/profiles/startup_task_runner_service.h
diff options
context:
space:
mode:
authormsarda@chromium.org <msarda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-18 17:17:33 +0000
committermsarda@chromium.org <msarda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-18 17:17:33 +0000
commitafecfb73fdbca719e3a861b3255e68f2c3ef8780 (patch)
treed10462f24aae74062803c782ae05cfbf6819bd41 /chrome/browser/profiles/startup_task_runner_service.h
parentac68e24b25c6578e131ba420abeeebddfb7bca0c (diff)
downloadchromium_src-afecfb73fdbca719e3a861b3255e68f2c3ef8780.zip
chromium_src-afecfb73fdbca719e3a861b3255e68f2c3ef8780.tar.gz
chromium_src-afecfb73fdbca719e3a861b3255e68f2c3ef8780.tar.bz2
Delay bookmarks load while the profile is loading.
This CL adds a new DeferredSequencedtaskRunner that queues up tasks until a first call to Start is issued. It creates such a task runner for the execution of bookmarks I/O operations. At profile creation, the bookmarks task runner is stopped and its execution is started after the profile has finished loading. BUG=NONE Review URL: https://chromiumcodereview.appspot.com/12952005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194956 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profiles/startup_task_runner_service.h')
-rw-r--r--chrome/browser/profiles/startup_task_runner_service.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/chrome/browser/profiles/startup_task_runner_service.h b/chrome/browser/profiles/startup_task_runner_service.h
new file mode 100644
index 0000000..f6298a3
--- /dev/null
+++ b/chrome/browser/profiles/startup_task_runner_service.h
@@ -0,0 +1,45 @@
+// 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 CHROME_BROWSER_PROFILES_STARTUP_TASK_RUNNER_SERVICE_H_
+#define CHROME_BROWSER_PROFILES_STARTUP_TASK_RUNNER_SERVICE_H_
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/threading/non_thread_safe.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
+
+class Profile;
+
+namespace base {
+class DeferredSequencedTaskRunner;
+} // namespace base
+
+// This service manages the startup task runners.
+class StartupTaskRunnerService : public base::NonThreadSafe,
+ public ProfileKeyedService {
+ public:
+ explicit StartupTaskRunnerService(Profile* profile);
+ virtual ~StartupTaskRunnerService();
+
+ // Returns sequenced task runner where all bookmarks I/O operations are
+ // performed.
+ // This method should only be called from the UI thread.
+ // Note: Using a separate task runner per profile service gives a better
+ // management of the sequence in which the task are started in order to avoid
+ // congestion during start-up (e.g the caller may decide to start loading the
+ // bookmarks only after the history finished).
+ scoped_refptr<base::DeferredSequencedTaskRunner> GetBookmarkTaskRunner();
+
+ // Starts the task runners that are deferred during start-up.
+ void StartDeferredTaskRunners();
+
+ private:
+ Profile* profile_;
+ scoped_refptr<base::DeferredSequencedTaskRunner> bookmark_task_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(StartupTaskRunnerService);
+};
+
+#endif // CHROME_BROWSER_PROFILES_STARTUP_TASK_RUNNER_SERVICE_H_