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

Unified Diff: components/history/core/browser/history_service.h

Issue 2486603003: Redirect HistoryService thread to TaskScheduler via a field trial. (Closed)
Patch Set: self-review Created 4 years, 1 month 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: components/history/core/browser/history_service.h
diff --git a/components/history/core/browser/history_service.h b/components/history/core/browser/history_service.h
index 430037133854ba0d0e65a1ab87763162f4f13eaa..d7c9bc49556bf47677b464af5b3ea7c1eeaf3f49 100644
--- a/components/history/core/browser/history_service.h
+++ b/components/history/core/browser/history_service.h
@@ -22,6 +22,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
+#include "base/sequenced_task_runner.h"
#include "base/strings/string16.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/threading/thread_checker.h"
@@ -93,6 +94,14 @@ class HistoryService : public syncer::SyncableService, public KeyedService {
std::unique_ptr<VisitDelegate> visit_delegate);
~HistoryService() override;
+ // When this is called, all HistoryService instances in this process will run
+ // their HistoryBackend tasks on a TaskScheduler sequence rather than on a
+ // dedicated thread. This must be called before instantiating the first
+ // HistoryService in the process.
+ // TODO(fdoray): Remove once the HistoryService redirection experiment
+ // concludes. https://crbug.com/661143
+ static void RedirectToTaskSchedulerForProcess();
+
// Initializes the history service, returning true on success. On false, do
// not call any other functions. The given directory will be used for storing
// the history files.
@@ -795,9 +804,15 @@ class HistoryService : public syncer::SyncableService, public KeyedService {
base::ThreadChecker thread_checker_;
- // The thread used by the history service to run complicated operations.
- // |thread_| is null once Cleanup() is called.
- base::Thread* thread_;
+ // The thread used by the history service to run HistoryBackend operations.
+ // Intentionally not a BrowserThread because the sync integration unit tests
+ // need to create multiple HistoryServices which each have their own thread.
+ // Nullptr if TaskScheduler is used for backend operations.
+ std::unique_ptr<base::Thread> thread_;
+
+ // The TaskRunner to which HistoryBackend tasks are posted. Nullptr once
+ // Cleanup() is called.
+ scoped_refptr<base::SequencedTaskRunner> backend_task_runner_;
// This class has most of the implementation and runs on the 'thread_'.
// You MUST communicate with this class ONLY through the thread_'s

Powered by Google App Engine
This is Rietveld 408576698