| 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 13 matching lines...) Expand all Loading... |
| 24 #include "base/threading/thread.h" | 24 #include "base/threading/thread.h" |
| 25 #include "base/threading/thread_task_runner_handle.h" | 25 #include "base/threading/thread_task_runner_handle.h" |
| 26 #include "base/trace_event/trace_event.h" | 26 #include "base/trace_event/trace_event.h" |
| 27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 28 #include "components/tracing/common/tracing_switches.h" | 28 #include "components/tracing/common/tracing_switches.h" |
| 29 #include "content/browser/browser_child_process_host_impl.h" | 29 #include "content/browser/browser_child_process_host_impl.h" |
| 30 #include "content/browser/gpu/compositor_util.h" | 30 #include "content/browser/gpu/compositor_util.h" |
| 31 #include "content/browser/gpu/gpu_data_manager_impl.h" | 31 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 32 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 32 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 33 #include "content/browser/gpu/shader_disk_cache.h" | 33 #include "content/browser/gpu/shader_disk_cache.h" |
| 34 #include "content/browser/mojo/mojo_application_host.h" | 34 #include "content/browser/mojo/constants.h" |
| 35 #include "content/browser/mojo/mojo_child_connection.h" |
| 36 #include "content/browser/mojo/mojo_shell_context.h" |
| 35 #include "content/browser/renderer_host/render_widget_host_impl.h" | 37 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 36 #include "content/common/child_process_host_impl.h" | 38 #include "content/common/child_process_host_impl.h" |
| 37 #include "content/common/establish_channel_params.h" | 39 #include "content/common/establish_channel_params.h" |
| 38 #include "content/common/gpu_host_messages.h" | 40 #include "content/common/gpu_host_messages.h" |
| 39 #include "content/common/in_process_child_thread_params.h" | 41 #include "content/common/in_process_child_thread_params.h" |
| 40 #include "content/common/view_messages.h" | 42 #include "content/common/view_messages.h" |
| 41 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
| 42 #include "content/public/browser/content_browser_client.h" | 44 #include "content/public/browser/content_browser_client.h" |
| 43 #include "content/public/browser/gpu_utils.h" | 45 #include "content/public/browser/gpu_utils.h" |
| 44 #include "content/public/browser/render_process_host.h" | 46 #include "content/public/browser/render_process_host.h" |
| 45 #include "content/public/browser/render_widget_host_view.h" | 47 #include "content/public/browser/render_widget_host_view.h" |
| 46 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 48 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 47 #include "content/public/common/content_client.h" | 49 #include "content/public/common/content_client.h" |
| 48 #include "content/public/common/content_switches.h" | 50 #include "content/public/common/content_switches.h" |
| 49 #include "content/public/common/mojo_channel_switches.h" | 51 #include "content/public/common/mojo_channel_switches.h" |
| 52 #include "content/public/common/mojo_shell_connection.h" |
| 50 #include "content/public/common/result_codes.h" | 53 #include "content/public/common/result_codes.h" |
| 51 #include "content/public/common/sandbox_type.h" | 54 #include "content/public/common/sandbox_type.h" |
| 52 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 55 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 53 #include "gpu/command_buffer/service/gpu_preferences.h" | 56 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 54 #include "gpu/command_buffer/service/gpu_switches.h" | 57 #include "gpu/command_buffer/service/gpu_switches.h" |
| 55 #include "ipc/ipc_channel_handle.h" | 58 #include "ipc/ipc_channel_handle.h" |
| 56 #include "ipc/ipc_switches.h" | 59 #include "ipc/ipc_switches.h" |
| 57 #include "ipc/message_filter.h" | 60 #include "ipc/message_filter.h" |
| 58 #include "media/base/media_switches.h" | 61 #include "media/base/media_switches.h" |
| 59 #include "mojo/edk/embedder/embedder.h" | 62 #include "mojo/edk/embedder/embedder.h" |
| 63 #include "services/shell/public/cpp/connection.h" |
| 60 #include "services/shell/public/cpp/interface_provider.h" | 64 #include "services/shell/public/cpp/interface_provider.h" |
| 61 #include "services/shell/public/cpp/interface_registry.h" | 65 #include "services/shell/public/cpp/interface_registry.h" |
| 62 #include "ui/base/ui_base_switches.h" | 66 #include "ui/base/ui_base_switches.h" |
| 63 #include "ui/events/latency_info.h" | 67 #include "ui/events/latency_info.h" |
| 64 #include "ui/gl/gl_switches.h" | 68 #include "ui/gl/gl_switches.h" |
| 65 | 69 |
| 66 #if defined(OS_ANDROID) | 70 #if defined(OS_ANDROID) |
| 67 #include "base/android/build_info.h" | 71 #include "base/android/build_info.h" |
| 68 #endif | 72 #endif |
| 69 | 73 |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 549 |
| 546 bool GpuProcessHost::Init() { | 550 bool GpuProcessHost::Init() { |
| 547 init_start_time_ = base::TimeTicks::Now(); | 551 init_start_time_ = base::TimeTicks::Now(); |
| 548 | 552 |
| 549 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD); | 553 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD); |
| 550 | 554 |
| 551 std::string channel_id = process_->GetHost()->CreateChannel(); | 555 std::string channel_id = process_->GetHost()->CreateChannel(); |
| 552 if (channel_id.empty()) | 556 if (channel_id.empty()) |
| 553 return false; | 557 return false; |
| 554 | 558 |
| 555 DCHECK(!mojo_application_host_); | 559 DCHECK(!mojo_child_connection_); |
| 556 mojo_application_host_.reset(new MojoApplicationHost(child_token_)); | 560 mojo_child_connection_.reset(new MojoChildConnection( |
| 561 kGpuMojoApplicationName, |
| 562 "", |
| 563 child_token_, |
| 564 MojoShellContext::GetConnectorForIOThread())); |
| 557 | 565 |
| 558 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); | 566 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); |
| 559 if (in_process_) { | 567 if (in_process_) { |
| 560 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 568 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 561 DCHECK(g_gpu_main_thread_factory); | 569 DCHECK(g_gpu_main_thread_factory); |
| 562 in_process_gpu_thread_.reset(g_gpu_main_thread_factory( | 570 in_process_gpu_thread_.reset(g_gpu_main_thread_factory( |
| 563 InProcessChildThreadParams( | 571 InProcessChildThreadParams( |
| 564 channel_id, base::ThreadTaskRunnerHandle::Get(), std::string(), | 572 channel_id, base::ThreadTaskRunnerHandle::Get(), std::string(), |
| 565 mojo_application_host_->GetToken()), | 573 mojo_child_connection_->shell_client_token()), |
| 566 gpu_preferences)); | 574 gpu_preferences)); |
| 567 base::Thread::Options options; | 575 base::Thread::Options options; |
| 568 #if defined(OS_WIN) | 576 #if defined(OS_WIN) |
| 569 // WGL needs to create its own window and pump messages on it. | 577 // WGL needs to create its own window and pump messages on it. |
| 570 options.message_loop_type = base::MessageLoop::TYPE_UI; | 578 options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 571 #endif | 579 #endif |
| 572 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 580 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 573 options.priority = base::ThreadPriority::DISPLAY; | 581 options.priority = base::ThreadPriority::DISPLAY; |
| 574 #endif | 582 #endif |
| 575 in_process_gpu_thread_->StartWithOptions(options); | 583 in_process_gpu_thread_->StartWithOptions(options); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 } | 925 } |
| 918 | 926 |
| 919 void GpuProcessHost::OnProcessCrashed(int exit_code) { | 927 void GpuProcessHost::OnProcessCrashed(int exit_code) { |
| 920 SendOutstandingReplies(); | 928 SendOutstandingReplies(); |
| 921 RecordProcessCrash(); | 929 RecordProcessCrash(); |
| 922 GpuDataManagerImpl::GetInstance()->ProcessCrashed( | 930 GpuDataManagerImpl::GetInstance()->ProcessCrashed( |
| 923 process_->GetTerminationStatus(true /* known_dead */, NULL)); | 931 process_->GetTerminationStatus(true /* known_dead */, NULL)); |
| 924 } | 932 } |
| 925 | 933 |
| 926 shell::InterfaceRegistry* GpuProcessHost::GetInterfaceRegistry() { | 934 shell::InterfaceRegistry* GpuProcessHost::GetInterfaceRegistry() { |
| 927 return mojo_application_host_->interface_registry(); | 935 return mojo_child_connection_->connection()->GetInterfaceRegistry(); |
| 928 } | 936 } |
| 929 | 937 |
| 930 shell::InterfaceProvider* GpuProcessHost::GetRemoteInterfaces() { | 938 shell::InterfaceProvider* GpuProcessHost::GetRemoteInterfaces() { |
| 931 return mojo_application_host_->remote_interfaces(); | 939 return mojo_child_connection_->connection()->GetRemoteInterfaces(); |
| 932 } | 940 } |
| 933 | 941 |
| 934 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { | 942 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { |
| 935 return kind_; | 943 return kind_; |
| 936 } | 944 } |
| 937 | 945 |
| 938 void GpuProcessHost::ForceShutdown() { | 946 void GpuProcessHost::ForceShutdown() { |
| 939 // This is only called on the IO thread so no race against the constructor | 947 // This is only called on the IO thread so no race against the constructor |
| 940 // for another GpuProcessHost. | 948 // for another GpuProcessHost. |
| 941 if (g_gpu_process_hosts[kind_] == this) | 949 if (g_gpu_process_hosts[kind_] == this) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 | 987 |
| 980 base::FilePath exe_path = ChildProcessHost::GetChildPath(child_flags); | 988 base::FilePath exe_path = ChildProcessHost::GetChildPath(child_flags); |
| 981 if (exe_path.empty()) | 989 if (exe_path.empty()) |
| 982 return false; | 990 return false; |
| 983 | 991 |
| 984 base::CommandLine* cmd_line = new base::CommandLine(exe_path); | 992 base::CommandLine* cmd_line = new base::CommandLine(exe_path); |
| 985 #endif | 993 #endif |
| 986 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kGpuProcess); | 994 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kGpuProcess); |
| 987 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 995 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
| 988 cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, | 996 cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, |
| 989 mojo_application_host_->GetToken()); | 997 mojo_child_connection_->shell_client_token()); |
| 990 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(cmd_line); | 998 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(cmd_line); |
| 991 | 999 |
| 992 #if defined(OS_WIN) | 1000 #if defined(OS_WIN) |
| 993 cmd_line->AppendArg(switches::kPrefetchArgumentGpu); | 1001 cmd_line->AppendArg(switches::kPrefetchArgumentGpu); |
| 994 #endif // defined(OS_WIN) | 1002 #endif // defined(OS_WIN) |
| 995 | 1003 |
| 996 if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED) | 1004 if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED) |
| 997 cmd_line->AppendSwitch(switches::kDisableGpuSandbox); | 1005 cmd_line->AppendSwitch(switches::kDisableGpuSandbox); |
| 998 | 1006 |
| 999 // TODO(penghuang): Replace all GPU related switches with GpuPreferences. | 1007 // TODO(penghuang): Replace all GPU related switches with GpuPreferences. |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1181 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1174 ClientIdToShaderCacheMap::iterator iter = | 1182 ClientIdToShaderCacheMap::iterator iter = |
| 1175 client_id_to_shader_cache_.find(client_id); | 1183 client_id_to_shader_cache_.find(client_id); |
| 1176 // If the cache doesn't exist then this is an off the record profile. | 1184 // If the cache doesn't exist then this is an off the record profile. |
| 1177 if (iter == client_id_to_shader_cache_.end()) | 1185 if (iter == client_id_to_shader_cache_.end()) |
| 1178 return; | 1186 return; |
| 1179 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1187 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1180 } | 1188 } |
| 1181 | 1189 |
| 1182 } // namespace content | 1190 } // namespace content |
| OLD | NEW |