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_ui_shim.h" | 5 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
11 #include "base/id_map.h" | 11 #include "base/id_map.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "content/browser/compositor/gpu_process_transport_factory.h" | 16 #include "content/browser/compositor/gpu_process_transport_factory.h" |
17 #include "content/browser/gpu/compositor_util.h" | 17 #include "content/browser/gpu/compositor_util.h" |
18 #include "content/browser/gpu/gpu_data_manager_impl.h" | 18 #include "content/browser/gpu/gpu_data_manager_impl.h" |
19 #include "content/browser/gpu/gpu_process_host.h" | 19 #include "content/browser/gpu/gpu_process_host.h" |
20 #include "content/browser/renderer_host/render_process_host_impl.h" | 20 #include "content/browser/renderer_host/render_process_host_impl.h" |
21 #include "content/browser/renderer_host/render_view_host_impl.h" | 21 #include "content/browser/renderer_host/render_view_host_impl.h" |
22 #include "content/browser/renderer_host/render_widget_helper.h" | 22 #include "content/browser/renderer_host/render_widget_helper.h" |
23 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 23 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
24 #include "content/common/gpu_host_messages.h" | 24 #include "content/common/gpu_host_messages.h" |
25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
26 #include "gpu/ipc/common/memory_stats.h" | 26 #include "gpu/ipc/common/memory_stats.h" |
27 #include "ui/gfx/swap_result.h" | 27 #include "ui/gfx/swap_result.h" |
28 | 28 |
| 29 #if defined(OS_ANDROID) |
| 30 #include "content/public/browser/android/java_interfaces.h" |
| 31 #include "media/mojo/interfaces/android_overlay.mojom.h" |
| 32 #include "services/service_manager/public/cpp/interface_provider.h" |
| 33 #include "services/service_manager/public/cpp/interface_registry.h" |
| 34 #endif |
| 35 |
29 #if defined(USE_OZONE) | 36 #if defined(USE_OZONE) |
30 #include "ui/ozone/public/gpu_platform_support_host.h" | 37 #include "ui/ozone/public/gpu_platform_support_host.h" |
31 #include "ui/ozone/public/ozone_platform.h" | 38 #include "ui/ozone/public/ozone_platform.h" |
32 #endif | 39 #endif |
33 | 40 |
34 namespace content { | 41 namespace content { |
35 | 42 |
36 namespace { | 43 namespace { |
37 | 44 |
38 // One of the linux specific headers defines this as a macro. | 45 // One of the linux specific headers defines this as a macro. |
(...skipping 11 matching lines...) Expand all Loading... |
50 else | 57 else |
51 delete msg; | 58 delete msg; |
52 } | 59 } |
53 | 60 |
54 void StopGpuProcessOnIO(int host_id) { | 61 void StopGpuProcessOnIO(int host_id) { |
55 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 62 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
56 if (host) | 63 if (host) |
57 host->StopGpuProcess(); | 64 host->StopGpuProcess(); |
58 } | 65 } |
59 | 66 |
| 67 #if defined(OS_ANDROID) |
| 68 template <typename Interface> |
| 69 void BindJavaInterface(mojo::InterfaceRequest<Interface> request) { |
| 70 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 71 content::GetGlobalJavaInterfaces()->GetInterface(std::move(request)); |
| 72 } |
| 73 |
| 74 // Binder which posts each request to the UI thread. |
| 75 template <typename Interface> |
| 76 void BindJavaInterfaceOnUIThread(mojo::InterfaceRequest<Interface> request) { |
| 77 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI) |
| 78 ->PostTask(FROM_HERE, base::Bind(&BindJavaInterface<Interface>, |
| 79 base::Passed(&request))); |
| 80 } |
| 81 #endif |
| 82 |
60 } // namespace | 83 } // namespace |
61 | 84 |
62 void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) { | 85 void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) { |
63 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id); | 86 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id); |
64 if (ui_shim) | 87 if (ui_shim) |
65 ui_shim->OnMessageReceived(msg); | 88 ui_shim->OnMessageReceived(msg); |
66 } | 89 } |
67 | 90 |
68 GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id) | 91 GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id) |
69 : host_id_(host_id) { | 92 : host_id_(host_id) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 235 |
213 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 236 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
214 } | 237 } |
215 | 238 |
216 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( | 239 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( |
217 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) { | 240 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) { |
218 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( | 241 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( |
219 video_memory_usage_stats); | 242 video_memory_usage_stats); |
220 } | 243 } |
221 | 244 |
| 245 #if defined(OS_ANDROID) |
| 246 // static |
| 247 void GpuProcessHostUIShim::RegisterUIThreadMojoInterfaces( |
| 248 service_manager::InterfaceRegistry* registry) { |
| 249 registry->AddInterface(base::Bind( |
| 250 &BindJavaInterfaceOnUIThread<media::mojom::AndroidOverlayProvider>)); |
| 251 } |
| 252 #endif |
| 253 |
222 } // namespace content | 254 } // namespace content |
OLD | NEW |