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

Side by Side Diff: content/renderer/render_process_impl.cc

Issue 2627953002: Initialize TaskScheduler in all child processes. (Closed)
Patch Set: fix test error Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « content/renderer/render_process_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_process_impl.h" 5 #include "content/renderer/render_process_impl.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // in GetDefaultSchedulerWorkerPoolParams(). 119 // in GetDefaultSchedulerWorkerPoolParams().
120 size_t DefaultRendererWorkerPoolIndexForTraits(const base::TaskTraits& traits) { 120 size_t DefaultRendererWorkerPoolIndexForTraits(const base::TaskTraits& traits) {
121 const bool is_background = 121 const bool is_background =
122 traits.priority() == base::TaskPriority::BACKGROUND; 122 traits.priority() == base::TaskPriority::BACKGROUND;
123 if (traits.with_file_io()) 123 if (traits.with_file_io())
124 return is_background ? BACKGROUND_FILE_IO : FOREGROUND_FILE_IO; 124 return is_background ? BACKGROUND_FILE_IO : FOREGROUND_FILE_IO;
125 125
126 return is_background ? BACKGROUND : FOREGROUND; 126 return is_background ? BACKGROUND : FOREGROUND;
127 } 127 }
128 128
129 void InitializeTaskScheduler() {
130 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
131 switches::kSingleProcess)) {
gab 2017/01/13 23:39:57 No longer care about single-process?
fdoray 2017/01/15 14:11:27 We do care. This check is now done in ChildProcess
132 // There should already be a TaskScheduler when the renderer runs inside the
133 // browser process.
134 DCHECK(base::TaskScheduler::GetInstance());
135 return;
136 }
137 DCHECK(!base::TaskScheduler::GetInstance());
138
139 std::vector<base::SchedulerWorkerPoolParams> params_vector;
140 base::TaskScheduler::WorkerPoolIndexForTraitsCallback
141 index_to_traits_callback;
142 content::GetContentClient()->renderer()->GetTaskSchedulerInitializationParams(
143 &params_vector, &index_to_traits_callback);
144
145 if (params_vector.empty()) {
146 params_vector = GetDefaultSchedulerWorkerPoolParams();
147 index_to_traits_callback =
148 base::Bind(&DefaultRendererWorkerPoolIndexForTraits);
149 }
150 DCHECK(index_to_traits_callback);
151
152 base::TaskScheduler::CreateAndSetDefaultTaskScheduler(
153 params_vector, index_to_traits_callback);
154 }
155
156 } // namespace 129 } // namespace
157 130
158 namespace content { 131 namespace content {
159 132
160 RenderProcessImpl::RenderProcessImpl() 133 RenderProcessImpl::RenderProcessImpl()
161 : enabled_bindings_(0) { 134 : enabled_bindings_(0) {
162 #if defined(OS_WIN) 135 #if defined(OS_WIN)
163 // Record whether the machine is domain joined in a crash key. This will be 136 // Record whether the machine is domain joined in a crash key. This will be
164 // used to better identify whether crashes are from enterprise users. 137 // used to better identify whether crashes are from enterprise users.
165 // Note that this is done very early on so that crashes have the highest 138 // Note that this is done very early on so that crashes have the highest
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 *base::CommandLine::ForCurrentProcess(); 179 *base::CommandLine::ForCurrentProcess();
207 180
208 if (command_line.HasSwitch(switches::kJavaScriptFlags)) { 181 if (command_line.HasSwitch(switches::kJavaScriptFlags)) {
209 std::string flags( 182 std::string flags(
210 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags)); 183 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags));
211 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); 184 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
212 } 185 }
213 186
214 SiteIsolationStatsGatherer::SetEnabled( 187 SiteIsolationStatsGatherer::SetEnabled(
215 GetContentClient()->renderer()->ShouldGatherSiteIsolationStats()); 188 GetContentClient()->renderer()->ShouldGatherSiteIsolationStats());
216
217 InitializeTaskScheduler();
218 } 189 }
219 190
220 RenderProcessImpl::~RenderProcessImpl() { 191 RenderProcessImpl::~RenderProcessImpl() {
221 #ifndef NDEBUG 192 #ifndef NDEBUG
222 int count = blink::WebFrame::instanceCount(); 193 int count = blink::WebFrame::instanceCount();
223 if (count) 194 if (count)
224 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES"; 195 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES";
225 #endif 196 #endif
226 197
227 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
228 switches::kSingleProcess)) {
229 DCHECK(base::TaskScheduler::GetInstance());
230 base::TaskScheduler::GetInstance()->Shutdown();
231 }
232
233 GetShutDownEvent()->Signal(); 198 GetShutDownEvent()->Signal();
234 } 199 }
235 200
236 void RenderProcessImpl::AddBindings(int bindings) { 201 void RenderProcessImpl::AddBindings(int bindings) {
237 enabled_bindings_ |= bindings; 202 enabled_bindings_ |= bindings;
238 } 203 }
239 204
240 int RenderProcessImpl::GetEnabledBindings() const { 205 int RenderProcessImpl::GetEnabledBindings() const {
241 return enabled_bindings_; 206 return enabled_bindings_;
242 } 207 }
243 208
209 void RenderProcessImpl::InitializeTaskScheduler() {
210 std::vector<base::SchedulerWorkerPoolParams> params_vector;
211 base::TaskScheduler::WorkerPoolIndexForTraitsCallback
212 index_to_traits_callback;
213 content::GetContentClient()->renderer()->GetTaskSchedulerInitializationParams(
214 &params_vector, &index_to_traits_callback);
215
216 if (params_vector.empty()) {
217 params_vector = GetDefaultSchedulerWorkerPoolParams();
218 index_to_traits_callback =
219 base::Bind(&DefaultRendererWorkerPoolIndexForTraits);
220 }
221 DCHECK(index_to_traits_callback);
222
223 base::TaskScheduler::CreateAndSetDefaultTaskScheduler(
224 params_vector, index_to_traits_callback);
225 }
226
244 } // namespace content 227 } // namespace content
OLDNEW
« 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