Skip to content

Commit 39dd14f

Browse files
danakjCommit Bot
authored andcommitted
Remove DidCommitAndDrawCompositorFrame IPC.
This IPC was used for tests to synchronize with the renderer from the browser process. The RenderFrameSubmissionObserver does this job for us instead now and does not rely on legacy mojo or test-only IPCs. This CL converts the 3 test cases relying on the old IPC over to use the RenderFrameSubmissionObserver utility instead. R=avi@chromium.org, rouslan@chromium.org Bug: 419087 Change-Id: I61d3cf37f55bfbbf97e73f8523605613d4e9be39 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787406 Reviewed-by: Ken Buchanan <kenrb@chromium.org> Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org> Reviewed-by: Avi Drissman <avi@chromium.org> Commit-Queue: danakj <danakj@chromium.org> Cr-Commit-Position: refs/heads/master@{#694304}
1 parent 99d77bc commit 39dd14f

15 files changed

+42
-101
lines changed

chrome/browser/autofill/captured_sites_test_utils.cc

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,18 @@ PageActivityObserver::PageActivityObserver(content::RenderFrameHost* frame)
195195
void PageActivityObserver::WaitTillPageIsIdle(
196196
base::TimeDelta continuous_paint_timeout) {
197197
base::TimeTicks finished_load_time = base::TimeTicks::Now();
198-
bool page_is_loading = false;
199-
do {
200-
paint_occurred_during_last_loop_ = false;
201-
base::RunLoop heart_beat;
202-
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
203-
FROM_HERE, heart_beat.QuitClosure(), kPaintEventCheckInterval);
204-
heart_beat.Run();
205-
page_is_loading =
198+
while (true) {
199+
content::RenderFrameSubmissionObserver frame_submission_observer(
200+
web_contents());
201+
// Runs a loop for kPaintEventCheckInterval to see if the renderer is
202+
// idle.
203+
{
204+
base::RunLoop heart_beat;
205+
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
206+
FROM_HERE, heart_beat.QuitClosure(), kPaintEventCheckInterval);
207+
heart_beat.Run();
208+
}
209+
bool page_is_loading =
206210
web_contents()->IsWaitingForResponse() || web_contents()->IsLoading();
207211
if (page_is_loading) {
208212
finished_load_time = base::TimeTicks::Now();
@@ -214,13 +218,19 @@ void PageActivityObserver::WaitTillPageIsIdle(
214218
// blinking caret or a persistent animation is making Chrome paint at
215219
// regular intervals. Exit.
216220
break;
221+
} else if (frame_submission_observer.render_frame_count() == 0) {
222+
// If the renderer has stopped submitting frames for the waiting interval
223+
// then we're done.
224+
break;
217225
}
218-
} while (page_is_loading || paint_occurred_during_last_loop_);
226+
}
219227
}
220228

