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" |
| 64 #include "services/shell/public/cpp/interface_provider.h" |
| 65 #include "services/shell/public/cpp/interface_registry.h" |
60 #include "ui/base/ui_base_switches.h" | 66 #include "ui/base/ui_base_switches.h" |
61 #include "ui/events/latency_info.h" | 67 #include "ui/events/latency_info.h" |
62 #include "ui/gl/gl_switches.h" | 68 #include "ui/gl/gl_switches.h" |
63 | 69 |
64 #if defined(OS_ANDROID) | 70 #if defined(OS_ANDROID) |
65 #include "base/android/build_info.h" | 71 #include "base/android/build_info.h" |
66 #endif | 72 #endif |
67 | 73 |
68 #if defined(OS_WIN) | 74 #if defined(OS_WIN) |
69 #include "base/win/windows_version.h" | 75 #include "base/win/windows_version.h" |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 549 |
544 bool GpuProcessHost::Init() { | 550 bool GpuProcessHost::Init() { |
545 init_start_time_ = base::TimeTicks::Now(); | 551 init_start_time_ = base::TimeTicks::Now(); |
546 | 552 |
547 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD); | 553 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD); |
548 | 554 |
549 std::string channel_id = process_->GetHost()->CreateChannel(); | 555 std::string channel_id = process_->GetHost()->CreateChannel(); |
550 if (channel_id.empty()) | 556 if (channel_id.empty()) |
551 return false; | 557 return false; |
552 | 558 |
553 DCHECK(!mojo_application_host_); | 559 DCHECK(!mojo_child_connection_); |
554 mojo_application_host_.reset(new MojoApplicationHost(child_token_)); | 560 mojo_child_connection_.reset(new MojoChildConnection( |
| 561 kGpuMojoApplicationName, |
| 562 "", |
| 563 child_token_, |
| 564 MojoShellContext::GetConnectorForIOThread())); |
555 | 565 |
556 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); | 566 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); |
557 if (in_process_) { | 567 if (in_process_) { |
558 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 568 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
559 DCHECK(g_gpu_main_thread_factory); | 569 DCHECK(g_gpu_main_thread_factory); |
560 in_process_gpu_thread_.reset(g_gpu_main_thread_factory( | 570 in_process_gpu_thread_.reset(g_gpu_main_thread_factory( |
561 InProcessChildThreadParams( | 571 InProcessChildThreadParams( |
562 channel_id, base::ThreadTaskRunnerHandle::Get(), std::string(), | 572 channel_id, base::ThreadTaskRunnerHandle::Get(), std::string(), |
563 mojo_application_host_->GetToken()), | 573 mojo_child_connection_->shell_client_token()), |
564 gpu_preferences)); | 574 gpu_preferences)); |
565 base::Thread::Options options; | 575 base::Thread::Options options; |
566 #if defined(OS_WIN) | 576 #if defined(OS_WIN) |
567 // 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. |
568 options.message_loop_type = base::MessageLoop::TYPE_UI; | 578 options.message_loop_type = base::MessageLoop::TYPE_UI; |
569 #endif | 579 #endif |
570 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 580 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
571 options.priority = base::ThreadPriority::DISPLAY; | 581 options.priority = base::ThreadPriority::DISPLAY; |
572 #endif | 582 #endif |
573 in_process_gpu_thread_->StartWithOptions(options); | 583 in_process_gpu_thread_->StartWithOptions(options); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 RecordProcessCrash(); | 948 RecordProcessCrash(); |
939 } | 949 } |
940 | 950 |
941 void GpuProcessHost::OnProcessCrashed(int exit_code) { | 951 void GpuProcessHost::OnProcessCrashed(int exit_code) { |
942 SendOutstandingReplies(); | 952 SendOutstandingReplies(); |
943 RecordProcessCrash(); | 953 RecordProcessCrash(); |
944 GpuDataManagerImpl::GetInstance()->ProcessCrashed( | 954 GpuDataManagerImpl::GetInstance()->ProcessCrashed( |
945 process_->GetTerminationStatus(true /* known_dead */, NULL)); | 955 process_->GetTerminationStatus(true /* known_dead */, NULL)); |
946 } | 956 } |
947 | 957 |
948 ServiceRegistry* GpuProcessHost::GetServiceRegistry() { | 958 shell::InterfaceRegistry* GpuProcessHost::GetInterfaceRegistry() { |
949 return mojo_application_host_->service_registry(); | 959 return mojo_child_connection_->connection()->GetInterfaceRegistry(); |
| 960 } |
| 961 |
| 962 shell::InterfaceProvider* GpuProcessHost::GetRemoteInterfaces() { |
| 963 return mojo_child_connection_->connection()->GetRemoteInterfaces(); |
950 } | 964 } |
951 | 965 |
952 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { | 966 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { |
953 return kind_; | 967 return kind_; |
954 } | 968 } |
955 | 969 |
956 void GpuProcessHost::ForceShutdown() { | 970 void GpuProcessHost::ForceShutdown() { |
957 // This is only called on the IO thread so no race against the constructor | 971 // This is only called on the IO thread so no race against the constructor |
958 // for another GpuProcessHost. | 972 // for another GpuProcessHost. |
959 if (g_gpu_process_hosts[kind_] == this) | 973 if (g_gpu_process_hosts[kind_] == this) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 | 1011 |
998 base::FilePath exe_path = ChildProcessHost::GetChildPath(child_flags); | 1012 base::FilePath exe_path = ChildProcessHost::GetChildPath(child_flags); |
999 if (exe_path.empty()) | 1013 if (exe_path.empty()) |
1000 return false; | 1014 return false; |
1001 | 1015 |
1002 base::CommandLine* cmd_line = new base::CommandLine(exe_path); | 1016 base::CommandLine* cmd_line = new base::CommandLine(exe_path); |
1003 #endif | 1017 #endif |
1004 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kGpuProcess); | 1018 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kGpuProcess); |
1005 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 1019 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
1006 cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, | 1020 cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, |
1007 mojo_application_host_->GetToken()); | 1021 mojo_child_connection_->shell_client_token()); |
1008 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(cmd_line); | 1022 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(cmd_line); |
1009 | 1023 |
1010 #if defined(OS_WIN) | 1024 #if defined(OS_WIN) |
1011 cmd_line->AppendArg(switches::kPrefetchArgumentGpu); | 1025 cmd_line->AppendArg(switches::kPrefetchArgumentGpu); |
1012 #endif // defined(OS_WIN) | 1026 #endif // defined(OS_WIN) |
1013 | 1027 |
1014 if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED) | 1028 if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED) |
1015 cmd_line->AppendSwitch(switches::kDisableGpuSandbox); | 1029 cmd_line->AppendSwitch(switches::kDisableGpuSandbox); |
1016 | 1030 |
1017 // TODO(penghuang): Replace all GPU related switches with GpuPreferences. | 1031 // TODO(penghuang): Replace all GPU related switches with GpuPreferences. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1205 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1192 ClientIdToShaderCacheMap::iterator iter = | 1206 ClientIdToShaderCacheMap::iterator iter = |
1193 client_id_to_shader_cache_.find(client_id); | 1207 client_id_to_shader_cache_.find(client_id); |
1194 // If the cache doesn't exist then this is an off the record profile. | 1208 // If the cache doesn't exist then this is an off the record profile. |
1195 if (iter == client_id_to_shader_cache_.end()) | 1209 if (iter == client_id_to_shader_cache_.end()) |
1196 return; | 1210 return; |
1197 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1211 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1198 } | 1212 } |
1199 | 1213 |
1200 } // namespace content | 1214 } // namespace content |
OLD | NEW |