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 20 matching lines...) Expand all Loading... |
31 #include "content/browser/browser_main_loop.h" | 31 #include "content/browser/browser_main_loop.h" |
32 #include "content/browser/gpu/compositor_util.h" | 32 #include "content/browser/gpu/compositor_util.h" |
33 #include "content/browser/gpu/gpu_data_manager_impl.h" | 33 #include "content/browser/gpu/gpu_data_manager_impl.h" |
34 #include "content/browser/gpu/gpu_main_thread_factory.h" | 34 #include "content/browser/gpu/gpu_main_thread_factory.h" |
35 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 35 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
36 #include "content/browser/gpu/shader_cache_factory.h" | 36 #include "content/browser/gpu/shader_cache_factory.h" |
37 #include "content/browser/renderer_host/render_widget_host_impl.h" | 37 #include "content/browser/renderer_host/render_widget_host_impl.h" |
38 #include "content/browser/renderer_host/render_widget_host_view_frame_subscriber
.h" | 38 #include "content/browser/renderer_host/render_widget_host_view_frame_subscriber
.h" |
39 #include "content/browser/service_manager/service_manager_context.h" | 39 #include "content/browser/service_manager/service_manager_context.h" |
40 #include "content/common/child_process_host_impl.h" | 40 #include "content/common/child_process_host_impl.h" |
41 #include "content/common/gpu_host_messages.h" | |
42 #include "content/common/in_process_child_thread_params.h" | 41 #include "content/common/in_process_child_thread_params.h" |
43 #include "content/common/service_manager/child_connection.h" | 42 #include "content/common/service_manager/child_connection.h" |
44 #include "content/common/view_messages.h" | 43 #include "content/common/view_messages.h" |
45 #include "content/public/browser/browser_thread.h" | 44 #include "content/public/browser/browser_thread.h" |
46 #include "content/public/browser/content_browser_client.h" | 45 #include "content/public/browser/content_browser_client.h" |
47 #include "content/public/browser/gpu_utils.h" | 46 #include "content/public/browser/gpu_utils.h" |
48 #include "content/public/browser/render_process_host.h" | 47 #include "content/public/browser/render_process_host.h" |
49 #include "content/public/browser/render_widget_host_view.h" | 48 #include "content/public/browser/render_widget_host_view.h" |
50 #include "content/public/common/connection_filter.h" | 49 #include "content/public/common/connection_filter.h" |
51 #include "content/public/common/content_client.h" | 50 #include "content/public/common/content_client.h" |
52 #include "content/public/common/content_switches.h" | 51 #include "content/public/common/content_switches.h" |
53 #include "content/public/common/mojo_channel_switches.h" | 52 #include "content/public/common/mojo_channel_switches.h" |
54 #include "content/public/common/result_codes.h" | 53 #include "content/public/common/result_codes.h" |
55 #include "content/public/common/sandbox_type.h" | 54 #include "content/public/common/sandbox_type.h" |
56 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 55 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
57 #include "content/public/common/service_manager_connection.h" | 56 #include "content/public/common/service_manager_connection.h" |
58 #include "content/public/common/service_names.mojom.h" | 57 #include "content/public/common/service_names.mojom.h" |
59 #include "gpu/command_buffer/service/gpu_preferences.h" | 58 #include "gpu/command_buffer/service/gpu_preferences.h" |
60 #include "gpu/command_buffer/service/gpu_switches.h" | 59 #include "gpu/command_buffer/service/gpu_switches.h" |
61 #include "gpu/config/gpu_driver_bug_list.h" | 60 #include "gpu/config/gpu_driver_bug_list.h" |
62 #include "gpu/ipc/host/shader_disk_cache.h" | 61 #include "gpu/ipc/host/shader_disk_cache.h" |
63 #include "gpu/ipc/service/switches.h" | 62 #include "gpu/ipc/service/switches.h" |
64 #include "ipc/ipc_channel_handle.h" | 63 #include "ipc/ipc_channel_handle.h" |
65 #include "ipc/message_filter.h" | 64 #include "ipc/message_filter.h" |
66 #include "media/base/media_switches.h" | 65 #include "media/base/media_switches.h" |
67 #include "media/media_features.h" | 66 #include "media/media_features.h" |
68 #include "mojo/edk/embedder/embedder.h" | 67 #include "mojo/edk/embedder/embedder.h" |
69 #include "services/resource_coordinator/memory/coordinator/coordinator_impl.h" | |
70 #include "services/service_manager/public/cpp/binder_registry.h" | 68 #include "services/service_manager/public/cpp/binder_registry.h" |
71 #include "services/service_manager/public/cpp/connection.h" | 69 #include "services/service_manager/public/cpp/connection.h" |
72 #include "services/service_manager/public/cpp/interface_provider.h" | 70 #include "services/service_manager/public/cpp/interface_provider.h" |
73 #include "services/service_manager/runner/common/client_util.h" | 71 #include "services/service_manager/runner/common/client_util.h" |
74 #include "ui/display/display_switches.h" | 72 #include "ui/display/display_switches.h" |
75 #include "ui/gfx/switches.h" | 73 #include "ui/gfx/switches.h" |
76 #include "ui/gl/gl_switches.h" | 74 #include "ui/gl/gl_switches.h" |
77 #include "ui/latency/latency_info.h" | 75 #include "ui/latency/latency_info.h" |
78 | 76 |
79 #if defined(OS_ANDROID) | 77 #if defined(OS_ANDROID) |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 317 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
320 if (host) | 318 if (host) |
321 host->LoadedShader(key, data); | 319 host->LoadedShader(key, data); |
322 } | 320 } |
323 | 321 |
324 } // anonymous namespace | 322 } // anonymous namespace |
325 | 323 |
326 class GpuProcessHost::ConnectionFilterImpl : public ConnectionFilter { | 324 class GpuProcessHost::ConnectionFilterImpl : public ConnectionFilter { |
327 public: | 325 public: |
328 ConnectionFilterImpl() { | 326 ConnectionFilterImpl() { |
329 registry_.AddInterface( | |
330 base::Bind( | |
331 &memory_instrumentation::CoordinatorImpl::BindCoordinatorRequest, | |
332 base::Unretained( | |
333 memory_instrumentation::CoordinatorImpl::GetInstance())), | |
334 content::BrowserThread::GetTaskRunnerForThread( | |
335 content::BrowserThread::UI)); | |
336 #if defined(OS_ANDROID) | |
337 GpuProcessHostUIShim::RegisterUIThreadMojoInterfaces(®istry_); | 327 GpuProcessHostUIShim::RegisterUIThreadMojoInterfaces(®istry_); |
338 #endif | |
339 } | 328 } |
340 | 329 |
341 private: | 330 private: |
342 // ConnectionFilter: | 331 // ConnectionFilter: |
343 void OnBindInterface(const service_manager::ServiceInfo& source_info, | 332 void OnBindInterface(const service_manager::ServiceInfo& source_info, |
344 const std::string& interface_name, | 333 const std::string& interface_name, |
345 mojo::ScopedMessagePipeHandle* interface_pipe, | 334 mojo::ScopedMessagePipeHandle* interface_pipe, |
346 service_manager::Connector* connector) override { | 335 service_manager::Connector* connector) override { |
347 if (registry_.CanBindInterface(interface_name)) { | 336 if (registry_.CanBindInterface(interface_name)) { |
348 registry_.BindInterface(source_info.identity, interface_name, | 337 registry_.BindInterface(source_info.identity, interface_name, |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 return result; | 662 return result; |
674 } | 663 } |
675 | 664 |
676 void GpuProcessHost::AddFilter(IPC::MessageFilter* filter) { | 665 void GpuProcessHost::AddFilter(IPC::MessageFilter* filter) { |
677 DCHECK(CalledOnValidThread()); | 666 DCHECK(CalledOnValidThread()); |
678 process_->GetHost()->AddFilter(filter); | 667 process_->GetHost()->AddFilter(filter); |
679 } | 668 } |
680 | 669 |
681 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { | 670 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
682 DCHECK(CalledOnValidThread()); | 671 DCHECK(CalledOnValidThread()); |
683 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 672 RouteOnUIThread(message); |
684 IPC_MESSAGE_HANDLER(GpuHostMsg_FieldTrialActivated, OnFieldTrialActivated); | |
685 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | |
686 IPC_END_MESSAGE_MAP() | |
687 | |
688 return true; | 673 return true; |
689 } | 674 } |
690 | 675 |
691 void GpuProcessHost::OnChannelConnected(int32_t peer_pid) { | 676 void GpuProcessHost::OnChannelConnected(int32_t peer_pid) { |
692 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); | 677 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelConnected"); |
693 | 678 |
694 while (!queued_messages_.empty()) { | 679 while (!queued_messages_.empty()) { |
695 Send(queued_messages_.front()); | 680 Send(queued_messages_.front()); |
696 queued_messages_.pop(); | 681 queued_messages_.pop(); |
697 } | 682 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 } | 787 } |
803 | 788 |
804 #if defined(OS_ANDROID) | 789 #if defined(OS_ANDROID) |
805 void GpuProcessHost::OnDestroyingVideoSurfaceAck() { | 790 void GpuProcessHost::OnDestroyingVideoSurfaceAck() { |
806 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck"); | 791 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck"); |
807 if (!send_destroying_video_surface_done_cb_.is_null()) | 792 if (!send_destroying_video_surface_done_cb_.is_null()) |
808 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); | 793 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); |
809 } | 794 } |
810 #endif | 795 #endif |
811 | 796 |
812 void GpuProcessHost::OnFieldTrialActivated(const std::string& trial_name) { | |
813 // Activate the trial in the browser process to match its state in the | |
814 // GPU process. This is done by calling FindFullName which finalizes the group | |
815 // and activates the trial. | |
816 base::FieldTrialList::FindFullName(trial_name); | |
817 } | |
818 | |
819 void GpuProcessHost::OnProcessLaunched() { | 797 void GpuProcessHost::OnProcessLaunched() { |
820 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", | 798 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", |
821 base::TimeTicks::Now() - init_start_time_); | 799 base::TimeTicks::Now() - init_start_time_); |
822 } | 800 } |
823 | 801 |
824 void GpuProcessHost::OnProcessLaunchFailed(int error_code) { | 802 void GpuProcessHost::OnProcessLaunchFailed(int error_code) { |
825 // TODO(wfh): do something more useful with this error code. | 803 // TODO(wfh): do something more useful with this error code. |
826 RecordProcessCrash(); | 804 RecordProcessCrash(); |
827 } | 805 } |
828 | 806 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 GetShaderCacheFactorySingleton()->Get(client_id); | 1192 GetShaderCacheFactorySingleton()->Get(client_id); |
1215 if (!cache.get()) | 1193 if (!cache.get()) |
1216 return; | 1194 return; |
1217 | 1195 |
1218 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_)); | 1196 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_)); |
1219 | 1197 |
1220 client_id_to_shader_cache_[client_id] = cache; | 1198 client_id_to_shader_cache_[client_id] = cache; |
1221 } | 1199 } |
1222 | 1200 |
1223 } // namespace content | 1201 } // namespace content |
OLD | NEW |