| 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <dwmapi.h> | 8 #include <dwmapi.h> |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #endif | 10 #endif |
| 11 | 11 |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/metrics/statistics_recorder.h" |
| 15 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
| 16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 18 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 19 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 19 #include "base/threading/platform_thread.h" | 20 #include "base/threading/platform_thread.h" |
| 20 #include "base/trace_event/trace_event.h" | 21 #include "base/trace_event/trace_event.h" |
| 21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 22 #include "content/child/child_process.h" | 23 #include "content/child/child_process.h" |
| 23 #include "content/common/content_constants_internal.h" | 24 #include "content/common/content_constants_internal.h" |
| 24 #include "content/common/gpu/gpu_config.h" | 25 #include "content/common/gpu/gpu_config.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 208 |
| 208 // Start the GPU watchdog only after anything that is expected to be time | 209 // Start the GPU watchdog only after anything that is expected to be time |
| 209 // consuming has completed, otherwise the process is liable to be aborted. | 210 // consuming has completed, otherwise the process is liable to be aborted. |
| 210 if (enable_watchdog && !delayed_watchdog_enable) { | 211 if (enable_watchdog && !delayed_watchdog_enable) { |
| 211 watchdog_thread = new GpuWatchdogThread(kGpuTimeout); | 212 watchdog_thread = new GpuWatchdogThread(kGpuTimeout); |
| 212 base::Thread::Options options; | 213 base::Thread::Options options; |
| 213 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | 214 options.timer_slack = base::TIMER_SLACK_MAXIMUM; |
| 214 watchdog_thread->StartWithOptions(options); | 215 watchdog_thread->StartWithOptions(options); |
| 215 } | 216 } |
| 216 | 217 |
| 218 // Initializes StatisticsRecorder which tracks UMA histograms. |
| 219 base::StatisticsRecorder::Initialize(); |
| 220 |
| 217 gpu::GPUInfo gpu_info; | 221 gpu::GPUInfo gpu_info; |
| 218 // Get vendor_id, device_id, driver_version from browser process through | 222 // Get vendor_id, device_id, driver_version from browser process through |
| 219 // commandline switches. | 223 // commandline switches. |
| 220 GetGpuInfoFromCommandLine(gpu_info, command_line); | 224 GetGpuInfoFromCommandLine(gpu_info, command_line); |
| 221 | 225 |
| 222 base::TimeDelta collect_context_time; | |
| 223 base::TimeDelta initialize_one_off_time; | |
| 224 | |
| 225 // Warm up resources that don't need access to GPUInfo. | 226 // Warm up resources that don't need access to GPUInfo. |
| 226 if (WarmUpSandbox(command_line)) { | 227 if (WarmUpSandbox(command_line)) { |
| 227 #if defined(OS_LINUX) | 228 #if defined(OS_LINUX) |
| 228 bool initialized_sandbox = false; | 229 bool initialized_sandbox = false; |
| 229 bool initialized_gl_context = false; | 230 bool initialized_gl_context = false; |
| 230 bool should_initialize_gl_context = false; | 231 bool should_initialize_gl_context = false; |
| 231 // On Chrome OS ARM Mali, GPU driver userspace creates threads when | 232 // On Chrome OS ARM Mali, GPU driver userspace creates threads when |
| 232 // initializing a GL context, so start the sandbox early. | 233 // initializing a GL context, so start the sandbox early. |
| 233 if (command_line.HasSwitch(switches::kGpuSandboxStartEarly)) { | 234 if (command_line.HasSwitch(switches::kGpuSandboxStartEarly)) { |
| 234 gpu_info.sandboxed = StartSandboxLinux( | 235 gpu_info.sandboxed = StartSandboxLinux( |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 #if defined(OS_LINUX) | 287 #if defined(OS_LINUX) |
| 287 initialized_gl_context = true; | 288 initialized_gl_context = true; |
| 288 #if !defined(OS_CHROMEOS) | 289 #if !defined(OS_CHROMEOS) |
| 289 if (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA | 290 if (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA |
| 290 gpu_info.driver_vendor == "NVIDIA" && | 291 gpu_info.driver_vendor == "NVIDIA" && |
| 291 !CanAccessNvidiaDeviceFile()) | 292 !CanAccessNvidiaDeviceFile()) |
| 292 dead_on_arrival = true; | 293 dead_on_arrival = true; |
| 293 #endif // !defined(OS_CHROMEOS) | 294 #endif // !defined(OS_CHROMEOS) |
| 294 #endif // defined(OS_LINUX) | 295 #endif // defined(OS_LINUX) |
| 295 #endif // !defined(OS_MACOSX) | 296 #endif // !defined(OS_MACOSX) |
| 296 collect_context_time = | 297 base::TimeDelta collect_context_time = |
| 297 base::TimeTicks::Now() - before_collect_context_graphics_info; | 298 base::TimeTicks::Now() - before_collect_context_graphics_info; |
| 299 UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo", |
| 300 collect_context_time); |
| 298 } else { // gl_initialized | 301 } else { // gl_initialized |
| 299 VLOG(1) << "gfx::GLSurface::InitializeOneOff failed"; | 302 VLOG(1) << "gfx::GLSurface::InitializeOneOff failed"; |
| 300 dead_on_arrival = true; | 303 dead_on_arrival = true; |
| 301 } | 304 } |
| 302 | 305 |
| 303 initialize_one_off_time = | 306 base::TimeDelta initialize_one_off_time = |
| 304 base::TimeTicks::Now() - before_initialize_one_off; | 307 base::TimeTicks::Now() - before_initialize_one_off; |
| 308 UMA_HISTOGRAM_TIMES("GPU.InitializeOneOffTime", initialize_one_off_time); |
| 305 | 309 |
| 306 if (enable_watchdog && delayed_watchdog_enable) { | 310 if (enable_watchdog && delayed_watchdog_enable) { |
| 307 watchdog_thread = new GpuWatchdogThread(kGpuTimeout); | 311 watchdog_thread = new GpuWatchdogThread(kGpuTimeout); |
| 308 base::Thread::Options options; | 312 base::Thread::Options options; |
| 309 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | 313 options.timer_slack = base::TIMER_SLACK_MAXIMUM; |
| 310 watchdog_thread->StartWithOptions(options); | 314 watchdog_thread->StartWithOptions(options); |
| 311 } | 315 } |
| 312 | 316 |
| 313 // OSMesa is expected to run very slowly, so disable the watchdog in that | 317 // OSMesa is expected to run very slowly, so disable the watchdog in that |
| 314 // case. | 318 // case. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 335 gpu_info.video_encode_accelerator_supported_profiles = | 339 gpu_info.video_encode_accelerator_supported_profiles = |
| 336 content::GpuVideoEncodeAccelerator::GetSupportedProfiles(); | 340 content::GpuVideoEncodeAccelerator::GetSupportedProfiles(); |
| 337 } else { | 341 } else { |
| 338 dead_on_arrival = true; | 342 dead_on_arrival = true; |
| 339 } | 343 } |
| 340 | 344 |
| 341 logging::SetLogMessageHandler(NULL); | 345 logging::SetLogMessageHandler(NULL); |
| 342 | 346 |
| 343 GpuProcess gpu_process; | 347 GpuProcess gpu_process; |
| 344 | 348 |
| 345 // These UMA must be stored after GpuProcess is constructed as it | |
| 346 // initializes StatisticsRecorder which tracks the histograms. | |
| 347 UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo", collect_context_time); | |
| 348 UMA_HISTOGRAM_TIMES("GPU.InitializeOneOffTime", initialize_one_off_time); | |
| 349 | |
| 350 GpuChildThread* child_thread = new GpuChildThread(watchdog_thread.get(), | 349 GpuChildThread* child_thread = new GpuChildThread(watchdog_thread.get(), |
| 351 dead_on_arrival, | 350 dead_on_arrival, |
| 352 gpu_info, | 351 gpu_info, |
| 353 deferred_messages.Get()); | 352 deferred_messages.Get()); |
| 354 while (!deferred_messages.Get().empty()) | 353 while (!deferred_messages.Get().empty()) |
| 355 deferred_messages.Get().pop(); | 354 deferred_messages.Get().pop(); |
| 356 | 355 |
| 357 child_thread->Init(start_time); | 356 child_thread->Init(start_time); |
| 358 | 357 |
| 359 gpu_process.set_main_thread(child_thread); | 358 gpu_process.set_main_thread(child_thread); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 return true; | 533 return true; |
| 535 } | 534 } |
| 536 | 535 |
| 537 return false; | 536 return false; |
| 538 } | 537 } |
| 539 #endif // defined(OS_WIN) | 538 #endif // defined(OS_WIN) |
| 540 | 539 |
| 541 } // namespace. | 540 } // namespace. |
| 542 | 541 |
| 543 } // namespace content | 542 } // namespace content |
| OLD | NEW |