blob: aed0e88f5fdd92e218f9ea91c92e591f97b1f943 [file] [log] [blame]
// 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.
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/sequence_checker.h"
#include "components/keyed_service/core/keyed_service.h"
namespace base {
class DeferredSequencedTaskRunner;
class SequencedTaskRunner;
} // namespace base
namespace bookmarks {
// This service manages the startup task runners.
class StartupTaskRunnerService : public KeyedService {
explicit StartupTaskRunnerService(
const scoped_refptr<base::SequencedTaskRunner>& io_task_runner);
~StartupTaskRunnerService() override;
// 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();
scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
scoped_refptr<base::DeferredSequencedTaskRunner> bookmark_task_runner_;
} // namespace bookmarks