Commit 68cf62dd authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

android: Fix visible ProcessedCrashCounts

NOTIFICATION_RENDERER_PROCESS_CLOSED is sent after all clients of
RenderProcessHostImpl has been removed, so it is no longer possible to
determine if the process was "visible" or not.

Instead add a renderer_has_visible_clients and renderer_was_subframe
to ChildProcessTerminationInfo instead and pass that up in the
notification.

Bug: 965599
Change-Id: I176dc838b5e142303c3acbc11e08b967dd585cc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1622737
Commit-Queue: Bo <boliu@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662243}
parent 736de469
......@@ -41,6 +41,9 @@ void PopulateTerminationInfo(
info->best_effort_reverse_rank = content_info.best_effort_reverse_rank;
info->was_oom_protected_status =
content_info.status == base::TERMINATION_STATUS_OOM_PROTECTED;
info->renderer_has_visible_clients =
content_info.renderer_has_visible_clients;
info->renderer_was_subframe = content_info.renderer_was_subframe;
}
} // namespace
......
......@@ -3439,6 +3439,7 @@ void RenderProcessHostImpl::Cleanup() {
false /* already_dead */);
info.status = base::TERMINATION_STATUS_NORMAL_TERMINATION;
info.exit_code = 0;
PopulateTerminationInfoRendererFields(&info);
for (auto& observer : observers_) {
observer.RenderProcessExited(this, info);
}
......@@ -3496,6 +3497,12 @@ void RenderProcessHostImpl::Cleanup() {
std::make_unique<base::WeakPtrFactory<RenderProcessHostImpl>>(this);
}
void RenderProcessHostImpl::PopulateTerminationInfoRendererFields(
ChildProcessTerminationInfo* info) {
info->renderer_has_visible_clients = VisibleClientCount() > 0;
info->renderer_was_subframe = GetFrameDepth() > 0;
}
void RenderProcessHostImpl::AddPendingView() {
const bool had_pending_views = pending_views_++;
if (!had_pending_views)
......@@ -4121,6 +4128,7 @@ void RenderProcessHostImpl::ProcessDied(
#endif
}
}
PopulateTerminationInfoRendererFields(&info);
child_process_launcher_.reset();
is_dead_ = true;
......@@ -4480,6 +4488,7 @@ void RenderProcessHostImpl::OnProcessLaunchFailed(int error_code) {
ChildProcessTerminationInfo info;
info.status = base::TERMINATION_STATUS_LAUNCH_FAILED;
info.exit_code = error_code;
PopulateTerminationInfoRendererFields(&info);
ProcessDied(true, &info);
}
......
......@@ -647,6 +647,7 @@ class CONTENT_EXPORT RenderProcessHostImpl
base::FilePath GetAecDumpFilePathWithExtensions(const base::FilePath& file);
base::SequencedTaskRunner& GetAecDumpFileTaskRunner();
void NotifyRendererIfLockedToSite();
void PopulateTerminationInfoRendererFields(ChildProcessTerminationInfo* info);
static void OnMojoError(int render_process_id, const std::string& error);
......
......@@ -34,6 +34,15 @@ struct CONTENT_EXPORT ChildProcessTerminationInfo {
// ChildProcessTerminationInfo is computed.
base::TimeDelta uptime = base::TimeDelta::Max();
// Populated only for renderer process. True if there are any visible
// clients at the time of process death.
bool renderer_has_visible_clients = false;
// Populated only for renderer process. True if
// RenderProcessHost::GetFrameDepth is bigger than 0. Note this is not exactly
// the same as not having main frames.
bool renderer_was_subframe = false;
#if defined(OS_ANDROID)
// True if child service has strong or moderate binding at time of death.
base::android::ChildBindingState binding_state =
......
......@@ -96,6 +96,8 @@ void MockRenderProcessHost::SimulateRenderProcessExit(
ChildProcessTerminationInfo termination_info;
termination_info.status = status;
termination_info.exit_code = exit_code;
termination_info.renderer_has_visible_clients = VisibleClientCount() > 0;
termination_info.renderer_was_subframe = GetFrameDepth() > 0;
NotificationService::current()->Notify(
NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this),
Details<ChildProcessTerminationInfo>(&termination_info));
......
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