Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> |
| 11 #include <objidl.h> | 11 #include <objidl.h> |
| 12 #include <mlang.h> | 12 #include <mlang.h> |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #include <stddef.h> | 15 #include <stddef.h> |
| 16 | 16 |
| 17 #include <algorithm> | 17 #include <algorithm> |
| 18 #include <vector> | 18 #include <vector> |
| 19 | 19 |
| 20 #include "base/bind.h" | 20 #include "base/bind.h" |
| 21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 22 #include "base/compiler_specific.h" | 22 #include "base/compiler_specific.h" |
| 23 #include "base/debug/crash_logging.h" | 23 #include "base/debug/crash_logging.h" |
| 24 #include "base/feature_list.h" | 24 #include "base/feature_list.h" |
| 25 #include "base/memory/ptr_util.h" | |
| 25 #include "base/sys_info.h" | 26 #include "base/sys_info.h" |
| 26 #include "base/task_scheduler/initialization_util.h" | 27 #include "base/task_scheduler/initialization_util.h" |
| 27 #include "base/task_scheduler/scheduler_worker_pool_params.h" | |
| 28 #include "base/task_scheduler/task_scheduler.h" | |
| 29 #include "base/task_scheduler/task_traits.h" | 28 #include "base/task_scheduler/task_traits.h" |
| 30 #include "base/threading/platform_thread.h" | 29 #include "base/threading/platform_thread.h" |
| 31 #include "base/time/time.h" | 30 #include "base/time/time.h" |
| 32 #include "content/child/site_isolation_stats_gatherer.h" | 31 #include "content/child/site_isolation_stats_gatherer.h" |
| 33 #include "content/public/common/bindings_policy.h" | 32 #include "content/public/common/bindings_policy.h" |
| 34 #include "content/public/common/content_client.h" | 33 #include "content/public/common/content_client.h" |
| 35 #include "content/public/common/content_features.h" | 34 #include "content/public/common/content_features.h" |
| 36 #include "content/public/common/content_switches.h" | 35 #include "content/public/common/content_switches.h" |
| 37 #include "content/public/renderer/content_renderer_client.h" | 36 #include "content/public/renderer/content_renderer_client.h" |
| 38 #include "third_party/WebKit/public/web/WebFrame.h" | 37 #include "third_party/WebKit/public/web/WebFrame.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 if (traits.may_block() || traits.with_base_sync_primitives()) | 124 if (traits.may_block() || traits.with_base_sync_primitives()) |
| 126 return is_background ? BACKGROUND_FILE_IO : FOREGROUND_FILE_IO; | 125 return is_background ? BACKGROUND_FILE_IO : FOREGROUND_FILE_IO; |
| 127 | 126 |
| 128 return is_background ? BACKGROUND : FOREGROUND; | 127 return is_background ? BACKGROUND : FOREGROUND; |
| 129 } | 128 } |
| 130 | 129 |
| 131 } // namespace | 130 } // namespace |
| 132 | 131 |
| 133 namespace content { | 132 namespace content { |
| 134 | 133 |
| 135 RenderProcessImpl::RenderProcessImpl() | 134 RenderProcessImpl::RenderProcessImpl( |
| 136 : enabled_bindings_(0) { | 135 const std::vector<base::SchedulerWorkerPoolParams>& worker_pool_params, |
| 136 base::TaskScheduler::WorkerPoolIndexForTraitsCallback | |
| 137 worker_pool_index_for_traits_callback) | |
| 138 : RenderProcess(worker_pool_params, worker_pool_index_for_traits_callback), | |
|
gab
2017/02/09 17:43:45
std::move callback
fdoray
2017/02/10 18:47:11
Done.
| |
| 139 enabled_bindings_(0) { | |
| 137 #if defined(OS_WIN) | 140 #if defined(OS_WIN) |
| 138 // Record whether the machine is domain joined in a crash key. This will be | 141 // Record whether the machine is domain joined in a crash key. This will be |
| 139 // used to better identify whether crashes are from enterprise users. | 142 // used to better identify whether crashes are from enterprise users. |
| 140 // Note that this is done very early on so that crashes have the highest | 143 // Note that this is done very early on so that crashes have the highest |
| 141 // chance of getting tagged. | 144 // chance of getting tagged. |
| 142 base::debug::SetCrashKeyValue("enrolled-to-domain", | 145 base::debug::SetCrashKeyValue("enrolled-to-domain", |
| 143 base::win::IsEnrolledToDomain() ? "yes" : "no"); | 146 base::win::IsEnrolledToDomain() ? "yes" : "no"); |
| 144 | 147 |
| 145 // HACK: See http://b/issue?id=1024307 for rationale. | 148 // HACK: See http://b/issue?id=1024307 for rationale. |
| 146 if (GetModuleHandle(L"LPK.DLL") == NULL) { | 149 if (GetModuleHandle(L"LPK.DLL") == NULL) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 RenderProcessImpl::~RenderProcessImpl() { | 202 RenderProcessImpl::~RenderProcessImpl() { |
| 200 #ifndef NDEBUG | 203 #ifndef NDEBUG |
| 201 int count = blink::WebFrame::instanceCount(); | 204 int count = blink::WebFrame::instanceCount(); |
| 202 if (count) | 205 if (count) |
| 203 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES"; | 206 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES"; |
| 204 #endif | 207 #endif |
| 205 | 208 |
| 206 GetShutDownEvent()->Signal(); | 209 GetShutDownEvent()->Signal(); |
| 207 } | 210 } |
| 208 | 211 |
| 212 std::unique_ptr<RenderProcess> RenderProcessImpl::Create() { | |
| 213 std::vector<base::SchedulerWorkerPoolParams> worker_pool_params_vector; | |
| 214 base::TaskScheduler::WorkerPoolIndexForTraitsCallback | |
| 215 worker_pool_index_for_traits_callback; | |
| 216 content::GetContentClient()->renderer()->GetTaskSchedulerInitializationParams( | |
| 217 &worker_pool_params_vector, &worker_pool_index_for_traits_callback); | |
| 218 | |
| 219 if (worker_pool_params_vector.empty()) { | |
| 220 worker_pool_params_vector = GetDefaultSchedulerWorkerPoolParams(); | |
| 221 worker_pool_index_for_traits_callback = | |
| 222 base::Bind(&DefaultRendererWorkerPoolIndexForTraits); | |
| 223 } | |
| 224 | |
| 225 DCHECK(!worker_pool_params_vector.empty()); | |
| 226 DCHECK(worker_pool_index_for_traits_callback); | |
| 227 | |
| 228 return base::WrapUnique( | |
| 229 new RenderProcessImpl(worker_pool_params_vector, | |
| 230 std::move(worker_pool_index_for_traits_callback))); | |
| 231 } | |
| 232 | |
| 209 void RenderProcessImpl::AddBindings(int bindings) { | 233 void RenderProcessImpl::AddBindings(int bindings) { |
| 210 enabled_bindings_ |= bindings; | 234 enabled_bindings_ |= bindings; |
| 211 } | 235 } |
| 212 | 236 |
| 213 int RenderProcessImpl::GetEnabledBindings() const { | 237 int RenderProcessImpl::GetEnabledBindings() const { |
| 214 return enabled_bindings_; | 238 return enabled_bindings_; |
| 215 } | 239 } |
| 216 | 240 |
| 217 void RenderProcessImpl::InitializeTaskScheduler() { | |
| 218 std::vector<base::SchedulerWorkerPoolParams> params_vector; | |
| 219 base::TaskScheduler::WorkerPoolIndexForTraitsCallback | |
| 220 index_to_traits_callback; | |
| 221 content::GetContentClient()->renderer()->GetTaskSchedulerInitializationParams( | |
| 222 ¶ms_vector, &index_to_traits_callback); | |
| 223 | |
| 224 if (params_vector.empty()) { | |
| 225 params_vector = GetDefaultSchedulerWorkerPoolParams(); | |
| 226 index_to_traits_callback = | |
| 227 base::Bind(&DefaultRendererWorkerPoolIndexForTraits); | |
| 228 } | |
| 229 DCHECK(index_to_traits_callback); | |
| 230 | |
| 231 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( | |
| 232 params_vector, index_to_traits_callback); | |
| 233 } | |
| 234 | |
| 235 } // namespace content | 241 } // namespace content |
| OLD | NEW |