221229
bool PageActivityObserver::WaitForVisualUpdate(base::TimeDelta timeout) {
222230
base::TimeTicks start_time = base::TimeTicks::Now();
223-
while (!paint_occurred_during_last_loop_) {
231+
content::RenderFrameSubmissionObserver frame_submission_observer(
232+
web_contents());
233+
while (frame_submission_observer.render_frame_count() == 0) {
224234
base::RunLoop heart_beat;
225235
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
226236
FROM_HERE, heart_beat.QuitClosure(), kPaintEventCheckInterval);
@@ -232,10 +242,6 @@ bool PageActivityObserver::WaitForVisualUpdate(base::TimeDelta timeout) {
232242
return true;
233243
}
234244

235-
void PageActivityObserver::DidCommitAndDrawCompositorFrame() {
236-
paint_occurred_during_last_loop_ = true;
237-
}
238-
239245
// FrameObserver --------------------------------------------------------------
240246
IFrameWaiter::IFrameWaiter(content::WebContents* web_contents)
241247
: content::WebContentsObserver(web_contents),

chrome/browser/autofill/captured_sites_test_utils.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,11 @@ class PageActivityObserver : public content::WebContentsObserver {
117117

118118
private:
119119
// PageActivityObserver determines if Chrome stopped painting by checking if
120-
// Chrome hasn't painted for a specific amount of time.
121-
// kPaintEventCheckInterval defines this amount of time.
120+
// the renderer hasn't submitted a compositor frame for a specific amount of
121+
// time. kPaintEventCheckInterval defines this amount of time.
122122
static constexpr base::TimeDelta kPaintEventCheckInterval =
123123
base::TimeDelta::FromMilliseconds(500);
124124

125-
// content::WebContentsObserver:
126-
void DidCommitAndDrawCompositorFrame() override;
127-
128-
bool paint_occurred_during_last_loop_ = false;
129-
130125
DISALLOW_COPY_AND_ASSIGN(PageActivityObserver);
131126
};
132127

chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos_browsertest.cc

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,32 +1164,6 @@ IN_PROC_BROWSER_TEST_F(TopControlsSlideControllerTest, TestPermissionBubble) {
11641164
TopChromeShownState::kFullyHidden);
11651165
}
11661166

1167-
// Waits for a compositor frame to be drawn and committed on the given
1168-
// web_contents.
1169-
class CompositorFrameWaiter : content::WebContentsObserver {
1170-
public:
1171-
explicit CompositorFrameWaiter(content::WebContents* contents)
1172-
: WebContentsObserver(contents) {}
1173-
~CompositorFrameWaiter() override = default;
1174-
1175-
void Wait() {
1176-
run_loop_ = std::make_unique<base::RunLoop>();
1177-
run_loop_->Run();
1178-
run_loop_.reset();
1179-
}
1180-
1181-
// content::WebContentsObserver:
1182-
void DidCommitAndDrawCompositorFrame() override {
1183-
if (run_loop_)
1184-
run_loop_->Quit();
1185-
}
1186-
1187-
private:
1188-
std::unique_ptr<base::RunLoop> run_loop_;
1189-
1190-
DISALLOW_COPY_AND_ASSIGN(CompositorFrameWaiter);
1191-
};
1192-
11931167
IN_PROC_BROWSER_TEST_F(TopControlsSlideControllerTest, TestToggleChromeVox) {
11941168
ToggleTabletMode();
11951169
ASSERT_TRUE(GetTabletModeEnabled());
@@ -1220,9 +1194,10 @@ IN_PROC_BROWSER_TEST_F(TopControlsSlideControllerTest, TestToggleChromeVox) {
12201194

12211195
// Now disable Chromevox, and expect it's now possible to hide top-chrome with
12221196
// gesture scrolling.
1223-
CompositorFrameWaiter compositor_frame_waiter(active_contents);
1197+
content::RenderFrameSubmissionObserver compositor_frame_waiter(
1198+
active_contents);
12241199
chromeos::AccessibilityManager::Get()->EnableSpokenFeedback(false);
1225-
compositor_frame_waiter.Wait();
1200+
compositor_frame_waiter.WaitForAnyFrameSubmission();
12261201
content::WaitForResizeComplete(active_contents);
12271202
EXPECT_FALSE(
12281203
chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled());

components/autofill_assistant/browser/web/web_controller_browsertest.cc

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,25 @@ class WebControllerBrowserTest : public content::ContentBrowserTest,
4646
Observe(shell()->web_contents());
4747
}
4848

49-
void DidCommitAndDrawCompositorFrame() override {
50-
paint_occurred_during_last_loop_ = true;
51-
}
52-
5349
void SetUpCommandLine(base::CommandLine* command_line) override {
5450
ContentBrowserTest::SetUpCommandLine(command_line);
5551
command_line->AppendSwitch("allow-pre-commit-input");
5652
}
5753

5854
void WaitTillPageIsIdle(base::TimeDelta continuous_paint_timeout) {
5955
base::TimeTicks finished_load_time = base::TimeTicks::Now();
60-
bool page_is_loading = false;
61-
do {
62-
paint_occurred_during_last_loop_ = false;
63-
base::RunLoop heart_beat;
64-
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
65-
FROM_HERE, heart_beat.QuitClosure(), base::TimeDelta::FromSeconds(3));
66-
heart_beat.Run();
67-
page_is_loading =
56+
while (true) {
57+
content::RenderFrameSubmissionObserver frame_submission_observer(
58+
web_contents());
59+
// Runs a loop for 3 seconds to see if the renderer is idle.
60+
{
61+
base::RunLoop heart_beat;
62+
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
63+
FROM_HERE, heart_beat.QuitClosure(),
64+
base::TimeDelta::FromSeconds(3));
65+
heart_beat.Run();
66+
}
67+
bool page_is_loading =
6868
web_contents()->IsWaitingForResponse() || web_contents()->IsLoading();
6969
if (page_is_loading) {
7070
finished_load_time = base::TimeTicks::Now();
@@ -76,8 +76,12 @@ class WebControllerBrowserTest : public content::ContentBrowserTest,
7676
// blinking caret or a persistent animation is making Chrome paint at
7777
// regular intervals. Exit.
7878
break;
79+
} else if (frame_submission_observer.render_frame_count() == 0) {
80+
// If the renderer has stopped submitting frames for 3 seconds then
81+
// we're done.
82+
break;
7983
}
80-
} while (page_is_loading || paint_occurred_during_last_loop_);
84+
}
8185
}
8286

