Commit 5c5c1199 authored by Mohsen Izadi's avatar Mohsen Izadi Committed by Commit Bot

Remove connection filter upon GpuProcessHost destruction

GpuProcessHost installs a filter on ServiceManagerConnection. It should
be removed when GpuProcessHost is destroyed to avoid memory leak.

BUG=885393

Change-Id: I7621b52b6110f1e1671f0ec966477f1302fbc585
Reviewed-on: https://chromium-review.googlesource.com/c/1277945Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Mohsen Izadi <mohsen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599293}
parent b6201339
...@@ -660,6 +660,8 @@ GpuProcessHost::GpuProcessHost(int host_id, GpuProcessKind kind) ...@@ -660,6 +660,8 @@ GpuProcessHost::GpuProcessHost(int host_id, GpuProcessKind kind)
in_process_(false), in_process_(false),
kind_(kind), kind_(kind),
process_launched_(false), process_launched_(false),
connection_filter_id_(
ServiceManagerConnection::kInvalidConnectionFilterId),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSingleProcess) || switches::kSingleProcess) ||
...@@ -774,6 +776,11 @@ GpuProcessHost::~GpuProcessHost() { ...@@ -774,6 +776,11 @@ GpuProcessHost::~GpuProcessHost() {
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::BindOnce(&OnGpuProcessHostDestroyedOnUI, host_id_, message)); base::BindOnce(&OnGpuProcessHostDestroyedOnUI, host_id_, message));
if (ServiceManagerConnection::GetForProcess()) {
ServiceManagerConnection::GetForProcess()->RemoveConnectionFilter(
connection_filter_id_);
}
} }
bool GpuProcessHost::Init() { bool GpuProcessHost::Init() {
...@@ -783,8 +790,9 @@ bool GpuProcessHost::Init() { ...@@ -783,8 +790,9 @@ bool GpuProcessHost::Init() {
// May be null during test execution. // May be null during test execution.
if (ServiceManagerConnection::GetForProcess()) { if (ServiceManagerConnection::GetForProcess()) {
ServiceManagerConnection::GetForProcess()->AddConnectionFilter( connection_filter_id_ =
std::make_unique<ConnectionFilterImpl>(process_->GetData().id)); ServiceManagerConnection::GetForProcess()->AddConnectionFilter(
std::make_unique<ConnectionFilterImpl>(process_->GetData().id));
} }
process_->GetHost()->CreateChannelMojo(); process_->GetHost()->CreateChannelMojo();
......
...@@ -202,6 +202,8 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, ...@@ -202,6 +202,8 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
// Time Init started. Used to log total GPU process startup time to UMA. // Time Init started. Used to log total GPU process startup time to UMA.
base::TimeTicks init_start_time_; base::TimeTicks init_start_time_;
int connection_filter_id_;
// The total number of GPU process crashes. // The total number of GPU process crashes.
static base::subtle::Atomic32 gpu_crash_count_; static base::subtle::Atomic32 gpu_crash_count_;
static bool crashed_before_; static bool crashed_before_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment