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 <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "base/environment.h" | 11 #include "base/environment.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/rand_util.h" | |
13 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
14 #include "base/threading/platform_thread.h" | 15 #include "base/threading/platform_thread.h" |
15 #include "base/win/scoped_com_initializer.h" | 16 #include "base/win/scoped_com_initializer.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "content/common/gpu/gpu_config.h" | 18 #include "content/common/gpu/gpu_config.h" |
18 #include "content/public/common/content_client.h" | 19 #include "content/public/common/content_client.h" |
19 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
20 #include "content/public/common/main_function_params.h" | 21 #include "content/public/common/main_function_params.h" |
21 #include "content/gpu/gpu_child_thread.h" | 22 #include "content/gpu/gpu_child_thread.h" |
22 #include "content/gpu/gpu_info_collector.h" | 23 #include "content/gpu/gpu_info_collector.h" |
23 #include "content/gpu/gpu_process.h" | 24 #include "content/gpu/gpu_process.h" |
24 #include "ui/gfx/gl/gl_surface.h" | 25 #include "ui/gfx/gl/gl_surface.h" |
25 #include "ui/gfx/gl/gl_switches.h" | 26 #include "ui/gfx/gl/gl_switches.h" |
26 | 27 |
27 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
28 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 29 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
29 #include "sandbox/src/sandbox.h" | 30 #include "sandbox/src/sandbox.h" |
30 #endif | 31 #endif |
31 | 32 |
32 #if defined(USE_X11) | 33 #if defined(USE_X11) |
33 #include "ui/base/x/x11_util.h" | 34 #include "ui/base/x/x11_util.h" |
34 #endif | 35 #endif |
35 | 36 |
36 #if defined(TOOLKIT_GTK) | 37 #if defined(TOOLKIT_GTK) |
37 #include "ui/gfx/gtk_util.h" | 38 #include "ui/gfx/gtk_util.h" |
38 #endif | 39 #endif |
39 | 40 |
41 #if defined(OS_LINUX) | |
42 #include "content/public/common/sandbox_init.h" | |
43 #endif | |
44 | |
40 // Main function for starting the Gpu process. | 45 // Main function for starting the Gpu process. |
41 int GpuMain(const content::MainFunctionParams& parameters) { | 46 int GpuMain(const content::MainFunctionParams& parameters) { |
42 base::Time start_time = base::Time::Now(); | 47 base::Time start_time = base::Time::Now(); |
43 | 48 |
44 const CommandLine& command_line = parameters.command_line; | 49 const CommandLine& command_line = parameters.command_line; |
45 if (command_line.HasSwitch(switches::kGpuStartupDialog)) { | 50 if (command_line.HasSwitch(switches::kGpuStartupDialog)) { |
46 ChildProcess::WaitForDebugger("Gpu"); | 51 ChildProcess::WaitForDebugger("Gpu"); |
47 } | 52 } |
48 | 53 |
49 if (!command_line.HasSwitch(switches::kSingleProcess)) { | 54 if (!command_line.HasSwitch(switches::kSingleProcess)) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 #endif | 98 #endif |
94 | 99 |
95 // Set the GPU info even if it failed. | 100 // Set the GPU info even if it failed. |
96 content::GetContentClient()->SetGpuInfo(gpu_info); | 101 content::GetContentClient()->SetGpuInfo(gpu_info); |
97 } else { | 102 } else { |
98 LOG(INFO) << "gfx::GLSurface::InitializeOneOff failed"; | 103 LOG(INFO) << "gfx::GLSurface::InitializeOneOff failed"; |
99 gpu_info.gpu_accessible = false; | 104 gpu_info.gpu_accessible = false; |
100 dead_on_arrival = true; | 105 dead_on_arrival = true; |
101 } | 106 } |
102 | 107 |
108 #if defined(OS_LINUX) | |
109 // TODO(cevans): eventually this will be removed when we have tested all | |
110 // cards and drivers. | |
111 if (gpu_info.vendor_id == 0x1002) { // ATI | |
Will Drewry
2012/04/12 01:08:56
Any chance we can get intel in here?
Chris Evans
2012/04/12 18:42:49
Yes, and imminently, but not for this first patch.
| |
112 // Warm up the random system before sandboxing. The numbers are arbitrary. | |
113 (void) base::RandInt(0, 1337); | |
apatrick_chromium
2012/04/12 18:36:46
We warm up rand on windows as well. Maybe just do
| |
114 // Initialize the sandbox here because it's after the card has been | |
115 // opened ("privileged" operation) but before we've kicked off any threads. | |
116 content::InitializeSandbox(); | |
117 } | |
118 #endif | |
119 | |
103 base::win::ScopedCOMInitializer com_initializer; | 120 base::win::ScopedCOMInitializer com_initializer; |
104 | 121 |
105 #if defined(OS_WIN) | 122 #if defined(OS_WIN) |
106 // Preload this DLL because the sandbox prevents it from loading. | 123 // Preload this DLL because the sandbox prevents it from loading. |
107 LoadLibrary(L"setupapi.dll"); | 124 LoadLibrary(L"setupapi.dll"); |
108 | 125 |
109 // Cause advapi32 to load before the sandbox is turned on. | 126 // Cause advapi32 to load before the sandbox is turned on. |
110 unsigned int dummy_rand; | 127 unsigned int dummy_rand; |
111 rand_s(&dummy_rand); | 128 rand_s(&dummy_rand); |
apatrick_chromium
2012/04/12 18:36:46
...here
| |
112 | 129 |
113 sandbox::TargetServices* target_services = | 130 sandbox::TargetServices* target_services = |
114 parameters.sandbox_info->target_services; | 131 parameters.sandbox_info->target_services; |
115 // Initialize H/W video decoding stuff which fails in the sandbox. | 132 // Initialize H/W video decoding stuff which fails in the sandbox. |
116 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); | 133 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); |
117 // For windows, if the target_services interface is not zero, the process | 134 // For windows, if the target_services interface is not zero, the process |
118 // is sandboxed and we must call LowerToken() before rendering untrusted | 135 // is sandboxed and we must call LowerToken() before rendering untrusted |
119 // content. | 136 // content. |
120 if (target_services) | 137 if (target_services) |
121 target_services->LowerToken(); | 138 target_services->LowerToken(); |
(...skipping 22 matching lines...) Expand all Loading... | |
144 child_thread->Init(start_time); | 161 child_thread->Init(start_time); |
145 | 162 |
146 gpu_process.set_main_thread(child_thread); | 163 gpu_process.set_main_thread(child_thread); |
147 | 164 |
148 main_message_loop.Run(); | 165 main_message_loop.Run(); |
149 | 166 |
150 child_thread->StopWatchdog(); | 167 child_thread->StopWatchdog(); |
151 | 168 |
152 return 0; | 169 return 0; |
153 } | 170 } |
OLD | NEW |