| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
| 77 #include "base/win/windows_version.h" | 77 #include "base/win/windows_version.h" |
| 78 #include "content/common/sandbox_win.h" | 78 #include "content/common/sandbox_win.h" |
| 79 #include "sandbox/win/src/sandbox_policy.h" | 79 #include "sandbox/win/src/sandbox_policy.h" |
| 80 #include "ui/gfx/switches.h" | 80 #include "ui/gfx/switches.h" |
| 81 #include "ui/gfx/win/rendering_window_manager.h" | 81 #include "ui/gfx/win/rendering_window_manager.h" |
| 82 #endif | 82 #endif |
| 83 | 83 |
| 84 #if defined(USE_OZONE) | 84 #if defined(USE_OZONE) |
| 85 #include "ui/ozone/public/gpu_platform_support_host.h" |
| 86 #include "ui/ozone/public/ozone_platform.h" |
| 85 #include "ui/ozone/public/ozone_switches.h" | 87 #include "ui/ozone/public/ozone_switches.h" |
| 86 #endif | 88 #endif |
| 87 | 89 |
| 88 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 90 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 89 #include "ui/gfx/x/x11_switches.h" // nogncheck | 91 #include "ui/gfx/x/x11_switches.h" // nogncheck |
| 90 #endif | 92 #endif |
| 91 | 93 |
| 92 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 94 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 93 #include "gpu/ipc/common/gpu_surface_tracker.h" | 95 #include "gpu/ipc/common/gpu_surface_tracker.h" |
| 94 #endif | 96 #endif |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 bool force_create, | 179 bool force_create, |
| 178 IPC::Message* message) { | 180 IPC::Message* message) { |
| 179 GpuProcessHost* host = GpuProcessHost::Get(kind, force_create); | 181 GpuProcessHost* host = GpuProcessHost::Get(kind, force_create); |
| 180 if (host) { | 182 if (host) { |
| 181 host->Send(message); | 183 host->Send(message); |
| 182 } else { | 184 } else { |
| 183 delete message; | 185 delete message; |
| 184 } | 186 } |
| 185 } | 187 } |
| 186 | 188 |
| 189 void SendGpuProcessMessageByHostId(int host_id, IPC::Message* message) { |
| 190 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
| 191 if (host) { |
| 192 host->Send(message); |
| 193 } else { |
| 194 delete message; |
| 195 } |
| 196 } |
| 197 |
| 187 // NOTE: changes to this class need to be reviewed by the security team. | 198 // NOTE: changes to this class need to be reviewed by the security team. |
| 188 class GpuSandboxedProcessLauncherDelegate | 199 class GpuSandboxedProcessLauncherDelegate |
| 189 : public SandboxedProcessLauncherDelegate { | 200 : public SandboxedProcessLauncherDelegate { |
| 190 public: | 201 public: |
| 191 GpuSandboxedProcessLauncherDelegate(base::CommandLine* cmd_line, | 202 GpuSandboxedProcessLauncherDelegate(base::CommandLine* cmd_line, |
| 192 ChildProcessHost* host) | 203 ChildProcessHost* host) |
| 193 #if defined(OS_WIN) | 204 #if defined(OS_WIN) |
| 194 : cmd_line_(cmd_line) {} | 205 : cmd_line_(cmd_line) {} |
| 195 #elif defined(OS_POSIX) | 206 #elif defined(OS_POSIX) |
| 196 : ipc_fd_(host->TakeClientFileDescriptor()) {} | 207 : ipc_fd_(host->TakeClientFileDescriptor()) {} |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 switches::kInProcessGPU)) { | 458 switches::kInProcessGPU)) { |
| 448 in_process_ = true; | 459 in_process_ = true; |
| 449 } | 460 } |
| 450 | 461 |
| 451 // If the 'single GPU process' policy ever changes, we still want to maintain | 462 // If the 'single GPU process' policy ever changes, we still want to maintain |
| 452 // it for 'gpu thread' mode and only create one instance of host and thread. | 463 // it for 'gpu thread' mode and only create one instance of host and thread. |
| 453 DCHECK(!in_process_ || g_gpu_process_hosts[kind] == NULL); | 464 DCHECK(!in_process_ || g_gpu_process_hosts[kind] == NULL); |
| 454 | 465 |
| 455 g_gpu_process_hosts[kind] = this; | 466 g_gpu_process_hosts[kind] = this; |
| 456 | 467 |
| 468 #if defined(USE_OZONE) |
| 469 ui::OzonePlatform::GetInstance() |
| 470 ->GetGpuPlatformSupportHost() |
| 471 ->OnGpuProcessLaunched( |
| 472 host_id, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), |
| 473 base::Bind(&SendGpuProcessMessageByHostId, host_id)); |
| 474 #endif |
| 475 |
| 457 // Post a task to create the corresponding GpuProcessHostUIShim. The | 476 // Post a task to create the corresponding GpuProcessHostUIShim. The |
| 458 // GpuProcessHostUIShim will be destroyed if either the browser exits, | 477 // GpuProcessHostUIShim will be destroyed if either the browser exits, |
| 459 // in which case it calls GpuProcessHostUIShim::DestroyAll, or the | 478 // in which case it calls GpuProcessHostUIShim::DestroyAll, or the |
| 460 // GpuProcessHost is destroyed, which happens when the corresponding GPU | 479 // GpuProcessHost is destroyed, which happens when the corresponding GPU |
| 461 // process terminates or fails to launch. | 480 // process terminates or fails to launch. |
| 462 BrowserThread::PostTask( | 481 BrowserThread::PostTask( |
| 463 BrowserThread::UI, | 482 BrowserThread::UI, |
| 464 FROM_HERE, | 483 FROM_HERE, |
| 465 base::Bind(base::IgnoreResult(&GpuProcessHostUIShim::Create), host_id)); | 484 base::Bind(base::IgnoreResult(&GpuProcessHostUIShim::Create), host_id)); |
| 466 | 485 |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1184 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1166 ClientIdToShaderCacheMap::iterator iter = | 1185 ClientIdToShaderCacheMap::iterator iter = |
| 1167 client_id_to_shader_cache_.find(client_id); | 1186 client_id_to_shader_cache_.find(client_id); |
| 1168 // If the cache doesn't exist then this is an off the record profile. | 1187 // If the cache doesn't exist then this is an off the record profile. |
| 1169 if (iter == client_id_to_shader_cache_.end()) | 1188 if (iter == client_id_to_shader_cache_.end()) |
| 1170 return; | 1189 return; |
| 1171 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1190 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1172 } | 1191 } |
| 1173 | 1192 |
| 1174 } // namespace content | 1193 } // namespace content |
| OLD | NEW |