Commit 8fc7b4dd authored by dalecurtis's avatar dalecurtis Committed by Commit bot

Cleanup power save blockers after a RenderView crashes.

Looks like RenderFrameDeleted() wasn't called if a RenderView
crashes, which results in the WebContents having some lingering
power save blockers and media player entries.

BUG=455943
TEST=new unittest. DCHECK() no longer fires.

Review URL: https://codereview.chromium.org/886603009

Cr-Commit-Position: refs/heads/master@{#314934}
parent 473ff677
...@@ -3663,6 +3663,10 @@ void WebContentsImpl::RenderViewReady(RenderViewHost* rvh) { ...@@ -3663,6 +3663,10 @@ void WebContentsImpl::RenderViewReady(RenderViewHost* rvh) {
void WebContentsImpl::RenderViewTerminated(RenderViewHost* rvh, void WebContentsImpl::RenderViewTerminated(RenderViewHost* rvh,
base::TerminationStatus status, base::TerminationStatus status,
int error_code) { int error_code) {
// TODO(nasko): This isn't ideal; the termination process should be handled by
// RenderFrameDeleted(). See http://crbug.com/455943.
ClearPowerSaveBlockers(rvh->GetMainFrame());
if (rvh != GetRenderViewHost()) { if (rvh != GetRenderViewHost()) {
// The pending page's RenderViewHost is gone. // The pending page's RenderViewHost is gone.
return; return;
......
...@@ -2977,6 +2977,24 @@ TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) { ...@@ -2977,6 +2977,24 @@ TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) {
FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId));
EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing());
EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing());
// Start a player with both audio and video. A video power save blocker
// should be created. If audio stream monitoring is available, an audio power
// save blocker should be created too.
rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification(
0, kPlayerAudioVideoId, true, true, false));
EXPECT_TRUE(contents()->has_video_power_save_blocker_for_testing());
EXPECT_EQ(contents()->has_audio_power_save_blocker_for_testing(),
!AudioStreamMonitor::monitoring_available());
// Crash the renderer.
contents()->GetMainFrame()->GetRenderViewHost()->OnMessageReceived(
ViewHostMsg_RenderProcessGone(
0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
// Verify that all the power save blockers have been released.
EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing());
EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing());
} }
#endif #endif
......
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