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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 #include "services/service_manager/public/cpp/connection.h" | 68 #include "services/service_manager/public/cpp/connection.h" |
69 #include "services/service_manager/public/cpp/interface_provider.h" | 69 #include "services/service_manager/public/cpp/interface_provider.h" |
70 #include "services/service_manager/runner/common/client_util.h" | 70 #include "services/service_manager/runner/common/client_util.h" |
71 #include "ui/base/ui_base_switches.h" | 71 #include "ui/base/ui_base_switches.h" |
72 #include "ui/events/latency_info.h" | 72 #include "ui/events/latency_info.h" |
73 #include "ui/gfx/switches.h" | 73 #include "ui/gfx/switches.h" |
74 #include "ui/gl/gl_switches.h" | 74 #include "ui/gl/gl_switches.h" |
75 | 75 |
76 #if defined(OS_ANDROID) | 76 #if defined(OS_ANDROID) |
77 #include "base/android/build_info.h" | 77 #include "base/android/build_info.h" |
78 #include "content/public/browser/android/java_interfaces.h" | |
79 #include "media/mojo/interfaces/android_overlay.mojom.h" | |
80 #include "services/service_manager/public/cpp/interface_registry.h" | |
78 #endif | 81 #endif |
79 | 82 |
80 #if defined(OS_WIN) | 83 #if defined(OS_WIN) |
81 #include "base/win/windows_version.h" | 84 #include "base/win/windows_version.h" |
82 #include "content/common/sandbox_win.h" | 85 #include "content/common/sandbox_win.h" |
83 #include "sandbox/win/src/sandbox_policy.h" | 86 #include "sandbox/win/src/sandbox_policy.h" |
84 #include "ui/gfx/switches.h" | 87 #include "ui/gfx/switches.h" |
85 #include "ui/gfx/win/rendering_window_manager.h" | 88 #include "ui/gfx/win/rendering_window_manager.h" |
86 #endif | 89 #endif |
87 | 90 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 void HostLoadedShader(int host_id, | 314 void HostLoadedShader(int host_id, |
312 const std::string& key, | 315 const std::string& key, |
313 const std::string& data) { | 316 const std::string& data) { |
314 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 317 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
315 if (host) | 318 if (host) |
316 host->LoadedShader(key, data); | 319 host->LoadedShader(key, data); |
317 } | 320 } |
318 | 321 |
319 } // anonymous namespace | 322 } // anonymous namespace |
320 | 323 |
324 #if defined(OS_ANDROID) | |
325 template <typename Interface> | |
326 void BindJavaInterface(mojo::InterfaceRequest<Interface> request) { | |
boliu
2017/02/17 21:20:51
if we end up creating a separate registry for gpu,
liberato (no reviews please)
2017/02/22 16:25:01
moved to UI shim, per offline discussion.
| |
327 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
328 content::GetGlobalJavaInterfaces()->GetInterface(std::move(request)); | |
329 } | |
330 | |
331 // Binder which posts each request to the UI thread. | |
332 template <typename Interface> | |
333 void BindJavaInterfaceOnUIThread(mojo::InterfaceRequest<Interface> request) { | |
334 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI) | |
335 ->PostTask(FROM_HERE, base::Bind(&BindJavaInterface<Interface>, | |
336 base::Passed(&request))); | |
337 } | |
338 #endif | |
339 | |
321 class GpuProcessHost::ConnectionFilterImpl : public ConnectionFilter { | 340 class GpuProcessHost::ConnectionFilterImpl : public ConnectionFilter { |
322 public: | 341 public: |
323 ConnectionFilterImpl(GpuProcessHost* host) : host_(host) {} | 342 ConnectionFilterImpl(GpuProcessHost* host) : host_(host) {} |
324 | 343 |
325 private: | 344 private: |
326 // ConnectionFilter: | 345 // ConnectionFilter: |
327 bool OnConnect(const service_manager::Identity& remote_identity, | 346 bool OnConnect(const service_manager::Identity& remote_identity, |
328 service_manager::InterfaceRegistry* registry, | 347 service_manager::InterfaceRegistry* registry, |
329 service_manager::Connector* connector) override { | 348 service_manager::Connector* connector) override { |
330 if (remote_identity.name() != mojom::kGpuServiceName) | 349 if (remote_identity.name() != mojom::kGpuServiceName) |
331 return false; | 350 return false; |
332 | 351 |
333 GetContentClient()->browser()->ExposeInterfacesToGpuProcess(registry, | 352 GetContentClient()->browser()->ExposeInterfacesToGpuProcess(registry, |
334 host_); | 353 host_); |
354 | |
355 #if defined(OS_ANDROID) | |
356 registry->AddInterface(base::Bind( | |
357 &BindJavaInterfaceOnUIThread<media::mojom::AndroidOverlayProvider>)); | |
358 #endif | |
359 | |
335 return true; | 360 return true; |
336 } | 361 } |
337 | 362 |
338 GpuProcessHost* host_; | 363 GpuProcessHost* host_; |
339 | 364 |
340 DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl); | 365 DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl); |
341 }; | 366 }; |
342 | 367 |
343 // static | 368 // static |
344 bool GpuProcessHost::ValidateHost(GpuProcessHost* host) { | 369 bool GpuProcessHost::ValidateHost(GpuProcessHost* host) { |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1185 GetShaderCacheFactorySingleton()->Get(client_id); | 1210 GetShaderCacheFactorySingleton()->Get(client_id); |
1186 if (!cache.get()) | 1211 if (!cache.get()) |
1187 return; | 1212 return; |
1188 | 1213 |
1189 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_)); | 1214 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_)); |
1190 | 1215 |
1191 client_id_to_shader_cache_[client_id] = cache; | 1216 client_id_to_shader_cache_[client_id] = cache; |
1192 } | 1217 } |
1193 | 1218 |
1194 } // namespace content | 1219 } // namespace content |
OLD | NEW |