diff options
author | kcwu <kcwu@chromium.org> | 2016-02-18 11:12:42 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-18 19:13:37 +0000 |
commit | 08377adbc7200d4a7e0e9821cfea0809ce61cd82 (patch) | |
tree | 5540634e822e10a470e235ca12d980b7f2f0d6cc | |
parent | e7e13e1d679f7111119bfc9c8a7588b68711a7ab (diff) | |
download | chromium_src-08377adbc7200d4a7e0e9821cfea0809ce61cd82.zip chromium_src-08377adbc7200d4a7e0e9821cfea0809ce61cd82.tar.gz chromium_src-08377adbc7200d4a7e0e9821cfea0809ce61cd82.tar.bz2 |
Add embedder api for participating in gpu logic
With new ContentGpuClient hook and GetGpuServiceRegistry, embedder can
register service in GPU process and query service registry in browser
process.
BUG=b/25057601
Review URL: https://codereview.chromium.org/1646853002
Cr-Commit-Position: refs/heads/master@{#376217}
-rw-r--r-- | content/BUILD.gn | 1 | ||||
-rw-r--r-- | content/app/content_main_runner.cc | 12 | ||||
-rw-r--r-- | content/browser/gpu/gpu_process_host.h | 4 | ||||
-rw-r--r-- | content/common/gpu/gpu_process_launch_causes.h | 1 | ||||
-rw-r--r-- | content/content_browser.gypi | 2 | ||||
-rw-r--r-- | content/content_gpu.gypi | 1 | ||||
-rw-r--r-- | content/gpu/DEPS | 1 | ||||
-rw-r--r-- | content/gpu/gpu_child_thread.cc | 4 | ||||
-rw-r--r-- | content/public/app/DEPS | 1 | ||||
-rw-r--r-- | content/public/app/content_main_delegate.cc | 9 | ||||
-rw-r--r-- | content/public/app/content_main_delegate.h | 2 | ||||
-rw-r--r-- | content/public/browser/gpu_service_registry.cc | 18 | ||||
-rw-r--r-- | content/public/browser/gpu_service_registry.h | 19 | ||||
-rw-r--r-- | content/public/common/content_client.cc | 7 | ||||
-rw-r--r-- | content/public/common/content_client.h | 4 | ||||
-rw-r--r-- | content/public/gpu/BUILD.gn | 30 | ||||
-rw-r--r-- | content/public/gpu/content_gpu_client.h | 27 |
17 files changed, 140 insertions, 3 deletions
diff --git a/content/BUILD.gn b/content/BUILD.gn index cb50de5..1d32ad2 100644 --- a/content/BUILD.gn +++ b/content/BUILD.gn @@ -43,6 +43,7 @@ if (!is_nacl_nonsfi) { "//content/gpu:gpu_sources", "//content/public/browser:browser_sources", "//content/public/child:child_sources", + "//content/public/gpu:gpu_sources", "//content/public/common:common_sources", "//content/public/plugin:plugin_sources", "//content/public/renderer:renderer_sources", diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc index 59efad3..ba10cbb 100644 --- a/content/app/content_main_runner.cc +++ b/content/app/content_main_runner.cc @@ -68,6 +68,7 @@ #include "content/browser/gpu/gpu_process_host.h" #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/utility_process_host_impl.h" +#include "content/public/gpu/content_gpu_client.h" #include "content/public/plugin/content_plugin_client.h" #include "content/public/renderer/content_renderer_client.h" #include "content/public/utility/content_utility_client.h" @@ -134,6 +135,8 @@ base::LazyInstance<ContentBrowserClient> #endif // !CHROME_MULTIPLE_DLL_CHILD #if !defined(OS_IOS) && !defined(CHROME_MULTIPLE_DLL_BROWSER) +base::LazyInstance<ContentGpuClient> + g_empty_content_gpu_client = LAZY_INSTANCE_INITIALIZER; base::LazyInstance<ContentPluginClient> g_empty_content_plugin_client = LAZY_INSTANCE_INITIALIZER; base::LazyInstance<ContentRendererClient> @@ -225,6 +228,15 @@ class ContentClientInitializer { #endif // !CHROME_MULTIPLE_DLL_CHILD #if !defined(OS_IOS) && !defined(CHROME_MULTIPLE_DLL_BROWSER) + if (process_type == switches::kGpuProcess || + base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kSingleProcess)) { + if (delegate) + content_client->gpu_ = delegate->CreateContentGpuClient(); + if (!content_client->gpu_) + content_client->gpu_ = &g_empty_content_gpu_client.Get(); + } + if (process_type == switches::kPluginProcess || process_type == switches::kPpapiPluginProcess) { if (delegate) diff --git a/content/browser/gpu/gpu_process_host.h b/content/browser/gpu/gpu_process_host.h index af4f4d8..5091e6f 100644 --- a/content/browser/gpu/gpu_process_host.h +++ b/content/browser/gpu/gpu_process_host.h @@ -95,6 +95,9 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, CONTENT_EXPORT static void RegisterGpuMainThreadFactory( GpuMainThreadFactoryFunction create); + // BrowserChildProcessHostDelegate implementation. + ServiceRegistry* GetServiceRegistry() override; + // Get the GPU process host for the GPU process with the given ID. Returns // null if the process no longer exists. static GpuProcessHost* FromID(int host_id); @@ -171,7 +174,6 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, void OnProcessLaunched() override; void OnProcessLaunchFailed() override; void OnProcessCrashed(int exit_code) override; - ServiceRegistry* GetServiceRegistry() override; // Message handlers. void OnInitialized(bool result, const gpu::GPUInfo& gpu_info); diff --git a/content/common/gpu/gpu_process_launch_causes.h b/content/common/gpu/gpu_process_launch_causes.h index 533a594..1fcdc27 100644 --- a/content/common/gpu/gpu_process_launch_causes.h +++ b/content/common/gpu/gpu_process_launch_causes.h @@ -23,6 +23,7 @@ enum CauseForGpuLaunch { CAUSE_FOR_GPU_LAUNCH_GPU_MEMORY_BUFFER_ALLOCATE, CAUSE_FOR_GPU_LAUNCH_JPEGDECODEACCELERATOR_INITIALIZE, CAUSE_FOR_GPU_LAUNCH_MOJO_SETUP, + CAUSE_FOR_GPU_LAUNCH_GET_GPU_SERVICE_REGISTRY, // All new values should be inserted above this point so that // existing values continue to match up with those in histograms.xml. diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 80620c1..06aa890 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -156,6 +156,8 @@ 'public/browser/global_request_id.h', 'public/browser/gpu_data_manager.h', 'public/browser/gpu_data_manager_observer.h', + 'public/browser/gpu_service_registry.cc', + 'public/browser/gpu_service_registry.h', 'public/browser/histogram_fetcher.h', 'public/browser/host_zoom_map.h', 'public/browser/indexed_db_context.h', diff --git a/content/content_gpu.gypi b/content/content_gpu.gypi index 1a6b7e6..f9dd636 100644 --- a/content/content_gpu.gypi +++ b/content/content_gpu.gypi @@ -21,6 +21,7 @@ 'gpu/gpu_watchdog_thread.h', 'gpu/in_process_gpu_thread.cc', 'gpu/in_process_gpu_thread.h', + 'public/gpu/content_gpu_client.h', ], 'include_dirs': [ '..', diff --git a/content/gpu/DEPS b/content/gpu/DEPS index f9f4c04..0a68a11 100644 --- a/content/gpu/DEPS +++ b/content/gpu/DEPS @@ -1,6 +1,7 @@ include_rules = [ "+components/tracing", "+content/child", + "+content/public/gpu", "+libEGL", "+libGLESv2", "+media/mojo/services", diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc index 2552d82..6ea7e2e 100644 --- a/content/gpu/gpu_child_thread.cc +++ b/content/gpu/gpu_child_thread.cc @@ -20,6 +20,7 @@ #include "content/gpu/gpu_watchdog_thread.h" #include "content/public/common/content_client.h" #include "content/public/common/content_switches.h" +#include "content/public/gpu/content_gpu_client.h" #include "gpu/config/gpu_info_collector.h" #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_sync_message_filter.h" @@ -205,6 +206,9 @@ void GpuChildThread::Init(const base::Time& process_start_time) { // will be destroyed before GpuChildThread is destructed. service_registry()->AddService(base::Bind( &GpuChildThread::BindProcessControlRequest, base::Unretained(this))); + + if (GetContentClient()->gpu()) // NULL in tests. + GetContentClient()->gpu()->RegisterMojoServices(service_registry()); } bool GpuChildThread::Send(IPC::Message* msg) { diff --git a/content/public/app/DEPS b/content/public/app/DEPS index 255cb72..47482a5 100644 --- a/content/public/app/DEPS +++ b/content/public/app/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+content/public/browser/content_browser_client.h", + "+content/public/gpu/content_gpu_client.h", "+content/public/plugin/content_plugin_client.h", "+content/public/renderer/content_renderer_client.h", "+content/public/utility/content_utility_client.h", diff --git a/content/public/app/content_main_delegate.cc b/content/public/app/content_main_delegate.cc index 3c979be..16fd804 100644 --- a/content/public/app/content_main_delegate.cc +++ b/content/public/app/content_main_delegate.cc @@ -11,6 +11,7 @@ #endif #if !defined(OS_IOS) +#include "content/public/gpu/content_gpu_client.h" #include "content/public/plugin/content_plugin_client.h" #include "content/public/renderer/content_renderer_client.h" #include "content/public/utility/content_utility_client.h" @@ -64,6 +65,14 @@ ContentBrowserClient* ContentMainDelegate::CreateContentBrowserClient() { #endif } +ContentGpuClient* ContentMainDelegate::CreateContentGpuClient() { +#if defined(OS_IOS) || defined(CHROME_MULTIPLE_DLL_BROWSER) + return NULL; +#else + return new ContentGpuClient(); +#endif +} + ContentPluginClient* ContentMainDelegate::CreateContentPluginClient() { #if defined(OS_IOS) || defined(CHROME_MULTIPLE_DLL_BROWSER) return NULL; diff --git a/content/public/app/content_main_delegate.h b/content/public/app/content_main_delegate.h index 6bd725d..7fecaea 100644 --- a/content/public/app/content_main_delegate.h +++ b/content/public/app/content_main_delegate.h @@ -16,6 +16,7 @@ class ScopedVector; namespace content { class ContentBrowserClient; +class ContentGpuClient; class ContentPluginClient; class ContentRendererClient; class ContentUtilityClient; @@ -88,6 +89,7 @@ class CONTENT_EXPORT ContentMainDelegate { // content. If an embedder wants the default (empty) implementation, don't // override this. virtual ContentBrowserClient* CreateContentBrowserClient(); + virtual ContentGpuClient* CreateContentGpuClient(); virtual ContentPluginClient* CreateContentPluginClient(); virtual ContentRendererClient* CreateContentRendererClient(); virtual ContentUtilityClient* CreateContentUtilityClient(); diff --git a/content/public/browser/gpu_service_registry.cc b/content/public/browser/gpu_service_registry.cc new file mode 100644 index 0000000..e6a2ba74 --- /dev/null +++ b/content/public/browser/gpu_service_registry.cc @@ -0,0 +1,18 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/public/browser/gpu_service_registry.h" + +#include "content/browser/gpu/gpu_process_host.h" + +namespace content { + +ServiceRegistry* GetGpuServiceRegistry() { + GpuProcessHost* host = + GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, + CAUSE_FOR_GPU_LAUNCH_GET_GPU_SERVICE_REGISTRY); + return host->GetServiceRegistry(); +} + +} // namespace content diff --git a/content/public/browser/gpu_service_registry.h b/content/public/browser/gpu_service_registry.h new file mode 100644 index 0000000..0e025ee --- /dev/null +++ b/content/public/browser/gpu_service_registry.h @@ -0,0 +1,19 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_PUBLIC_BROWSER_GPU_SERVICE_REGISTRY_H_ +#define CONTENT_PUBLIC_BROWSER_GPU_SERVICE_REGISTRY_H_ + +#include "content/common/content_export.h" + +namespace content { +class ServiceRegistry; + +// Get ServiceRegistry registered via ContentGpuClient::RegisterMojoServices(). +// This must be called on IO thread. +CONTENT_EXPORT ServiceRegistry* GetGpuServiceRegistry(); + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_GPU_SERVICE_REGISTRY_H_ diff --git a/content/public/common/content_client.cc b/content/public/common/content_client.cc index e7f50c8..75ed9979 100644 --- a/content/public/common/content_client.cc +++ b/content/public/common/content_client.cc @@ -62,8 +62,11 @@ ContentUtilityClient* SetUtilityClientForTesting(ContentUtilityClient* u) { } ContentClient::ContentClient() - : browser_(NULL), plugin_(NULL), renderer_(NULL), utility_(NULL) { -} + : browser_(NULL), + gpu_(NULL), + plugin_(NULL), + renderer_(NULL), + utility_(NULL) {} ContentClient::~ContentClient() { } diff --git a/content/public/common/content_client.h b/content/public/common/content_client.h index 9d51d5b..5bd865d 100644 --- a/content/public/common/content_client.h +++ b/content/public/common/content_client.h @@ -42,6 +42,7 @@ namespace content { class ContentBrowserClient; class ContentClient; +class ContentGpuClient; class ContentPluginClient; class ContentRendererClient; class ContentUtilityClient; @@ -72,6 +73,7 @@ class CONTENT_EXPORT ContentClient { virtual ~ContentClient(); ContentBrowserClient* browser() { return browser_; } + ContentGpuClient* gpu() { return gpu_; } ContentPluginClient* plugin() { return plugin_; } ContentRendererClient* renderer() { return renderer_; } ContentUtilityClient* utility() { return utility_; } @@ -159,6 +161,8 @@ class CONTENT_EXPORT ContentClient { // The embedder API for participating in browser logic. ContentBrowserClient* browser_; + // The embedder API for participating in gpu logic. + ContentGpuClient* gpu_; // The embedder API for participating in plugin logic. ContentPluginClient* plugin_; // The embedder API for participating in renderer logic. diff --git a/content/public/gpu/BUILD.gn b/content/public/gpu/BUILD.gn new file mode 100644 index 0000000..8de310c --- /dev/null +++ b/content/public/gpu/BUILD.gn @@ -0,0 +1,30 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# See //content/BUILD.gn for how this works. +group("gpu") { + if (is_component_build) { + public_deps = [ + "//content", + ] + } else { + public_deps = [ + ":gpu_sources", + ] + } +} + +source_set("gpu_sources") { + visibility = [ "//content/*" ] + + sources = [ + "content_gpu_client.h", + ] + + deps = [ + "//base", + "//content:export", + "//content/gpu:gpu_sources", + ] +} diff --git a/content/public/gpu/content_gpu_client.h b/content/public/gpu/content_gpu_client.h new file mode 100644 index 0000000..3b0095b --- /dev/null +++ b/content/public/gpu/content_gpu_client.h @@ -0,0 +1,27 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_PUBLIC_GPU_CONTENT_GPU_CLIENT_H_ +#define CONTENT_PUBLIC_GPU_CONTENT_GPU_CLIENT_H_ + +#include "content/public/common/content_client.h" + +namespace content { + +class ServiceRegistry; + +// Embedder API for participating in gpu logic. +class CONTENT_EXPORT ContentGpuClient { + public: + virtual ~ContentGpuClient() {} + + // Allows client to register Mojo services in |registry| on the GPU process. + // The registered services will be exposed to the browser process through + // GpuProcessHost. + virtual void RegisterMojoServices(ServiceRegistry* registry) {} +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_GPU_CONTENT_GPU_CLIENT_H_ |