| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 bool force_create, | 180 bool force_create, |
| 179 IPC::Message* message) { | 181 IPC::Message* message) { |
| 180 GpuProcessHost* host = GpuProcessHost::Get(kind, force_create); | 182 GpuProcessHost* host = GpuProcessHost::Get(kind, force_create); |
| 181 if (host) { | 183 if (host) { |
| 182 host->Send(message); | 184 host->Send(message); |
| 183 } else { | 185 } else { |
| 184 delete message; | 186 delete message; |
| 185 } | 187 } |
| 186 } | 188 } |
| 187 | 189 |
| 190 #if defined(USE_OZONE) |
| 191 void SendGpuProcessMessageByHostId(int host_id, IPC::Message* message) { |
| 192 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
| 193 if (host) { |
| 194 host->Send(message); |
| 195 } else { |
| 196 delete message; |
| 197 } |
| 198 } |
| 199 #endif |
| 200 |
| 188 // 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. |
| 189 class GpuSandboxedProcessLauncherDelegate | 202 class GpuSandboxedProcessLauncherDelegate |
| 190 : public SandboxedProcessLauncherDelegate { | 203 : public SandboxedProcessLauncherDelegate { |
| 191 public: | 204 public: |
| 192 GpuSandboxedProcessLauncherDelegate(base::CommandLine* cmd_line, | 205 GpuSandboxedProcessLauncherDelegate(base::CommandLine* cmd_line, |
| 193 ChildProcessHost* host) | 206 ChildProcessHost* host) |
| 194 #if defined(OS_WIN) | 207 #if defined(OS_WIN) |
| 195 : cmd_line_(cmd_line) {} | 208 : cmd_line_(cmd_line) {} |
| 196 #elif defined(OS_POSIX) | 209 #elif defined(OS_POSIX) |
| 197 : ipc_fd_(host->TakeClientFileDescriptor()) {} | 210 : ipc_fd_(host->TakeClientFileDescriptor()) {} |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 in_process_gpu_thread_->StartWithOptions(options); | 602 in_process_gpu_thread_->StartWithOptions(options); |
| 590 | 603 |
| 591 OnProcessLaunched(); // Fake a callback that the process is ready. | 604 OnProcessLaunched(); // Fake a callback that the process is ready. |
| 592 } else if (!LaunchGpuProcess(&gpu_preferences)) { | 605 } else if (!LaunchGpuProcess(&gpu_preferences)) { |
| 593 return false; | 606 return false; |
| 594 } | 607 } |
| 595 | 608 |
| 596 if (!Send(new GpuMsg_Initialize(gpu_preferences))) | 609 if (!Send(new GpuMsg_Initialize(gpu_preferences))) |
| 597 return false; | 610 return false; |
| 598 | 611 |
| 612 #if defined(USE_OZONE) |
| 613 // Ozone needs to send the primary DRM device to GPU process as early as |
| 614 // possible to ensure the latter always has a valid device. crbug.com/608839 |
| 615 ui::OzonePlatform::GetInstance() |
| 616 ->GetGpuPlatformSupportHost() |
| 617 ->OnGpuProcessLaunched( |
| 618 host_id_, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), |
| 619 base::Bind(&SendGpuProcessMessageByHostId, host_id_)); |
| 620 #endif |
| 621 |
| 599 return true; | 622 return true; |
| 600 } | 623 } |
| 601 | 624 |
| 602 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { | 625 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { |
| 603 BrowserThread::PostTask( | 626 BrowserThread::PostTask( |
| 604 BrowserThread::UI, | 627 BrowserThread::UI, |
| 605 FROM_HERE, | 628 FROM_HERE, |
| 606 base::Bind(&RouteToGpuProcessHostUIShimTask, host_id_, message)); | 629 base::Bind(&RouteToGpuProcessHostUIShimTask, host_id_, message)); |
| 607 } | 630 } |
| 608 | 631 |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1189 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1167 ClientIdToShaderCacheMap::iterator iter = | 1190 ClientIdToShaderCacheMap::iterator iter = |
| 1168 client_id_to_shader_cache_.find(client_id); | 1191 client_id_to_shader_cache_.find(client_id); |
| 1169 // If the cache doesn't exist then this is an off the record profile. | 1192 // If the cache doesn't exist then this is an off the record profile. |
| 1170 if (iter == client_id_to_shader_cache_.end()) | 1193 if (iter == client_id_to_shader_cache_.end()) |
| 1171 return; | 1194 return; |
| 1172 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1195 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1173 } | 1196 } |
| 1174 | 1197 |
| 1175 } // namespace content | 1198 } // namespace content |
| OLD | NEW |