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

Unified Diff: content/public/renderer/content_renderer_client.cc

Issue 2491823005: Initialize TaskScheduler in renderers. (Closed)
Patch Set: add dcheck 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: content/public/renderer/content_renderer_client.cc
diff --git a/content/public/renderer/content_renderer_client.cc b/content/public/renderer/content_renderer_client.cc
index 642521f5819662f50c28f83e12418c2ca6632a26..b276888086864ca5309db4720d1542013059af59 100644
--- a/content/public/renderer/content_renderer_client.cc
+++ b/content/public/renderer/content_renderer_client.cc
@@ -4,6 +4,12 @@
#include "content/public/renderer/content_renderer_client.h"
+#include "base/bind.h"
+#include "base/task_scheduler/initialization_util.h"
+#include "base/task_scheduler/scheduler_worker_pool_params.h"
+#include "base/task_scheduler/task_traits.h"
+#include "base/threading/platform_thread.h"
+#include "base/time/time.h"
#include "cc/blimp/remote_compositor_bridge.h"
#include "content/public/renderer/media_stream_renderer_factory.h"
#include "media/base/renderer_factory.h"
@@ -12,6 +18,24 @@
namespace content {
+namespace {
+
+enum WorkerPoolType : size_t {
+ BACKGROUND_WORKER_POOL = 0,
+ FOREGROUND_WORKER_POOL,
gab 2016/11/18 18:31:59 Not used anywhere but in GetTaskSchedulerWorkerPoo
+ WORKER_POOL_COUNT // Always last.
+};
+
+size_t GetTaskSchedulerWorkerPoolIndexForTraits(
+ const base::TaskTraits& traits) {
+ DCHECK(!traits.with_file_io());
+ return traits.priority() == base::TaskPriority::BACKGROUND
+ ? BACKGROUND_WORKER_POOL
+ : FOREGROUND_WORKER_POOL;
+}
gab 2016/11/18 18:31:59 I'd prefer for this to be inlined in method's scop
+
+} // namespace
+
SkBitmap* ContentRendererClient::GetSadPluginBitmap() {
return nullptr;
}
@@ -44,6 +68,43 @@ bool ContentRendererClient::ShouldSuppressErrorPage(RenderFrame* render_frame,
return false;
}
+void ContentRendererClient::GetTaskSchedulerInitializationArguments(
+ std::vector<base::SchedulerWorkerPoolParams>* worker_pool_params_vector,
+ base::Callback<size_t(const base::TaskTraits& traits)>*
+ worker_pool_index_for_traits_callback,
+ bool* redirect_sequenced_worker_pool) {
+ constexpr int kBackgroundThreadsMin = 3;
+ constexpr int kBackgroundThreadsMax = 8;
+ constexpr double kBackgroundThreadsCoresMultiplier = 0.1;
+ constexpr int kBackgroundThreadsOffset = 0;
+ worker_pool_params_vector->emplace_back(
+ "RendererBackground", base::ThreadPriority::NORMAL,
+ base::SchedulerWorkerPoolParams::IORestriction::DISALLOWED,
+ base::SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY,
+ base::RecommendedMaxNumberOfThreadsInPool(
+ kBackgroundThreadsMin, kBackgroundThreadsMax,
+ kBackgroundThreadsCoresMultiplier, kBackgroundThreadsOffset),
+ base::TimeDelta::FromSeconds(30));
+
+ constexpr int kForegroundThreadsMin = 8;
+ constexpr int kForegroundThreadsMax = 32;
+ constexpr double kForegroundThreadsCoresMultiplier = 0.3;
+ constexpr int kForegroundThreadsOffset = 0;
gab 2016/11/18 18:31:59 These constants are probably too high for the rend
+ worker_pool_params_vector->emplace_back(
+ "RendererForeground", base::ThreadPriority::NORMAL,
+ base::SchedulerWorkerPoolParams::IORestriction::DISALLOWED,
+ base::SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY,
+ base::RecommendedMaxNumberOfThreadsInPool(
+ kForegroundThreadsMin, kForegroundThreadsMax,
+ kForegroundThreadsCoresMultiplier, kForegroundThreadsOffset),
+ base::TimeDelta::FromSeconds(30));
+
+ *worker_pool_index_for_traits_callback =
+ base::Bind(&GetTaskSchedulerWorkerPoolIndexForTraits);
+
+ *redirect_sequenced_worker_pool = false;
+}
+
void ContentRendererClient::DeferMediaLoad(
RenderFrame* render_frame,
bool has_played_media_before,

Powered by Google App Engine
This is Rietveld 408576698