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/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/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "content/common/gpu/gpu_messages.h" | 26 #include "content/common/gpu/gpu_messages.h" |
| 27 #include "content/common/view_messages.h" | 27 #include "content/common/view_messages.h" |
| 28 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" | 28 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" |
| 29 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/browser/content_browser_client.h" | 30 #include "content/public/browser/content_browser_client.h" |
| 31 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
| 32 #include "content/public/browser/render_widget_host_view.h" | 32 #include "content/public/browser/render_widget_host_view.h" |
| 33 #include "content/public/common/content_client.h" | 33 #include "content/public/common/content_client.h" |
| 34 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
| 35 #include "content/public/common/result_codes.h" | 35 #include "content/public/common/result_codes.h" |
| 36 #include "content/public/common/sandboxed_process_launcher_delegate.h" | |
| 36 #include "gpu/command_buffer/service/gpu_switches.h" | 37 #include "gpu/command_buffer/service/gpu_switches.h" |
| 37 #include "ipc/ipc_channel_handle.h" | 38 #include "ipc/ipc_channel_handle.h" |
| 38 #include "ipc/ipc_switches.h" | 39 #include "ipc/ipc_switches.h" |
| 39 #include "ui/events/latency_info.h" | 40 #include "ui/events/latency_info.h" |
| 40 #include "ui/gl/gl_switches.h" | 41 #include "ui/gl/gl_switches.h" |
| 41 | 42 |
| 42 | 43 |
| 43 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
| 44 #include "base/win/windows_version.h" | 45 #include "base/win/windows_version.h" |
| 45 #include "content/common/sandbox_win.h" | 46 #include "content/common/sandbox_win.h" |
| 46 #include "content/public/common/sandboxed_process_launcher_delegate.h" | |
| 47 #include "sandbox/win/src/sandbox_policy.h" | 47 #include "sandbox/win/src/sandbox_policy.h" |
| 48 #include "ui/gfx/switches.h" | 48 #include "ui/gfx/switches.h" |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
| 52 #include "chromeos/chromeos_switches.h" | 52 #include "chromeos/chromeos_switches.h" |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 #if defined(USE_OZONE) | 55 #if defined(USE_OZONE) |
| 56 #include "ui/ozone/ozone_switches.h" | 56 #include "ui/ozone/ozone_switches.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 AcceleratedSurfaceBuffersSwappedCompletedForGPU( | 171 AcceleratedSurfaceBuffersSwappedCompletedForGPU( |
| 172 host_id, route_id, alive, timebase, interval); | 172 host_id, route_id, alive, timebase, interval); |
| 173 AcceleratedSurfaceBuffersSwappedCompletedForRenderer( | 173 AcceleratedSurfaceBuffersSwappedCompletedForRenderer( |
| 174 surface_id, timebase, interval, latency_info); | 174 surface_id, timebase, interval, latency_info); |
| 175 } | 175 } |
| 176 | 176 |
| 177 // NOTE: changes to this class need to be reviewed by the security team. | 177 // NOTE: changes to this class need to be reviewed by the security team. |
| 178 class GpuSandboxedProcessLauncherDelegate | 178 class GpuSandboxedProcessLauncherDelegate |
| 179 : public SandboxedProcessLauncherDelegate { | 179 : public SandboxedProcessLauncherDelegate { |
| 180 public: | 180 public: |
| 181 explicit GpuSandboxedProcessLauncherDelegate(CommandLine* cmd_line) | 181 GpuSandboxedProcessLauncherDelegate(CommandLine* cmd_line, |
| 182 : cmd_line_(cmd_line) {} | 182 ChildProcessHost* /*host*/): |
|
jam
2014/02/26 19:47:52
nit: here and in other places, within content code
aberent
2014/02/28 08:51:06
Done.
| |
| 183 cmd_line_(cmd_line) {} | |
|
jam
2014/02/26 19:47:52
nit: indentation
aberent
2014/02/28 08:51:06
Done.
| |
| 183 virtual ~GpuSandboxedProcessLauncherDelegate() {} | 184 virtual ~GpuSandboxedProcessLauncherDelegate() {} |
| 184 | 185 |
| 185 virtual void ShouldSandbox(bool* in_sandbox) OVERRIDE { | 186 virtual void ShouldSandbox(bool* in_sandbox) OVERRIDE { |
| 186 if (cmd_line_->HasSwitch(switches::kDisableGpuSandbox)) { | 187 if (cmd_line_->HasSwitch(switches::kDisableGpuSandbox)) { |
| 187 *in_sandbox = false; | 188 *in_sandbox = false; |
| 188 DVLOG(1) << "GPU sandbox is disabled"; | 189 DVLOG(1) << "GPU sandbox is disabled"; |
| 189 } | 190 } |
| 190 } | 191 } |
| 191 | 192 |
| 192 virtual void PreSandbox(bool* disable_default_policy, | 193 virtual void PreSandbox(bool* disable_default_policy, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 *success = false; | 271 *success = false; |
| 271 return; | 272 return; |
| 272 } | 273 } |
| 273 } | 274 } |
| 274 } | 275 } |
| 275 } | 276 } |
| 276 | 277 |
| 277 private: | 278 private: |
| 278 CommandLine* cmd_line_; | 279 CommandLine* cmd_line_; |
| 279 }; | 280 }; |
| 280 #endif // defined(OS_WIN) | 281 |
| 282 #elif defined(OS_POSIX) | |
| 283 // NOTE: changes to this class need to be reviewed by the security team. | |
| 284 class GpuSandboxedProcessLauncherDelegate | |
|
jam
2014/02/26 19:47:52
ditto, we should have one implementation of this f
aberent
2014/02/28 08:51:06
Done.
| |
| 285 : public SandboxedProcessLauncherDelegate { | |
| 286 public: | |
| 287 GpuSandboxedProcessLauncherDelegate(CommandLine* /*cmd_line*/, | |
| 288 ChildProcessHost* host) | |
| 289 : ipc_fd_(host->TakeClientFileDescriptor()) {} | |
| 290 virtual ~GpuSandboxedProcessLauncherDelegate() {} | |
| 291 | |
| 292 virtual int IpcFd() OVERRIDE { | |
| 293 return ipc_fd_; | |
| 294 } | |
| 295 | |
| 296 private: | |
| 297 int ipc_fd_; | |
| 298 }; | |
| 299 #endif // OS_WIN | |
| 281 | 300 |
| 282 } // anonymous namespace | 301 } // anonymous namespace |
| 283 | 302 |
| 284 // static | 303 // static |
| 285 bool GpuProcessHost::ValidateHost(GpuProcessHost* host) { | 304 bool GpuProcessHost::ValidateHost(GpuProcessHost* host) { |
| 286 if (!host) | 305 if (!host) |
| 287 return false; | 306 return false; |
| 288 | 307 |
| 289 // The Gpu process is invalid if it's not using SwiftShader, the card is | 308 // The Gpu process is invalid if it's not using SwiftShader, the card is |
| 290 // blacklisted, and we can kill it and start over. | 309 // blacklisted, and we can kill it and start over. |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1134 } | 1153 } |
| 1135 | 1154 |
| 1136 UMA_HISTOGRAM_BOOLEAN("GPU.GPU.GPUProcessSoftwareRendering", | 1155 UMA_HISTOGRAM_BOOLEAN("GPU.GPU.GPUProcessSoftwareRendering", |
| 1137 swiftshader_rendering_); | 1156 swiftshader_rendering_); |
| 1138 | 1157 |
| 1139 // If specified, prepend a launcher program to the command line. | 1158 // If specified, prepend a launcher program to the command line. |
| 1140 if (!gpu_launcher.empty()) | 1159 if (!gpu_launcher.empty()) |
| 1141 cmd_line->PrependWrapper(gpu_launcher); | 1160 cmd_line->PrependWrapper(gpu_launcher); |
| 1142 | 1161 |
| 1143 process_->Launch( | 1162 process_->Launch( |
| 1144 #if defined(OS_WIN) | 1163 new GpuSandboxedProcessLauncherDelegate(cmd_line, |
| 1145 new GpuSandboxedProcessLauncherDelegate(cmd_line), | 1164 process_->GetHost()), |
| 1146 false, | |
| 1147 #elif defined(OS_POSIX) | |
| 1148 false, | |
| 1149 base::EnvironmentMap(), | |
| 1150 #endif | |
| 1151 cmd_line); | 1165 cmd_line); |
| 1152 process_launched_ = true; | 1166 process_launched_ = true; |
| 1153 | 1167 |
| 1154 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", | 1168 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", |
| 1155 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); | 1169 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); |
| 1156 return true; | 1170 return true; |
| 1157 } | 1171 } |
| 1158 | 1172 |
| 1159 void GpuProcessHost::SendOutstandingReplies() { | 1173 void GpuProcessHost::SendOutstandingReplies() { |
| 1160 valid_ = false; | 1174 valid_ = false; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1227 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1241 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1228 ClientIdToShaderCacheMap::iterator iter = | 1242 ClientIdToShaderCacheMap::iterator iter = |
| 1229 client_id_to_shader_cache_.find(client_id); | 1243 client_id_to_shader_cache_.find(client_id); |
| 1230 // If the cache doesn't exist then this is an off the record profile. | 1244 // If the cache doesn't exist then this is an off the record profile. |
| 1231 if (iter == client_id_to_shader_cache_.end()) | 1245 if (iter == client_id_to_shader_cache_.end()) |
| 1232 return; | 1246 return; |
| 1233 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1247 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1234 } | 1248 } |
| 1235 | 1249 |
| 1236 } // namespace content | 1250 } // namespace content |
| OLD | NEW |