| 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> |
| 10 #include <list> |
| 9 #include <utility> | 11 #include <utility> |
| 10 | 12 |
| 11 #include "base/base64.h" | 13 #include "base/base64.h" |
| 12 #include "base/base_switches.h" | 14 #include "base/base_switches.h" |
| 13 #include "base/bind.h" | 15 #include "base/bind.h" |
| 14 #include "base/callback_helpers.h" | 16 #include "base/callback_helpers.h" |
| 15 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 16 #include "base/logging.h" | 18 #include "base/logging.h" |
| 17 #include "base/macros.h" | 19 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 19 #include "base/metrics/histogram.h" | 21 #include "base/metrics/field_trial.h" |
| 22 #include "base/metrics/histogram_macros.h" |
| 20 #include "base/sha1.h" | 23 #include "base/sha1.h" |
| 21 #include "base/threading/thread.h" | 24 #include "base/threading/thread.h" |
| 22 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
| 23 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 24 #include "components/tracing/common/tracing_switches.h" | 27 #include "components/tracing/common/tracing_switches.h" |
| 25 #include "content/browser/browser_child_process_host_impl.h" | 28 #include "content/browser/browser_child_process_host_impl.h" |
| 26 #include "content/browser/gpu/compositor_util.h" | 29 #include "content/browser/gpu/compositor_util.h" |
| 27 #include "content/browser/gpu/gpu_data_manager_impl.h" | 30 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 28 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 31 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 29 #include "content/browser/gpu/shader_disk_cache.h" | 32 #include "content/browser/gpu/shader_disk_cache.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 : cmd_line_(cmd_line) {} | 184 : cmd_line_(cmd_line) {} |
| 182 #elif defined(OS_POSIX) | 185 #elif defined(OS_POSIX) |
| 183 : ipc_fd_(host->TakeClientFileDescriptor()) {} | 186 : ipc_fd_(host->TakeClientFileDescriptor()) {} |
| 184 #endif | 187 #endif |
| 185 | 188 |
| 186 ~GpuSandboxedProcessLauncherDelegate() override {} | 189 ~GpuSandboxedProcessLauncherDelegate() override {} |
| 187 | 190 |
| 188 #if defined(OS_WIN) | 191 #if defined(OS_WIN) |
| 189 bool ShouldSandbox() override { | 192 bool ShouldSandbox() override { |
| 190 bool sandbox = !cmd_line_->HasSwitch(switches::kDisableGpuSandbox); | 193 bool sandbox = !cmd_line_->HasSwitch(switches::kDisableGpuSandbox); |
| 191 if(! sandbox) { | 194 if (!sandbox) { |
| 192 DVLOG(1) << "GPU sandbox is disabled"; | 195 DVLOG(1) << "GPU sandbox is disabled"; |
| 193 } | 196 } |
| 194 return sandbox; | 197 return sandbox; |
| 195 } | 198 } |
| 196 | 199 |
| 197 bool DisableDefaultPolicy() override { | 200 bool DisableDefaultPolicy() override { |
| 198 return true; | 201 return true; |
| 199 } | 202 } |
| 200 | 203 |
| 201 // For the GPU process we gotten as far as USER_LIMITED. The next level | 204 // For the GPU process we gotten as far as USER_LIMITED. The next level |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, | 625 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, |
| 623 OnDidDestroyOffscreenContext) | 626 OnDidDestroyOffscreenContext) |
| 624 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, | 627 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, |
| 625 OnGpuMemoryUmaStatsReceived) | 628 OnGpuMemoryUmaStatsReceived) |
| 626 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, OnDestroyChannel) | 629 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, OnDestroyChannel) |
| 627 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, OnCacheShader) | 630 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, OnCacheShader) |
| 628 #if defined(OS_WIN) | 631 #if defined(OS_WIN) |
| 629 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceCreatedChildWindow, | 632 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceCreatedChildWindow, |
| 630 OnAcceleratedSurfaceCreatedChildWindow) | 633 OnAcceleratedSurfaceCreatedChildWindow) |
| 631 #endif | 634 #endif |
| 632 | 635 IPC_MESSAGE_HANDLER(GpuHostMsg_FieldTrialActivated, OnFieldTrialActivated); |
| 633 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 636 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
| 634 IPC_END_MESSAGE_MAP() | 637 IPC_END_MESSAGE_MAP() |
| 635 | 638 |
| 636 return true; | 639 return true; |
| 637 } | 640 } |
| 638 | 641 |
| 639 #if defined(OS_WIN) | 642 #if defined(OS_WIN) |
| 640 void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow( | 643 void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow( |
| 641 gpu::SurfaceHandle parent_handle, | 644 gpu::SurfaceHandle parent_handle, |
| 642 gpu::SurfaceHandle window_handle) { | 645 gpu::SurfaceHandle window_handle) { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 urls_with_live_offscreen_contexts_.erase(url); | 904 urls_with_live_offscreen_contexts_.erase(url); |
| 902 } | 905 } |
| 903 | 906 |
| 904 void GpuProcessHost::OnGpuMemoryUmaStatsReceived( | 907 void GpuProcessHost::OnGpuMemoryUmaStatsReceived( |
| 905 const gpu::GPUMemoryUmaStats& stats) { | 908 const gpu::GPUMemoryUmaStats& stats) { |
| 906 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryUmaStatsReceived"); | 909 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryUmaStatsReceived"); |
| 907 uma_memory_stats_received_ = true; | 910 uma_memory_stats_received_ = true; |
| 908 uma_memory_stats_ = stats; | 911 uma_memory_stats_ = stats; |
| 909 } | 912 } |
| 910 | 913 |
| 914 void GpuProcessHost::OnFieldTrialActivated(const std::string& trial_name) { |
| 915 // Activate the trial in the browser process to match its state in the |
| 916 // GPU process. This is done by calling FindFullName which finalizes the group |
| 917 // and activates the trial. |
| 918 base::FieldTrialList::FindFullName(trial_name); |
| 919 } |
| 920 |
| 911 void GpuProcessHost::OnProcessLaunched() { | 921 void GpuProcessHost::OnProcessLaunched() { |
| 912 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", | 922 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", |
| 913 base::TimeTicks::Now() - init_start_time_); | 923 base::TimeTicks::Now() - init_start_time_); |
| 914 } | 924 } |
| 915 | 925 |
| 916 void GpuProcessHost::OnProcessLaunchFailed(int error_code) { | 926 void GpuProcessHost::OnProcessLaunchFailed(int error_code) { |
| 917 // TODO(wfh): do something more useful with this error code. | 927 // TODO(wfh): do something more useful with this error code. |
| 918 RecordProcessCrash(); | 928 RecordProcessCrash(); |
| 919 } | 929 } |
| 920 | 930 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1182 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1173 ClientIdToShaderCacheMap::iterator iter = | 1183 ClientIdToShaderCacheMap::iterator iter = |
| 1174 client_id_to_shader_cache_.find(client_id); | 1184 client_id_to_shader_cache_.find(client_id); |
| 1175 // If the cache doesn't exist then this is an off the record profile. | 1185 // If the cache doesn't exist then this is an off the record profile. |
| 1176 if (iter == client_id_to_shader_cache_.end()) | 1186 if (iter == client_id_to_shader_cache_.end()) |
| 1177 return; | 1187 return; |
| 1178 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1188 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1179 } | 1189 } |
| 1180 | 1190 |
| 1181 } // namespace content | 1191 } // namespace content |
| OLD | NEW |