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

Unified Diff: content/renderer/render_process_impl.cc

Issue 2491823005: Initialize TaskScheduler in renderers. (Closed)
Patch Set: do not enable in this CL 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
« no previous file with comments | « content/renderer/render_process_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_process_impl.cc
diff --git a/content/renderer/render_process_impl.cc b/content/renderer/render_process_impl.cc
index 0ad4d1b0066be8c76af12461a3d9c798bd51371a..1b7a64eac4ffe5895688f296eb4a606a134667be 100644
--- a/content/renderer/render_process_impl.cc
+++ b/content/renderer/render_process_impl.cc
@@ -12,10 +12,17 @@
#include <mlang.h>
#endif
+#include <stddef.h>
+
+#include <vector>
+
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/feature_list.h"
#include "base/sys_info.h"
+#include "base/task_scheduler/scheduler_worker_pool_params.h"
+#include "base/task_scheduler/task_scheduler.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "content/child/site_isolation_stats_gatherer.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
@@ -23,6 +30,10 @@
#include "third_party/WebKit/public/web/WebFrame.h"
#include "v8/include/v8.h"
+namespace base {
+class TaskTraits;
+}
+
namespace {
const base::Feature kV8_ES2015_TailCalls_Feature {
@@ -50,12 +61,39 @@ void SetV8FlagIfHasSwitch(const char* switch_name, const char* v8_flag) {
}
}
+bool MaybeInitializeTaskScheduler() {
robliao 2016/11/14 16:05:26 What's the behavior when base linked to chrome.dll
gab 2016/11/14 16:16:43 Hmm? base is linked to both but any process instan
fdoray 2016/11/15 16:30:34 --single-process only works in component builds ht
+ // TaskScheduler already exists when the renderer runs inside the browser
+ // process.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
gab 2016/11/14 16:16:43 Use base::TaskScheduler::GetInstance() instead? (p
fdoray 2016/11/15 16:30:34 Done. With some changes because I don't want a Ren
+ switches::kSingleProcess)) {
+ return false;
+ }
+
+ std::vector<base::SchedulerWorkerPoolParams> worker_pool_params_vector;
+ base::Callback<size_t(const base::TaskTraits& traits)>
+ worker_pool_index_for_traits_callback;
+ bool should_redirect_sequenced_worker_pool = false;
+
+ if (!content::GetContentClient()->renderer()->ShouldInitializeTaskScheduler(
+ &worker_pool_params_vector, &worker_pool_index_for_traits_callback,
+ &should_redirect_sequenced_worker_pool)) {
+ return false;
+ }
+
+ base::TaskScheduler::CreateAndSetDefaultTaskScheduler(
+ worker_pool_params_vector, worker_pool_index_for_traits_callback);
+
+ if (should_redirect_sequenced_worker_pool)
+ base::SequencedWorkerPool::RedirectToTaskSchedulerForProcess();
+
+ return true;
+}
+
} // namespace
namespace content {
-RenderProcessImpl::RenderProcessImpl()
- : enabled_bindings_(0) {
+RenderProcessImpl::RenderProcessImpl() {
#if defined(OS_WIN)
// HACK: See http://b/issue?id=1024307 for rationale.
if (GetModuleHandle(L"LPK.DLL") == NULL) {
@@ -103,6 +141,8 @@ RenderProcessImpl::RenderProcessImpl()
SiteIsolationStatsGatherer::SetEnabled(
GetContentClient()->renderer()->ShouldGatherSiteIsolationStats());
+
+ initialized_task_scheduler_ = MaybeInitializeTaskScheduler();
}
RenderProcessImpl::~RenderProcessImpl() {
@@ -112,6 +152,11 @@ RenderProcessImpl::~RenderProcessImpl() {
DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES";
#endif
+ if (initialized_task_scheduler_) {
+ DCHECK(base::TaskScheduler::GetInstance());
+ base::TaskScheduler::GetInstance()->Shutdown();
+ }
+
GetShutDownEvent()->Signal();
}
« no previous file with comments | « content/renderer/render_process_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698