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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 } else { | 195 } else { |
196 delete message; | 196 delete message; |
197 } | 197 } |
198 } | 198 } |
199 #endif | 199 #endif |
200 | 200 |
201 // NOTE: changes to this class need to be reviewed by the security team. | 201 // NOTE: changes to this class need to be reviewed by the security team. |
202 class GpuSandboxedProcessLauncherDelegate | 202 class GpuSandboxedProcessLauncherDelegate |
203 : public SandboxedProcessLauncherDelegate { | 203 : public SandboxedProcessLauncherDelegate { |
204 public: | 204 public: |
205 GpuSandboxedProcessLauncherDelegate(base::CommandLine* cmd_line, | 205 explicit GpuSandboxedProcessLauncherDelegate(base::CommandLine* cmd_line) |
206 ChildProcessHost* host) | |
207 #if defined(OS_WIN) | 206 #if defined(OS_WIN) |
208 : cmd_line_(cmd_line) {} | 207 : cmd_line_(cmd_line) |
209 #elif defined(OS_POSIX) | |
210 : ipc_fd_(host->TakeClientFileDescriptor()) {} | |
211 #endif | 208 #endif |
209 { | |
210 } | |
nasko
2016/11/09 18:38:10
Is this formatted using "git cl format"?
Sam McNally
2016/11/09 20:21:39
Yes.
| |
212 | 211 |
213 ~GpuSandboxedProcessLauncherDelegate() override {} | 212 ~GpuSandboxedProcessLauncherDelegate() override {} |
214 | 213 |
215 #if defined(OS_WIN) | 214 #if defined(OS_WIN) |
216 bool ShouldSandbox() override { | 215 bool ShouldSandbox() override { |
217 bool sandbox = !cmd_line_->HasSwitch(switches::kDisableGpuSandbox); | 216 bool sandbox = !cmd_line_->HasSwitch(switches::kDisableGpuSandbox); |
218 if (!sandbox) { | 217 if (!sandbox) { |
219 DVLOG(1) << "GPU sandbox is disabled"; | 218 DVLOG(1) << "GPU sandbox is disabled"; |
220 } | 219 } |
221 return sandbox; | 220 return sandbox; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, | 281 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, |
283 sandbox::TargetPolicy::FILES_ALLOW_ANY, | 282 sandbox::TargetPolicy::FILES_ALLOW_ANY, |
284 log_file_path.c_str()); | 283 log_file_path.c_str()); |
285 if (result != sandbox::SBOX_ALL_OK) | 284 if (result != sandbox::SBOX_ALL_OK) |
286 return false; | 285 return false; |
287 } | 286 } |
288 } | 287 } |
289 | 288 |
290 return true; | 289 return true; |
291 } | 290 } |
292 #elif defined(OS_POSIX) | |
293 | |
294 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } | |
295 #endif // OS_WIN | 291 #endif // OS_WIN |
296 | 292 |
297 SandboxType GetSandboxType() override { | 293 SandboxType GetSandboxType() override { |
298 return SANDBOX_TYPE_GPU; | 294 return SANDBOX_TYPE_GPU; |
299 } | 295 } |
300 | 296 |
301 private: | 297 private: |
302 #if defined(OS_WIN) | 298 #if defined(OS_WIN) |
303 base::CommandLine* cmd_line_; | 299 base::CommandLine* cmd_line_; |
304 #elif defined(OS_POSIX) | |
305 base::ScopedFD ipc_fd_; | |
306 #endif // OS_WIN | 300 #endif // OS_WIN |
307 }; | 301 }; |
308 | 302 |
309 void HostLoadedShader(int host_id, | 303 void HostLoadedShader(int host_id, |
310 const std::string& key, | 304 const std::string& key, |
311 const std::string& data) { | 305 const std::string& data) { |
312 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 306 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
313 if (host) | 307 if (host) |
314 host->LoadedShader(key, data); | 308 host->LoadedShader(key, data); |
315 } | 309 } |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1042 return false; | 1036 return false; |
1043 } | 1037 } |
1044 | 1038 |
1045 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessSoftwareRendering", | 1039 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessSoftwareRendering", |
1046 swiftshader_rendering_); | 1040 swiftshader_rendering_); |
1047 | 1041 |
1048 // If specified, prepend a launcher program to the command line. | 1042 // If specified, prepend a launcher program to the command line. |
1049 if (!gpu_launcher.empty()) | 1043 if (!gpu_launcher.empty()) |
1050 cmd_line->PrependWrapper(gpu_launcher); | 1044 cmd_line->PrependWrapper(gpu_launcher); |
1051 | 1045 |
1052 process_->Launch( | 1046 process_->Launch(new GpuSandboxedProcessLauncherDelegate(cmd_line), cmd_line, |
1053 new GpuSandboxedProcessLauncherDelegate(cmd_line, process_->GetHost()), | 1047 true); |
1054 cmd_line, true); | |
1055 process_launched_ = true; | 1048 process_launched_ = true; |
1056 | 1049 |
1057 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", | 1050 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", |
1058 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); | 1051 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); |
1059 return true; | 1052 return true; |
1060 } | 1053 } |
1061 | 1054 |
1062 void GpuProcessHost::SendOutstandingReplies() { | 1055 void GpuProcessHost::SendOutstandingReplies() { |
1063 valid_ = false; | 1056 valid_ = false; |
1064 // First send empty channel handles for all EstablishChannel requests. | 1057 // First send empty channel handles for all EstablishChannel requests. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1197 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1190 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1198 ClientIdToShaderCacheMap::iterator iter = | 1191 ClientIdToShaderCacheMap::iterator iter = |
1199 client_id_to_shader_cache_.find(client_id); | 1192 client_id_to_shader_cache_.find(client_id); |
1200 // If the cache doesn't exist then this is an off the record profile. | 1193 // If the cache doesn't exist then this is an off the record profile. |
1201 if (iter == client_id_to_shader_cache_.end()) | 1194 if (iter == client_id_to_shader_cache_.end()) |
1202 return; | 1195 return; |
1203 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1196 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1204 } | 1197 } |
1205 | 1198 |
1206 } // namespace content | 1199 } // namespace content |
OLD | NEW |