| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/base64.h" | 13 #include "base/base64.h" |
| 14 #include "base/base_switches.h" | 14 #include "base/base_switches.h" |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/callback_helpers.h" | 16 #include "base/callback_helpers.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/files/file_util.h" | |
| 19 #include "base/logging.h" | 18 #include "base/logging.h" |
| 20 #include "base/macros.h" | 19 #include "base/macros.h" |
| 21 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 22 #include "base/metrics/field_trial.h" | 21 #include "base/metrics/field_trial.h" |
| 23 #include "base/metrics/histogram_macros.h" | 22 #include "base/metrics/histogram_macros.h" |
| 24 #include "base/sha1.h" | 23 #include "base/sha1.h" |
| 25 #include "base/threading/thread.h" | 24 #include "base/threading/thread.h" |
| 26 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
| 27 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 28 #include "components/tracing/common/tracing_switches.h" | 27 #include "components/tracing/common/tracing_switches.h" |
| 29 #include "content/browser/browser_child_process_host_impl.h" | 28 #include "content/browser/browser_child_process_host_impl.h" |
| 30 #include "content/browser/gpu/compositor_util.h" | 29 #include "content/browser/gpu/compositor_util.h" |
| 31 #include "content/browser/gpu/gpu_data_manager_impl.h" | 30 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 32 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 31 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 33 #include "content/browser/gpu/shader_disk_cache.h" | 32 #include "content/browser/gpu/shader_disk_cache.h" |
| 34 #include "content/browser/mojo/mojo_application_host.h" | 33 #include "content/browser/mojo/mojo_application_host.h" |
| 35 #include "content/browser/renderer_host/render_widget_host_impl.h" | 34 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 36 #include "content/common/child_process_host_impl.h" | 35 #include "content/common/child_process_host_impl.h" |
| 37 #include "content/common/establish_channel_params.h" | 36 #include "content/common/establish_channel_params.h" |
| 38 #include "content/common/gpu_host_messages.h" | 37 #include "content/common/gpu_host_messages.h" |
| 39 #include "content/common/gpu_watchdog_utils.h" | |
| 40 #include "content/common/in_process_child_thread_params.h" | 38 #include "content/common/in_process_child_thread_params.h" |
| 41 #include "content/common/view_messages.h" | 39 #include "content/common/view_messages.h" |
| 42 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
| 43 #include "content/public/browser/content_browser_client.h" | 41 #include "content/public/browser/content_browser_client.h" |
| 44 #include "content/public/browser/gpu_utils.h" | 42 #include "content/public/browser/gpu_utils.h" |
| 45 #include "content/public/browser/render_process_host.h" | 43 #include "content/public/browser/render_process_host.h" |
| 46 #include "content/public/browser/render_widget_host_view.h" | 44 #include "content/public/browser/render_widget_host_view.h" |
| 47 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 45 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 48 #include "content/public/common/content_client.h" | 46 #include "content/public/common/content_client.h" |
| 49 #include "content/public/common/content_switches.h" | 47 #include "content/public/common/content_switches.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 base::string16 log_file_path = logging::GetLogFileFullPath(); | 257 base::string16 log_file_path = logging::GetLogFileFullPath(); |
| 260 if (!log_file_path.empty()) { | 258 if (!log_file_path.empty()) { |
| 261 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, | 259 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, |
| 262 sandbox::TargetPolicy::FILES_ALLOW_ANY, | 260 sandbox::TargetPolicy::FILES_ALLOW_ANY, |
| 263 log_file_path.c_str()); | 261 log_file_path.c_str()); |
| 264 if (result != sandbox::SBOX_ALL_OK) | 262 if (result != sandbox::SBOX_ALL_OK) |
| 265 return false; | 263 return false; |
| 266 } | 264 } |
| 267 } | 265 } |
| 268 | 266 |
| 269 // Enable GPU watchdog to write to a temp file to delay crashing when | |
| 270 // there is a high I/O activitiy. | |
| 271 base::FilePath temp_file_path; | |
| 272 if (content::GetGpuWatchdogTempFile(&temp_file_path)) { | |
| 273 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, | |
| 274 sandbox::TargetPolicy::FILES_ALLOW_ANY, | |
| 275 temp_file_path.value().c_str()); | |
| 276 if (result != sandbox::SBOX_ALL_OK) | |
| 277 return false; | |
| 278 } | |
| 279 | |
| 280 return true; | 267 return true; |
| 281 } | 268 } |
| 282 #elif defined(OS_POSIX) | 269 #elif defined(OS_POSIX) |
| 283 | 270 |
| 284 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } | 271 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } |
| 285 #endif // OS_WIN | 272 #endif // OS_WIN |
| 286 | 273 |
| 287 SandboxType GetSandboxType() override { | 274 SandboxType GetSandboxType() override { |
| 288 return SANDBOX_TYPE_GPU; | 275 return SANDBOX_TYPE_GPU; |
| 289 } | 276 } |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1191 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1205 ClientIdToShaderCacheMap::iterator iter = | 1192 ClientIdToShaderCacheMap::iterator iter = |
| 1206 client_id_to_shader_cache_.find(client_id); | 1193 client_id_to_shader_cache_.find(client_id); |
| 1207 // If the cache doesn't exist then this is an off the record profile. | 1194 // If the cache doesn't exist then this is an off the record profile. |
| 1208 if (iter == client_id_to_shader_cache_.end()) | 1195 if (iter == client_id_to_shader_cache_.end()) |
| 1209 return; | 1196 return; |
| 1210 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1197 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1211 } | 1198 } |
| 1212 | 1199 |
| 1213 } // namespace content | 1200 } // namespace content |
| OLD | NEW |