Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1723)

Side by Side Diff: content/browser/gpu/gpu_process_host_ui_shim.cc

Issue 2688193002: Mojo framework for AndroidOverlay. (Closed)
Patch Set: fixed mojo manifest bug introduced by rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/gpu/gpu_process_host_ui_shim.h ('k') | content/public/android/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.
39 #ifdef DestroyAll 46 #ifdef DestroyAll
40 #undef DestroyAll 47 #undef DestroyAll
41 #endif 48 #endif
42 49
43 base::LazyInstance<IDMap<GpuProcessHostUIShim*>>::DestructorAtExit 50 base::LazyInstance<IDMap<GpuProcessHostUIShim*>>::DestructorAtExit
44 g_hosts_by_id = LAZY_INSTANCE_INITIALIZER; 51 g_hosts_by_id = LAZY_INSTANCE_INITIALIZER;
45 52
53 #if defined(OS_ANDROID)
54 template <typename Interface>
55 void BindJavaInterface(mojo::InterfaceRequest<Interface> request) {
56 DCHECK_CURRENTLY_ON(BrowserThread::UI);
57 content::GetGlobalJavaInterfaces()->GetInterface(std::move(request));
58 }
59
60 // Binder which posts each request to the UI thread.
61 template <typename Interface>
62 void BindJavaInterfaceOnUIThread(mojo::InterfaceRequest<Interface> request) {
63 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)
64 ->PostTask(FROM_HERE, base::Bind(&BindJavaInterface<Interface>,
65 base::Passed(&request)));
66 }
67 #endif
68
46 } // namespace 69 } // namespace
47 70
48 void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) { 71 void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) {
49 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id); 72 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id);
50 if (ui_shim) 73 if (ui_shim)
51 ui_shim->OnMessageReceived(msg); 74 ui_shim->OnMessageReceived(msg);
52 } 75 }
53 76
54 GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id) 77 GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id)
55 : host_id_(host_id) { 78 : host_id_(host_id) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 168
146 void GpuProcessHostUIShim::OnGraphicsInfoCollected( 169 void GpuProcessHostUIShim::OnGraphicsInfoCollected(
147 const gpu::GPUInfo& gpu_info) { 170 const gpu::GPUInfo& gpu_info) {
148 // OnGraphicsInfoCollected is sent back after the GPU process successfully 171 // OnGraphicsInfoCollected is sent back after the GPU process successfully
149 // initializes GL. 172 // initializes GL.
150 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected"); 173 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected");
151 174
152 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); 175 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info);
153 } 176 }
154 177
178 #if defined(OS_ANDROID)
179 // static
180 void GpuProcessHostUIShim::RegisterUIThreadMojoInterfaces(
181 service_manager::InterfaceRegistry* registry) {
182 registry->AddInterface(base::Bind(
183 &BindJavaInterfaceOnUIThread<media::mojom::AndroidOverlayProvider>));
184 }
185 #endif
186
155 } // namespace content 187 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host_ui_shim.h ('k') | content/public/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698