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

Unified Diff: components/task_scheduler_util/renderer/initialization.cc

Issue 2749303002: [reference - do not submit] Always create four pools in TaskSchedulerImpl. (Closed)
Patch Set: rebase Created 3 years, 9 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
« no previous file with comments | « components/task_scheduler_util/renderer/initialization.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/task_scheduler_util/renderer/initialization.cc
diff --git a/components/task_scheduler_util/renderer/initialization.cc b/components/task_scheduler_util/renderer/initialization.cc
index 0bef44603c623aabd0da6423fe738b48adf8ac2b..b3dbefb00727d1e2b17a345ac4322dbddf9b224c 100644
--- a/components/task_scheduler_util/renderer/initialization.cc
+++ b/components/task_scheduler_util/renderer/initialization.cc
@@ -4,55 +4,29 @@
#include "components/task_scheduler_util/renderer/initialization.h"
-#include <map>
-#include <string>
-
#include "base/command_line.h"
-#include "base/logging.h"
-#include "base/task_scheduler/task_traits.h"
-#include "base/threading/platform_thread.h"
+#include "base/memory/ptr_util.h"
#include "components/task_scheduler_util/common/variations_util.h"
namespace task_scheduler_util {
-namespace {
-
-enum WorkerPoolType : size_t {
- BACKGROUND = 0,
- BACKGROUND_BLOCKING,
- FOREGROUND,
- FOREGROUND_BLOCKING,
- WORKER_POOL_COUNT // Always last.
-};
-
-} // namespace
-
-std::vector<base::SchedulerWorkerPoolParams> GetRendererWorkerPoolParams() {
- using ThreadPriority = base::ThreadPriority;
- std::vector<SchedulerImmutableWorkerPoolParams> immutable_worker_pool_params;
- DCHECK_EQ(BACKGROUND, immutable_worker_pool_params.size());
- immutable_worker_pool_params.emplace_back("RendererBackground",
- ThreadPriority::BACKGROUND);
- DCHECK_EQ(BACKGROUND_BLOCKING, immutable_worker_pool_params.size());
- immutable_worker_pool_params.emplace_back("RendererBackgroundBlocking",
- ThreadPriority::BACKGROUND);
- DCHECK_EQ(FOREGROUND, immutable_worker_pool_params.size());
- immutable_worker_pool_params.emplace_back("RendererForeground",
- ThreadPriority::NORMAL);
- DCHECK_EQ(FOREGROUND_BLOCKING, immutable_worker_pool_params.size());
- immutable_worker_pool_params.emplace_back("RendererForegroundBlocking",
- ThreadPriority::NORMAL);
- return GetWorkerPoolParams(immutable_worker_pool_params,
- GetVariationParamsFromCommandLine(
- *base::CommandLine::ForCurrentProcess()));
-}
+std::unique_ptr<base::TaskSchedulerInitParams>
+GetRendererTaskSchedulerInitParamsFromCommandLine() {
+ auto variation_params = GetVariationParamsFromCommandLine(
+ *base::CommandLine::ForCurrentProcess());
+
+ auto init_params = base::MakeUnique<base::TaskSchedulerInitParams>(
+ StringToVariableWorkerPoolParams(variation_params["RendererBackground"]),
+ StringToVariableWorkerPoolParams(
+ variation_params["RendererBackgroundBlocking"]),
+ StringToVariableWorkerPoolParams(variation_params["RendererForeground"]),
+ StringToVariableWorkerPoolParams(
+ variation_params["RendererForegroundBlocking"]));
+
+ if (init_params->IsValid())
+ return init_params;
-size_t RendererWorkerPoolIndexForTraits(const base::TaskTraits& traits) {
- const bool is_background =
- traits.priority() == base::TaskPriority::BACKGROUND;
- if (traits.may_block() || traits.with_base_sync_primitives())
- return is_background ? BACKGROUND_BLOCKING : FOREGROUND_BLOCKING;
- return is_background ? BACKGROUND : FOREGROUND;
+ return nullptr;
}
} // namespace task_scheduler_util
« no previous file with comments | « components/task_scheduler_util/renderer/initialization.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698