Index: content/gpu/gpu_main.cc |
diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc |
index be583047eba9bc3f51e3f6329094e067907564fc..470075e3bbb7c19f21ad632afad9c68e0e204064 100644 |
--- a/content/gpu/gpu_main.cc |
+++ b/content/gpu/gpu_main.cc |
@@ -44,6 +44,11 @@ |
#include "content/public/common/sandbox_init.h" |
#endif |
+namespace { |
+void WarmUpSandbox(content::GPUInfo*, bool); |
+void CollectGraphicsInfo(content::GPUInfo*); |
+} |
+ |
// Main function for starting the Gpu process. |
int GpuMain(const content::MainFunctionParams& parameters) { |
TRACE_EVENT0("gpu", "GpuMain"); |
@@ -99,6 +104,8 @@ int GpuMain(const content::MainFunctionParams& parameters) { |
command_line.GetSwitchValueASCII(switches::kGpuDriverVersion); |
content::GetContentClient()->SetGpuInfo(gpu_info); |
+ // We need to track that information for the sandbox PreWarm function. |
+ bool collect_graphics_info_called = false; |
// Load and initialize the GL implementation and locate the GL entry points. |
if (gfx::GLSurface::InitializeOneOff()) { |
#if defined(OS_LINUX) |
@@ -108,9 +115,8 @@ int GpuMain(const content::MainFunctionParams& parameters) { |
// However, on Linux, we may not have enough info for blacklisting. |
if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id || |
gpu_info.driver_vendor.empty() || gpu_info.driver_version.empty()) { |
- if (!gpu_info_collector::CollectGraphicsInfo(&gpu_info)) |
- VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; |
- content::GetContentClient()->SetGpuInfo(gpu_info); |
+ CollectGraphicsInfo(&gpu_info); |
+ collect_graphics_info_called = true; |
} |
#if !defined(OS_CHROMEOS) |
@@ -133,19 +139,10 @@ int GpuMain(const content::MainFunctionParams& parameters) { |
} |
{ |
- TRACE_EVENT0("gpu", "Warm up rand"); |
- // Warm up the random subsystem, which needs to be done pre-sandbox on all |
- // platforms. |
- (void) base::RandUint64(); |
- } |
- { |
- TRACE_EVENT0("gpu", "Warm up HMAC"); |
- // Warm up the crypto subsystem, which needs to done pre-sandbox on all |
- // platforms. |
- crypto::HMAC hmac(crypto::HMAC::SHA256); |
- unsigned char key = '\0'; |
- bool ret = hmac.Init(&key, sizeof(key)); |
- (void) ret; |
+ const bool should_collect_graphics_info = !collect_graphics_info_called && |
+ !dead_on_arrival; |
+ // Warm up the current process before enabling the sandbox. |
+ WarmUpSandbox(&gpu_info, should_collect_graphics_info); |
} |
#if defined(OS_LINUX) |
@@ -153,12 +150,6 @@ int GpuMain(const content::MainFunctionParams& parameters) { |
TRACE_EVENT0("gpu", "Initialize sandbox"); |
bool do_init_sandbox = true; |
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
- OmxVideoDecodeAccelerator::PreSandboxInitialization(); |
-#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
- VaapiVideoDecodeAccelerator::PreSandboxInitialization(); |
-#endif |
- |
#if defined(OS_CHROMEOS) && defined(NDEBUG) |
// On Chrome OS and when not on a debug build, initialize |
// the GPU process' sandbox only for Intel GPUs. |
@@ -171,25 +162,8 @@ int GpuMain(const content::MainFunctionParams& parameters) { |
} |
#endif |
- { |
- TRACE_EVENT0("gpu", "Initialize COM"); |
- base::win::ScopedCOMInitializer com_initializer; |
- } |
- |
#if defined(OS_WIN) |
{ |
- TRACE_EVENT0("gpu", "Preload setupapi.dll"); |
- // Preload this DLL because the sandbox prevents it from loading. |
- LoadLibrary(L"setupapi.dll"); |
- } |
- |
- { |
- TRACE_EVENT0("gpu", "Initialize DXVA"); |
- // Initialize H/W video decoding stuff which fails in the sandbox. |
- DXVAVideoDecodeAccelerator::PreSandboxInitialization(); |
- } |
- |
- { |
TRACE_EVENT0("gpu", "Lower token"); |
// For windows, if the target_services interface is not zero, the process |
// is sandboxed and we must call LowerToken() before rendering untrusted |
@@ -235,3 +209,68 @@ int GpuMain(const content::MainFunctionParams& parameters) { |
return 0; |
} |
+ |
+namespace { |
+ |
+void WarmUpSandbox(content::GPUInfo* gpu_info, |
+ bool should_collect_graphics_info) { |
+ { |
+ TRACE_EVENT0("gpu", "Warm up rand"); |
+ // Warm up the random subsystem, which needs to be done pre-sandbox on all |
+ // platforms. |
+ (void) base::RandUint64(); |
+ } |
+ { |
+ TRACE_EVENT0("gpu", "Warm up HMAC"); |
+ // Warm up the crypto subsystem, which needs to done pre-sandbox on all |
+ // platforms. |
+ crypto::HMAC hmac(crypto::HMAC::SHA256); |
+ unsigned char key = '\0'; |
+ bool ret = hmac.Init(&key, sizeof(key)); |
+ (void) ret; |
+ } |
+ |
+#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
+ OmxVideoDecodeAccelerator::PreSandboxInitialization(); |
+#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
+ VaapiVideoDecodeAccelerator::PreSandboxInitialization(); |
+#endif |
+ |
+#if defined(OS_LINUX) |
+ // On Linux, this is needed to make sure /dev/nvidiactl has |
+ // been opened and its descriptor cached. |
+ if (gpu_info->gpu.vendor_id == 0x10de && // NVIDIA |
+ gpu_info->driver_vendor == "NVIDIA" && |
+ should_collect_graphics_info) { |
+ CollectGraphicsInfo(gpu_info); |
Ken Russell (switch to Gerrit)
2012/08/16 00:45:54
I think you should be more explicit about this. In
jln (very slow on Chromium)
2012/08/16 00:52:53
I refactored the local "CollectGraphicsInfo" at th
|
+ } |
+#endif |
+ |
+ { |
+ TRACE_EVENT0("gpu", "Initialize COM"); |
+ base::win::ScopedCOMInitializer com_initializer; |
+ } |
+ |
+#if defined(OS_WIN) |
+ { |
+ TRACE_EVENT0("gpu", "Preload setupapi.dll"); |
+ // Preload this DLL because the sandbox prevents it from loading. |
+ LoadLibrary(L"setupapi.dll"); |
+ } |
+ |
+ { |
+ TRACE_EVENT0("gpu", "Initialize DXVA"); |
+ // Initialize H/W video decoding stuff which fails in the sandbox. |
+ DXVAVideoDecodeAccelerator::PreSandboxInitialization(); |
+ } |
+#endif |
+} |
+ |
+void CollectGraphicsInfo(content::GPUInfo* gpu_info) { |
+ if (!gpu_info_collector::CollectGraphicsInfo(gpu_info)) |
+ VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; |
+ content::GetContentClient()->SetGpuInfo(*gpu_info); |
+} |
+ |
+} // namespace. |
+ |