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/gpu/compositor_util.h" | 31 #include "content/browser/gpu/compositor_util.h" |
32 #include "content/browser/gpu/gpu_data_manager_impl.h" | 32 #include "content/browser/gpu/gpu_data_manager_impl.h" |
33 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 33 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
34 #include "content/browser/gpu/shader_disk_cache.h" | 34 #include "content/browser/gpu/shader_disk_cache.h" |
35 #include "content/browser/renderer_host/render_widget_host_impl.h" | 35 #include "content/browser/renderer_host/render_widget_host_impl.h" |
36 #include "content/browser/service_manager/service_manager_context.h" | 36 #include "content/browser/service_manager/service_manager_context.h" |
37 #include "content/common/child_process_host_impl.h" | 37 #include "content/common/child_process_host_impl.h" |
38 #include "content/common/establish_channel_params.h" | 38 #include "content/common/establish_channel_params.h" |
39 #include "content/common/gpu_host_messages.h" | 39 #include "content/common/gpu_host_messages.h" |
40 #include "content/common/in_process_child_thread_params.h" | 40 #include "content/common/in_process_child_thread_params.h" |
41 #include "content/common/mojo/mojo_child_connection.h" | 41 #include "content/common/service_manager/child_connection.h" |
42 #include "content/common/view_messages.h" | 42 #include "content/common/view_messages.h" |
43 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
44 #include "content/public/browser/content_browser_client.h" | 44 #include "content/public/browser/content_browser_client.h" |
45 #include "content/public/browser/gpu_utils.h" | 45 #include "content/public/browser/gpu_utils.h" |
46 #include "content/public/browser/render_process_host.h" | 46 #include "content/public/browser/render_process_host.h" |
47 #include "content/public/browser/render_widget_host_view.h" | 47 #include "content/public/browser/render_widget_host_view.h" |
48 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 48 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
49 #include "content/public/common/connection_filter.h" | 49 #include "content/public/common/connection_filter.h" |
50 #include "content/public/common/content_client.h" | 50 #include "content/public/common/content_client.h" |
51 #include "content/public/common/content_switches.h" | 51 #include "content/public/common/content_switches.h" |
52 #include "content/public/common/mojo_channel_switches.h" | 52 #include "content/public/common/mojo_channel_switches.h" |
53 #include "content/public/common/mojo_shell_connection.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" |
| 56 #include "content/public/common/service_manager_connection.h" |
57 #include "content/public/common/service_names.h" | 57 #include "content/public/common/service_names.h" |
58 #include "gpu/command_buffer/service/gpu_preferences.h" | 58 #include "gpu/command_buffer/service/gpu_preferences.h" |
59 #include "gpu/command_buffer/service/gpu_switches.h" | 59 #include "gpu/command_buffer/service/gpu_switches.h" |
60 #include "gpu/ipc/service/switches.h" | 60 #include "gpu/ipc/service/switches.h" |
61 #include "ipc/ipc_channel_handle.h" | 61 #include "ipc/ipc_channel_handle.h" |
62 #include "ipc/message_filter.h" | 62 #include "ipc/message_filter.h" |
63 #include "media/base/media_switches.h" | 63 #include "media/base/media_switches.h" |
64 #include "mojo/edk/embedder/embedder.h" | 64 #include "mojo/edk/embedder/embedder.h" |
65 #include "services/shell/public/cpp/connection.h" | 65 #include "services/shell/public/cpp/connection.h" |
66 #include "services/shell/public/cpp/interface_provider.h" | 66 #include "services/shell/public/cpp/interface_provider.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 295 |
296 class GpuProcessHost::ConnectionFilterImpl : public ConnectionFilter { | 296 class GpuProcessHost::ConnectionFilterImpl : public ConnectionFilter { |
297 public: | 297 public: |
298 ConnectionFilterImpl(GpuProcessHost* host) : host_(host) {} | 298 ConnectionFilterImpl(GpuProcessHost* host) : host_(host) {} |
299 | 299 |
300 private: | 300 private: |
301 // ConnectionFilter: | 301 // ConnectionFilter: |
302 bool OnConnect(const shell::Identity& remote_identity, | 302 bool OnConnect(const shell::Identity& remote_identity, |
303 shell::InterfaceRegistry* registry, | 303 shell::InterfaceRegistry* registry, |
304 shell::Connector* connector) override { | 304 shell::Connector* connector) override { |
305 if (remote_identity.name() != kGpuMojoApplicationName) | 305 if (remote_identity.name() != kGpuServiceName) |
306 return false; | 306 return false; |
307 | 307 |
308 GetContentClient()->browser()->ExposeInterfacesToGpuProcess(registry, | 308 GetContentClient()->browser()->ExposeInterfacesToGpuProcess(registry, |
309 host_); | 309 host_); |
310 return true; | 310 return true; |
311 } | 311 } |
312 | 312 |
313 GpuProcessHost* host_; | 313 GpuProcessHost* host_; |
314 | 314 |
315 DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl); | 315 DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 // GpuProcessHostUIShim will be destroyed if either the browser exits, | 457 // GpuProcessHostUIShim will be destroyed if either the browser exits, |
458 // in which case it calls GpuProcessHostUIShim::DestroyAll, or the | 458 // in which case it calls GpuProcessHostUIShim::DestroyAll, or the |
459 // GpuProcessHost is destroyed, which happens when the corresponding GPU | 459 // GpuProcessHost is destroyed, which happens when the corresponding GPU |
460 // process terminates or fails to launch. | 460 // process terminates or fails to launch. |
461 BrowserThread::PostTask( | 461 BrowserThread::PostTask( |
462 BrowserThread::UI, | 462 BrowserThread::UI, |
463 FROM_HERE, | 463 FROM_HERE, |
464 base::Bind(base::IgnoreResult(&GpuProcessHostUIShim::Create), host_id)); | 464 base::Bind(base::IgnoreResult(&GpuProcessHostUIShim::Create), host_id)); |
465 | 465 |
466 process_.reset(new BrowserChildProcessHostImpl( | 466 process_.reset(new BrowserChildProcessHostImpl( |
467 PROCESS_TYPE_GPU, this, kGpuMojoApplicationName)); | 467 PROCESS_TYPE_GPU, this, kGpuServiceName)); |
468 } | 468 } |
469 | 469 |
470 GpuProcessHost::~GpuProcessHost() { | 470 GpuProcessHost::~GpuProcessHost() { |
471 DCHECK(CalledOnValidThread()); | 471 DCHECK(CalledOnValidThread()); |
472 | 472 |
473 SendOutstandingReplies(); | 473 SendOutstandingReplies(); |
474 | 474 |
475 // In case we never started, clean up. | 475 // In case we never started, clean up. |
476 while (!queued_messages_.empty()) { | 476 while (!queued_messages_.empty()) { |
477 delete queued_messages_.front(); | 477 delete queued_messages_.front(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 host_id_, | 553 host_id_, |
554 message)); | 554 message)); |
555 } | 555 } |
556 | 556 |
557 bool GpuProcessHost::Init() { | 557 bool GpuProcessHost::Init() { |
558 init_start_time_ = base::TimeTicks::Now(); | 558 init_start_time_ = base::TimeTicks::Now(); |
559 | 559 |
560 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD); | 560 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD); |
561 | 561 |
562 // May be null during test execution. | 562 // May be null during test execution. |
563 if (MojoShellConnection::GetForProcess()) { | 563 if (ServiceManagerConnection::GetForProcess()) { |
564 MojoShellConnection::GetForProcess()->AddConnectionFilter( | 564 ServiceManagerConnection::GetForProcess()->AddConnectionFilter( |
565 base::MakeUnique<ConnectionFilterImpl>(this)); | 565 base::MakeUnique<ConnectionFilterImpl>(this)); |
566 } | 566 } |
567 | 567 |
568 process_->GetHost()->CreateChannelMojo(); | 568 process_->GetHost()->CreateChannelMojo(); |
569 | 569 |
570 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); | 570 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); |
571 if (in_process_) { | 571 if (in_process_) { |
572 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 572 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
573 DCHECK(g_gpu_main_thread_factory); | 573 DCHECK(g_gpu_main_thread_factory); |
574 in_process_gpu_thread_.reset(g_gpu_main_thread_factory( | 574 in_process_gpu_thread_.reset(g_gpu_main_thread_factory( |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1164 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1165 ClientIdToShaderCacheMap::iterator iter = | 1165 ClientIdToShaderCacheMap::iterator iter = |
1166 client_id_to_shader_cache_.find(client_id); | 1166 client_id_to_shader_cache_.find(client_id); |
1167 // If the cache doesn't exist then this is an off the record profile. | 1167 // If the cache doesn't exist then this is an off the record profile. |
1168 if (iter == client_id_to_shader_cache_.end()) | 1168 if (iter == client_id_to_shader_cache_.end()) |
1169 return; | 1169 return; |
1170 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1170 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1171 } | 1171 } |
1172 | 1172 |
1173 } // namespace content | 1173 } // namespace content |
OLD | NEW |