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

Side by Side Diff: content/browser/gpu/gpu_process_host.cc

Issue 12805004: Remove mention of the nacl process in content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/child_process_launcher.cc ('k') | content/browser/plugin_process_host.cc » ('j') | 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/browser/gpu/gpu_process_host.h" 5 #include "content/browser/gpu/gpu_process_host.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/base_switches.h" 8 #include "base/base_switches.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/logging.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
15 #include "base/process_util.h" 16 #include "base/process_util.h"
16 #include "base/sha1.h" 17 #include "base/sha1.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "content/browser/browser_child_process_host_impl.h" 19 #include "content/browser/browser_child_process_host_impl.h"
19 #include "content/browser/gpu/gpu_data_manager_impl.h" 20 #include "content/browser/gpu/gpu_data_manager_impl.h"
20 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 21 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
21 #include "content/browser/gpu/gpu_surface_tracker.h" 22 #include "content/browser/gpu/gpu_surface_tracker.h"
22 #include "content/browser/gpu/shader_disk_cache.h" 23 #include "content/browser/gpu/shader_disk_cache.h"
(...skipping 16 matching lines...) Expand all
39 #include "gpu/command_buffer/service/gpu_switches.h" 40 #include "gpu/command_buffer/service/gpu_switches.h"
40 #include "ipc/ipc_channel_handle.h" 41 #include "ipc/ipc_channel_handle.h"
41 #include "ipc/ipc_switches.h" 42 #include "ipc/ipc_switches.h"
42 #include "ui/gl/gl_switches.h" 43 #include "ui/gl/gl_switches.h"
43 44
44 #if defined(TOOLKIT_GTK) 45 #if defined(TOOLKIT_GTK)
45 #include "ui/gfx/gtk_native_view_id_manager.h" 46 #include "ui/gfx/gtk_native_view_id_manager.h"
46 #endif 47 #endif
47 48
48 #if defined(OS_WIN) 49 #if defined(OS_WIN)
50 #include "base/win/windows_version.h"
51 #include "content/common/sandbox_win.h"
52 #include "content/public/common/sandboxed_process_launcher_delegate.h"
53 #include "sandbox/win/src/sandbox_policy.h"
49 #include "ui/surface/accelerated_surface_win.h" 54 #include "ui/surface/accelerated_surface_win.h"
50 #endif 55 #endif
51 56
52 namespace content { 57 namespace content {
53 58
54 bool GpuProcessHost::gpu_enabled_ = true; 59 bool GpuProcessHost::gpu_enabled_ = true;
55 bool GpuProcessHost::hardware_gpu_enabled_ = true; 60 bool GpuProcessHost::hardware_gpu_enabled_ = true;
56 61
57 namespace { 62 namespace {
58 63
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 int surface_id, 161 int surface_id,
157 uint64 surface_handle, 162 uint64 surface_handle,
158 bool alive, 163 bool alive,
159 base::TimeTicks timebase, 164 base::TimeTicks timebase,
160 base::TimeDelta interval) { 165 base::TimeDelta interval) {
161 AcceleratedSurfaceBuffersSwappedCompletedForGPU(host_id, route_id, 166 AcceleratedSurfaceBuffersSwappedCompletedForGPU(host_id, route_id,
162 alive, surface_handle); 167 alive, surface_handle);
163 AcceleratedSurfaceBuffersSwappedCompletedForRenderer(surface_id, timebase, 168 AcceleratedSurfaceBuffersSwappedCompletedForRenderer(surface_id, timebase,
164 interval); 169 interval);
165 } 170 }
171
172 // NOTE: changes to this class need to be reviewed by the security team.
173 class GpuSandboxedProcessLauncherDelegate
174 : public SandboxedProcessLauncherDelegate {
175 public:
176 explicit GpuSandboxedProcessLauncherDelegate(CommandLine* cmd_line)
177 : cmd_line_(cmd_line) {}
178 virtual ~GpuSandboxedProcessLauncherDelegate() {}
179
180 virtual void PreSandbox(bool* disable_default_policy,
181 base::FilePath* exposed_dir) OVERRIDE {
182 *disable_default_policy = true;
183 }
184
185 // For the GPU process we gotten as far as USER_LIMITED. The next level
186 // which is USER_RESTRICTED breaks both the DirectX backend and the OpenGL
187 // backend. Note that the GPU process is connected to the interactive
188 // desktop.
189 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy,
190 bool* success) {
191 if (base::win::GetVersion() > base::win::VERSION_XP) {
192 if (cmd_line_->GetSwitchValueASCII(switches::kUseGL) ==
193 gfx::kGLImplementationDesktopName) {
194 // Open GL path.
195 policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS,
196 sandbox::USER_LIMITED);
197 SetJobLevel(*cmd_line_, sandbox::JOB_UNPROTECTED, 0, policy);
198 policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW);
199 } else {
200 if (cmd_line_->GetSwitchValueASCII(switches::kUseGL) ==
201 gfx::kGLImplementationSwiftShaderName ||
202 cmd_line_->HasSwitch(switches::kReduceGpuSandbox) ||
203 cmd_line_->HasSwitch(switches::kDisableImageTransportSurface)) {
204 // Swiftshader path.
205 policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS,
206 sandbox::USER_LIMITED);
207 } else {
208 // Angle + DirectX path.
209 policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS,
210 sandbox::USER_RESTRICTED);
211 // This is a trick to keep the GPU out of low-integrity processes. It
212 // starts at low-integrity for UIPI to work, then drops below
213 // low-integrity after warm-up.
214 policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_UNTRUSTED);
215 }
216
217 // UI restrictions break when we access Windows from outside our job.
218 // However, we don't want a proxy window in this process because it can
219 // introduce deadlocks where the renderer blocks on the gpu, which in
220 // turn blocks on the browser UI thread. So, instead we forgo a window
221 // message pump entirely and just add job restrictions to prevent child
222 // processes.
223 SetJobLevel(*cmd_line_,
224 sandbox::JOB_LIMITED_USER,
225 JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS |
226 JOB_OBJECT_UILIMIT_DESKTOP |
227 JOB_OBJECT_UILIMIT_EXITWINDOWS |
228 JOB_OBJECT_UILIMIT_DISPLAYSETTINGS,
229 policy);
230
231 policy->SetIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW);
232 }
233 } else {
234 SetJobLevel(*cmd_line_, sandbox::JOB_UNPROTECTED, 0, policy);
235 policy->SetTokenLevel(sandbox::USER_UNPROTECTED,
236 sandbox::USER_LIMITED);
237 }
238
239 // Allow the server side of GPU sockets, which are pipes that have
240 // the "chrome.gpu" namespace and an arbitrary suffix.
241 sandbox::ResultCode result = policy->AddRule(
242 sandbox::TargetPolicy::SUBSYS_NAMED_PIPES,
243 sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY,
244 L"\\\\.\\pipe\\chrome.gpu.*");
245 if (result != sandbox::SBOX_ALL_OK) {
246 *success = false;
247 return;
248 }
249
250 #ifdef USE_AURA
251 // GPU also needs to add sections to the browser for aura
252 // TODO(jschuh): refactor the GPU channel to remove this. crbug.com/128786
253 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES,
254 sandbox::TargetPolicy::HANDLES_DUP_BROKER,
255 L"Section");
256 if (result != sandbox::SBOX_ALL_OK) {
257 *success = false;
258 return;
259 }
260 #endif
261
262 if (cmd_line_->HasSwitch(switches::kEnableLogging)) {
263 string16 log_file_path = logging::GetLogFileFullPath();
264 if (!log_file_path.empty()) {
265 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
266 sandbox::TargetPolicy::FILES_ALLOW_ANY,
267 log_file_path.c_str());
268 if (result != sandbox::SBOX_ALL_OK) {
269 *success = false;
270 return;
271 }
272 }
273 }
274 }
275
276 private:
277 CommandLine* cmd_line_;
278 };
166 #endif // defined(OS_WIN) 279 #endif // defined(OS_WIN)
167 280
168 } // anonymous namespace 281 } // anonymous namespace
169 282
170 #if defined(TOOLKIT_GTK) 283 #if defined(TOOLKIT_GTK)
171 // Used to put a lock on surfaces so that the window to which the GPU 284 // Used to put a lock on surfaces so that the window to which the GPU
172 // process is drawing to doesn't disappear while it is drawing when 285 // process is drawing to doesn't disappear while it is drawing when
173 // a WebContents is closed. 286 // a WebContents is closed.
174 class GpuProcessHost::SurfaceRef { 287 class GpuProcessHost::SurfaceRef {
175 public: 288 public:
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 switches::kDisableSeccompFilterSandbox, 1167 switches::kDisableSeccompFilterSandbox,
1055 switches::kEnableGpuSandbox, 1168 switches::kEnableGpuSandbox,
1056 switches::kEnableLogging, 1169 switches::kEnableLogging,
1057 switches::kEnableVirtualGLContexts, 1170 switches::kEnableVirtualGLContexts,
1058 switches::kGpuStartupDialog, 1171 switches::kGpuStartupDialog,
1059 switches::kLoggingLevel, 1172 switches::kLoggingLevel,
1060 switches::kNoSandbox, 1173 switches::kNoSandbox,
1061 switches::kReduceGpuSandbox, 1174 switches::kReduceGpuSandbox,
1062 switches::kTestGLLib, 1175 switches::kTestGLLib,
1063 switches::kTraceStartup, 1176 switches::kTraceStartup,
1177 switches::kUseExynosVda,
1064 switches::kV, 1178 switches::kV,
1065 switches::kVModule, 1179 switches::kVModule,
1066 #if defined(OS_MACOSX) 1180 #if defined(OS_MACOSX)
1067 switches::kEnableSandboxLogging, 1181 switches::kEnableSandboxLogging,
1068 #endif 1182 #endif
1069 #if defined(USE_AURA) 1183 #if defined(USE_AURA)
1070 switches::kUIPrioritizeInGpuProcess, 1184 switches::kUIPrioritizeInGpuProcess,
1071 #endif 1185 #endif
1072 switches::kUseExynosVda,
1073 }; 1186 };
1074 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, 1187 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
1075 arraysize(kSwitchNames)); 1188 arraysize(kSwitchNames));
1076 cmd_line->CopySwitchesFrom( 1189 cmd_line->CopySwitchesFrom(
1077 browser_command_line, switches::kGpuSwitches, switches::kNumGpuSwitches); 1190 browser_command_line, switches::kGpuSwitches, switches::kNumGpuSwitches);
1078 cmd_line->CopySwitchesFrom( 1191 cmd_line->CopySwitchesFrom(
1079 browser_command_line, switches::kGLSwitchesCopiedFromGpuProcessHost, 1192 browser_command_line, switches::kGLSwitchesCopiedFromGpuProcessHost,
1080 switches::kGLSwitchesCopiedFromGpuProcessHostNumSwitches); 1193 switches::kGLSwitchesCopiedFromGpuProcessHostNumSwitches);
1081 1194
1082 GetContentClient()->browser()->AppendExtraCommandLineSwitches( 1195 GetContentClient()->browser()->AppendExtraCommandLineSwitches(
1083 cmd_line, process_->GetData().id); 1196 cmd_line, process_->GetData().id);
1084 1197
1085 GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line); 1198 GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line);
1086 1199
1087 if (cmd_line->HasSwitch(switches::kUseGL)) { 1200 if (cmd_line->HasSwitch(switches::kUseGL)) {
1088 software_rendering_ = 1201 software_rendering_ =
1089 (cmd_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); 1202 (cmd_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader");
1090 } 1203 }
1091 1204
1092 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessSoftwareRendering", software_rendering_); 1205 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessSoftwareRendering", software_rendering_);
1093 1206
1094 #if defined(OS_WIN)
1095 // Make GoogleDesktopNetwork3.dll think that the GPU process is a renderer
1096 // process so the DLL unloads itself. http://crbug/129884
1097 cmd_line->AppendSwitchASCII("ignored", " --type=renderer ");
1098 #endif
1099
1100 // If specified, prepend a launcher program to the command line. 1207 // If specified, prepend a launcher program to the command line.
1101 if (!gpu_launcher.empty()) 1208 if (!gpu_launcher.empty())
1102 cmd_line->PrependWrapper(gpu_launcher); 1209 cmd_line->PrependWrapper(gpu_launcher);
1103 1210
1104 process_->Launch( 1211 process_->Launch(
1105 #if defined(OS_WIN) 1212 #if defined(OS_WIN)
1106 base::FilePath(), 1213 new GpuSandboxedProcessLauncherDelegate(cmd_line),
1107 #elif defined(OS_POSIX) 1214 #elif defined(OS_POSIX)
1108 false, 1215 false,
1109 base::EnvironmentVector(), 1216 base::EnvironmentVector(),
1110 #endif 1217 #endif
1111 cmd_line); 1218 cmd_line);
1112 process_launched_ = true; 1219 process_launched_ = true;
1113 1220
1114 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", 1221 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents",
1115 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); 1222 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX);
1116 return true; 1223 return true;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); 1288 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader");
1182 ClientIdToShaderCacheMap::iterator iter = 1289 ClientIdToShaderCacheMap::iterator iter =
1183 client_id_to_shader_cache_.find(client_id); 1290 client_id_to_shader_cache_.find(client_id);
1184 // If the cache doesn't exist then this is an off the record profile. 1291 // If the cache doesn't exist then this is an off the record profile.
1185 if (iter == client_id_to_shader_cache_.end()) 1292 if (iter == client_id_to_shader_cache_.end())
1186 return; 1293 return;
1187 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); 1294 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader);
1188 } 1295 }
1189 1296
1190 } // namespace content 1297 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/child_process_launcher.cc ('k') | content/browser/plugin_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698