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

Unified Diff: chrome/browser/chrome_browser_main.cc

Issue 2241703002: Add an experiment to redirect SequencedWorkerPool tasks to TaskScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b3_delay_metrics_blocking
Patch Set: Created 4 years, 4 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: chrome/browser/chrome_browser_main.cc
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 262d91c8b06ff3eeefc1474964e5284c8d531fe5..10356a458ba6d2d499d2d24a903dc6cef46d061e 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -41,6 +41,7 @@
#include "base/task_scheduler/task_scheduler.h"
#include "base/task_scheduler/task_traits.h"
#include "base/threading/platform_thread.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "base/time/default_tick_clock.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
@@ -452,6 +453,14 @@ void MaybeInitializeTaskScheduler() {
base::TaskScheduler::CreateAndSetDefaultTaskScheduler(
params_vector, base::Bind(WorkerPoolIndexForTraits));
+
+ const auto sequenced_worker_pool_param =
brettw 2016/08/12 19:30:00 This should have a reference to a bug to remove it
gab 2016/08/12 23:27:46 Done.
+ variation_params.find("RedirectSequencedWorkerPools");
+ if (sequenced_worker_pool_param != variation_params.end() &&
+ sequenced_worker_pool_param->second == "true") {
+ base::SequencedWorkerPool::
+ RedirectSequencedWorkerPoolsToTaskSchedulerForProcess();
+ }
}
// Returns the new local state object, guaranteed non-NULL.
@@ -1347,14 +1356,21 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() {
// IOThread's initialization which happens in BrowserProcess:PreCreateThreads.
SetupMetricsAndFieldTrials();
- MaybeInitializeTaskScheduler();
-
// ChromeOS needs ResourceBundle::InitSharedInstance to be called before this.
browser_process_->PreCreateThreads();
device::GeolocationProvider::SetGeolocationDelegate(
new ChromeGeolocationDelegate());
+ // This needs to be the last thing in PreCreateThreads() because the
+ // TaskScheduler needs to be created before any other threads are (by
+ // contract) but it creates threads itself so instantiating it earlier is also
+ // incorrect. It also has to be after SetupMetricsAndFieldTrials() to allow it
+ // to use field trials. Note: it could also be the first thing in
+ // CreateThreads() but being in chrome/ is convenient for now as the
+ // initialization uses variations parameters extensively.
+ MaybeInitializeTaskScheduler();
+
return content::RESULT_CODE_NORMAL_EXIT;
}
« base/threading/sequenced_worker_pool.cc ('K') | « base/threading/sequenced_worker_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698