8387
void RunStrictElementCheck(const Selector& selector, bool result) {
@@ -461,7 +465,6 @@ class WebControllerBrowserTest : public content::ContentBrowserTest,
461465

462466
private:
463467
std::unique_ptr<net::EmbeddedTestServer> http_server_;
464-
bool paint_occurred_during_last_loop_ = false;
465468
ClientSettings settings_;
466469

467470
DISALLOW_COPY_AND_ASSIGN(WebControllerBrowserTest);

content/browser/renderer_host/render_view_host_delegate.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,6 @@ class CONTENT_EXPORT RenderViewHostDelegate {
194194
// The RenderView finished the first visually non-empty paint.
195195
virtual void DidFirstVisuallyNonEmptyPaint(RenderViewHostImpl* source) {}
196196

197-
// The RenderView has issued a draw command, signaling the it
198-
// has been visually updated.
199-
virtual void DidCommitAndDrawCompositorFrame(RenderViewHostImpl* source) {}
200-
201197
// Returns true if the render view is rendering a portal.
202198
virtual bool IsPortal() const;
203199

content/browser/renderer_host/render_view_host_impl.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,6 @@ void RenderViewHostImpl::RenderWidgetDidFirstVisuallyNonEmptyPaint() {
787787
delegate_->DidFirstVisuallyNonEmptyPaint(this);
788788
}
789789

790-
void RenderViewHostImpl::RenderWidgetDidCommitAndDrawCompositorFrame() {
791-
delegate_->DidCommitAndDrawCompositorFrame(this);
792-
}
793-
794790
bool RenderViewHostImpl::SuddenTerminationAllowed() const {
795791
return sudden_termination_allowed_;
796792
}

content/browser/renderer_host/render_view_host_impl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ class CONTENT_EXPORT RenderViewHostImpl
219219
void RenderWidgetDidInit() override;
220220
void RenderWidgetDidClose() override;
221221
void RenderWidgetDidFirstVisuallyNonEmptyPaint() override;
222-
void RenderWidgetDidCommitAndDrawCompositorFrame() override;
223222
void RenderWidgetGotFocus() override;
224223
void RenderWidgetLostFocus() override;
225224
void RenderWidgetDidForwardMouseEvent(

content/browser/renderer_host/render_widget_host_impl.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,6 @@ bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) {
645645
OnForceRedrawComplete)
646646
IPC_MESSAGE_HANDLER(WidgetHostMsg_DidFirstVisuallyNonEmptyPaint,
647647
OnFirstVisuallyNonEmptyPaint)
648-
IPC_MESSAGE_HANDLER(WidgetHostMsg_DidCommitAndDrawCompositorFrame,
649-
OnCommitAndDrawCompositorFrame)
650648
IPC_MESSAGE_HANDLER(WidgetHostMsg_HasTouchEventHandlers,
651649
OnHasTouchEventHandlers)
652650
IPC_MESSAGE_HANDLER(WidgetHostMsg_IntrinsicSizingInfoChanged,
@@ -1838,11 +1836,6 @@ void RenderWidgetHostImpl::OnFirstVisuallyNonEmptyPaint() {
18381836
owner_delegate_->RenderWidgetDidFirstVisuallyNonEmptyPaint();
18391837
}
18401838

1841-
void RenderWidgetHostImpl::OnCommitAndDrawCompositorFrame() {
1842-
if (owner_delegate_)
1843-
owner_delegate_->RenderWidgetDidCommitAndDrawCompositorFrame();
1844-
}
1845-
18461839
void RenderWidgetHostImpl::RendererExited() {
18471840
if (!renderer_initialized_)
18481841
return;

content/browser/renderer_host/render_widget_host_owner_delegate.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ class CONTENT_EXPORT RenderWidgetHostOwnerDelegate {
4141
// The RenderWidget finished the first visually non-empty paint.
4242
virtual void RenderWidgetDidFirstVisuallyNonEmptyPaint() = 0;
4343

44-
// The RenderWidget has issued a draw command, signaling the widget
45-
// has been visually updated.
46-
virtual void RenderWidgetDidCommitAndDrawCompositorFrame() = 0;
47-
4844
// The RenderWidgetHost got the focus.
4945
virtual void RenderWidgetGotFocus() = 0;
5046

content/browser/web_contents/web_contents_impl.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5117,12 +5117,6 @@ void WebContentsImpl::DidFirstVisuallyNonEmptyPaint(
51175117
}
51185118
}
51195119

5120-
void WebContentsImpl::DidCommitAndDrawCompositorFrame(
5121-
RenderViewHostImpl* source) {
5122-
for (auto& observer : observers_)
5123-
observer.DidCommitAndDrawCompositorFrame();
5124-
}
5125-
51265120
bool WebContentsImpl::IsPortal() const {
51275121
return portal();
51285122
}

content/browser/web_contents/web_contents_impl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,6 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
698698
bool IsSpatialNavigationDisabled() const override;
699699
RenderFrameHost* GetPendingMainFrame() override;
700700
void DidFirstVisuallyNonEmptyPaint(RenderViewHostImpl* source) override;
701-
void DidCommitAndDrawCompositorFrame(RenderViewHostImpl* source) override;
702701
bool IsPortal() const override;
703702

704703
// NavigatorDelegate ---------------------------------------------------------

content/common/widget_messages.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,6 @@ IPC_MESSAGE_ROUTED0(WidgetHostMsg_WaitForNextFrameForTests_ACK)
333333
// after the frame widget has painted something.
334334
IPC_MESSAGE_ROUTED0(WidgetHostMsg_DidFirstVisuallyNonEmptyPaint)
335335

336-
// Sent once the RenderWidgetCompositor issues a draw command.
337-
IPC_MESSAGE_ROUTED0(WidgetHostMsg_DidCommitAndDrawCompositorFrame)
338-
339336
// Notifies whether there are JavaScript touch event handlers or not.
340337
IPC_MESSAGE_ROUTED1(WidgetHostMsg_HasTouchEventHandlers,
341338
bool /* has_handlers */)

content/public/browser/web_contents_observer.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,6 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener {
568568
const std::string& interface_name,
569569
mojo::ScopedMessagePipeHandle* interface_pipe) {}
570570

571-
// Notifies that the RenderWidgetCompositor has issued a draw command. An
572-
// observer can use this method to detect when Chrome visually updated a
573-
// tab.
574-
virtual void DidCommitAndDrawCompositorFrame() {}
575-
576571
// Called when "audible" playback starts or stops on a WebAudio AudioContext.
577572
using AudioContextId = std::pair<RenderFrameHost*, int>;
578573
virtual void AudioContextPlaybackStarted(

content/renderer/render_widget.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,6 @@ void RenderWidget::DidCommitAndDrawCompositorFrame() {
12171217

12181218
// Notify subclasses that we initiated the paint operation.
12191219
DidInitiatePaint();
1220-
1221-
Send(new WidgetHostMsg_DidCommitAndDrawCompositorFrame(routing_id_));
12221220
}
12231221

12241222
void RenderWidget::WillCommitCompositorFrame() {

content/test/stub_render_widget_host_owner_delegate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class StubRenderWidgetHostOwnerDelegate : public RenderWidgetHostOwnerDelegate {
1414
void RenderWidgetDidInit() override {}
1515
void RenderWidgetDidClose() override {}
1616
void RenderWidgetDidFirstVisuallyNonEmptyPaint() override {}
17-
void RenderWidgetDidCommitAndDrawCompositorFrame() override {}
1817
void RenderWidgetGotFocus() override {}
1918
void RenderWidgetLostFocus() override {}
2019
void RenderWidgetDidForwardMouseEvent(

0 commit comments

Comments
 (0)