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

Unified Diff: content/browser/gpu/gpu_process_host.cc

Issue 2848643002: Revert of gpu: Completely remove GpuProcessHostUIShim. (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/browser/gpu/gpu_process_host_ui_shim.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/gpu/gpu_process_host.cc
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index 57ae36c0f546cf657e832f3be4ad085ea10ba40c..7749da464a4d2790cbd2bc3fd6cb9055163779f8 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -29,10 +29,10 @@
#include "components/tracing/common/tracing_switches.h"
#include "content/browser/browser_child_process_host_impl.h"
#include "content/browser/browser_main_loop.h"
-#include "content/browser/field_trial_recorder.h"
#include "content/browser/gpu/compositor_util.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_main_thread_factory.h"
+#include "content/browser/gpu/gpu_process_host_ui_shim.h"
#include "content/browser/gpu/shader_cache_factory.h"
#include "content/browser/service_manager/service_manager_context.h"
#include "content/common/child_process_host_impl.h"
@@ -71,8 +71,6 @@
#if defined(OS_ANDROID)
#include "base/android/build_info.h"
-#include "content/public/browser/android/java_interfaces.h"
-#include "media/mojo/interfaces/android_overlay.mojom.h"
#endif
#if defined(OS_WIN)
@@ -196,7 +194,6 @@
}
#if defined(USE_OZONE)
-// The ozone platform use this callback to send IPC messages to the gpu process.
void SendGpuProcessMessage(base::WeakPtr<GpuProcessHost> host,
IPC::Message* message) {
if (host)
@@ -204,26 +201,7 @@
else
delete message;
}
-
-void RouteMessageToOzoneOnUI(const IPC::Message& message) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- ui::OzonePlatform::GetInstance()
- ->GetGpuPlatformSupportHost()
- ->OnMessageReceived(message);
-}
-
#endif // defined(USE_OZONE)
-
-void OnGpuProcessHostDestroyedOnUI(int host_id, const std::string& message) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- GpuDataManagerImpl::GetInstance()->AddLogMessage(
- logging::LOG_ERROR, "GpuProcessHostUIShim", message);
-#if defined(USE_OZONE)
- ui::OzonePlatform::GetInstance()
- ->GetGpuPlatformSupportHost()
- ->OnChannelDestroyed(host_id);
-#endif
-}
// NOTE: changes to this class need to be reviewed by the security team.
class GpuSandboxedProcessLauncherDelegate
@@ -328,33 +306,12 @@
#endif // OS_WIN
};
-#if defined(OS_ANDROID)
-template <typename Interface>
-void BindJavaInterface(mojo::InterfaceRequest<Interface> request) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- content::GetGlobalJavaInterfaces()->GetInterface(std::move(request));
-}
-#endif // defined(OS_ANDROID)
-
} // anonymous namespace
class GpuProcessHost::ConnectionFilterImpl : public ConnectionFilter {
public:
ConnectionFilterImpl() {
- auto task_runner = BrowserThread::GetTaskRunnerForThread(BrowserThread::UI);
- registry_.AddInterface(base::Bind(&FieldTrialRecorder::Create),
- task_runner);
- registry_.AddInterface(
- base::Bind(
- &memory_instrumentation::CoordinatorImpl::BindCoordinatorRequest,
- base::Unretained(
- memory_instrumentation::CoordinatorImpl::GetInstance())),
- task_runner);
-#if defined(OS_ANDROID)
- registry_.AddInterface(
- base::Bind(&BindJavaInterface<media::mojom::AndroidOverlayProvider>),
- task_runner);
-#endif
+ GpuProcessHostUIShim::RegisterUIThreadMojoInterfaces(&registry_);
}
private:
@@ -509,6 +466,15 @@
g_gpu_process_hosts[kind] = this;
+ // Post a task to create the corresponding GpuProcessHostUIShim. The
+ // GpuProcessHostUIShim will be destroyed when the GpuProcessHost is
+ // destroyed, which happens when the corresponding GPU process terminates or
+ // fails to launch. On browser exit, the shim can be leaked.
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(base::IgnoreResult(&GpuProcessHostUIShim::Create), host_id));
+
process_.reset(new BrowserChildProcessHostImpl(
PROCESS_TYPE_GPU, this, mojom::kGpuServiceName));
}
@@ -596,9 +562,11 @@
if (block_offscreen_contexts)
BlockLiveOffscreenContexts();
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&OnGpuProcessHostDestroyedOnUI, host_id_, message));
+ BrowserThread::PostTask(BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&GpuProcessHostUIShim::Destroy,
+ host_id_,
+ message));
}
bool GpuProcessHost::Init() {
@@ -651,12 +619,18 @@
ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupportHost()
->OnGpuProcessLaunched(
- host_id_, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
- base::ThreadTaskRunnerHandle::Get(),
+ host_id_, base::ThreadTaskRunnerHandle::Get(),
base::Bind(&SendGpuProcessMessage, weak_ptr_factory_.GetWeakPtr()));
#endif
return true;
+}
+
+void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) {
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&RouteToGpuProcessHostUIShimTask, host_id_, message));
}
bool GpuProcessHost::Send(IPC::Message* msg) {
@@ -678,10 +652,7 @@
bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
DCHECK(CalledOnValidThread());
-#if defined(USE_OZONE)
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&RouteMessageToOzoneOnUI, message));
-#endif
+ RouteOnUIThread(message);
return true;
}
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/browser/gpu/gpu_process_host_ui_shim.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698