Commit 0f0f3a41 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Move Begin/EndCommitCompositorFrame and DidBeginMainFrame into base.

Move the duplicate implementation of these methods into the base class.

BUG=1097816

Change-Id: Ibc97bc14dbc246cbc7bdced0a53bb43afa96cfbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2526912
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826364}
parent a3fd7be3
......@@ -24,6 +24,7 @@
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_plugin.h"
#include "third_party/blink/public/web/web_settings.h"
#include "third_party/blink/public/web/web_view_client.h"
#include "third_party/blink/public/web/web_widget_client.h"
#include "third_party/blink/renderer/core/content_capture/content_capture_manager.h"
#include "third_party/blink/renderer/core/dom/element.h"
......@@ -878,6 +879,8 @@ WebFrameWidgetBase::AllocateNewLayerTreeFrameSink() {
void WebFrameWidgetBase::DidBeginMainFrame() {
Client()->DidBeginMainFrame();
DCHECK(LocalRootImpl()->GetFrame());
PageWidgetDelegate::DidBeginFrame(*LocalRootImpl()->GetFrame());
}
void WebFrameWidgetBase::WillBeginMainFrame() {
......@@ -1262,6 +1265,32 @@ void WebFrameWidgetBase::BeginMainFrame(base::TimeTicks last_frame_time) {
GetPage()->GetValidationMessageClient().LayoutOverlay();
}
void WebFrameWidgetBase::BeginCommitCompositorFrame() {
commit_compositor_frame_start_time_.emplace(base::TimeTicks::Now());
}
void WebFrameWidgetBase::EndCommitCompositorFrame(
base::TimeTicks commit_start_time) {
DCHECK(commit_compositor_frame_start_time_.has_value());
CHECK(LocalRootImpl());
CHECK(LocalRootImpl()->GetFrame());
CHECK(LocalRootImpl()->GetFrame()->View());
if (ForMainFrame()) {
View()->Client()->DidCommitCompositorFrameForLocalMainFrame(
commit_start_time);
View()->UpdatePreferredSize();
}
LocalRootImpl()
->GetFrame()
->View()
->EnsureUkmAggregator()
.RecordImplCompositorSample(commit_compositor_frame_start_time_.value(),
commit_start_time, base::TimeTicks::Now());
commit_compositor_frame_start_time_.reset();
}
void WebFrameWidgetBase::RecordDispatchRafAlignedInputTime(
base::TimeTicks raf_aligned_input_start_time) {
if (LocalRootImpl()) {
......
......@@ -349,6 +349,8 @@ class CORE_EXPORT WebFrameWidgetBase
// WidgetBaseClient methods.
void BeginMainFrame(base::TimeTicks last_frame_time) override;
void BeginCommitCompositorFrame() override;
void EndCommitCompositorFrame(base::TimeTicks commit_start_time) override;
void RecordDispatchRafAlignedInputTime(
base::TimeTicks raf_aligned_input_start_time) override;
void SetSuppressFrameRequestsWorkaroundFor704763Only(bool) override;
......@@ -800,6 +802,9 @@ class CORE_EXPORT WebFrameWidgetBase
// Set when a measurement begins, reset when the measurement is taken.
base::Optional<base::TimeTicks> update_layers_start_time_;
// Metrics for gathering time for commit of compositor frame.
base::Optional<base::TimeTicks> commit_compositor_frame_start_time_;
friend class WebViewImpl;
friend class ReportTimeSwapPromise;
};
......
......@@ -308,15 +308,6 @@ void WebFrameWidgetImpl::UpdateMainFrameLayoutSize() {
view->SetLayoutSize(WebSize(layout_size));
}
void WebFrameWidgetImpl::DidBeginMainFrame() {
DCHECK(LocalRootImpl()->GetFrame());
WebFrameWidgetBase::DidBeginMainFrame();
// TODO(szager): Investigate why WebViewFrameWidget::DidBeginMainFrame
// instantiates AllowThrottlingScope before calling
// PageWidgetDeleget::DidBeginFrame, but this method doesn't.
PageWidgetDelegate::DidBeginFrame(*LocalRootImpl()->GetFrame());
}
bool WebFrameWidgetImpl::ShouldHandleImeEvents() {
// TODO(ekaramad): WebViewWidgetImpl returns true only if it has focus.
// We track page focus in all RenderViews on the page but
......@@ -328,25 +319,6 @@ bool WebFrameWidgetImpl::ShouldHandleImeEvents() {
return LocalRootImpl();
}
void WebFrameWidgetImpl::BeginCommitCompositorFrame() {
if (LocalRootImpl()) {
commit_compositor_frame_start_time_.emplace(base::TimeTicks::Now());
}
}
void WebFrameWidgetImpl::EndCommitCompositorFrame(
base::TimeTicks commit_start_time) {
if (LocalRootImpl()) {
LocalRootImpl()
->GetFrame()
->View()
->EnsureUkmAggregator()
.RecordImplCompositorSample(commit_compositor_frame_start_time_.value(),
commit_start_time, base::TimeTicks::Now());
}
commit_compositor_frame_start_time_.reset();
}
void WebFrameWidgetImpl::UpdateLifecycle(WebLifecycleUpdate requested_update,
DocumentUpdateReason reason) {
TRACE_EVENT0("blink", "WebFrameWidgetImpl::updateAllLifecyclePhases");
......
......@@ -141,9 +141,6 @@ class WebFrameWidgetImpl final : public WebFrameWidgetBase {
bool ShouldHandleImeEvents() override;
// WidgetBaseClient overrides:
void BeginCommitCompositorFrame() override;
void EndCommitCompositorFrame(base::TimeTicks commit_start_time) override;
void DidBeginMainFrame() override;
void FocusChanged(bool enable) override;
gfx::Rect ViewportVisibleRect() override;
void DidCompletePageScaleAnimation() override;
......@@ -181,7 +178,6 @@ class WebFrameWidgetImpl final : public WebFrameWidgetBase {
// Metrics gathering timing information
base::Optional<base::TimeTicks> update_layers_start_time_;
base::Optional<base::TimeTicks> commit_compositor_frame_start_time_;
bool did_suspend_parsing_ = false;
......
......@@ -92,39 +92,6 @@ void WebViewFrameWidget::Resize(const gfx::Size& size) {
web_view_->Resize(size);
}
void WebViewFrameWidget::DidBeginMainFrame() {
WebFrameWidgetBase::DidBeginMainFrame();
auto* main_frame = web_view_->MainFrameImpl();
PageWidgetDelegate::DidBeginFrame(*main_frame->GetFrame());
}
void WebViewFrameWidget::BeginCommitCompositorFrame() {
commit_compositor_frame_start_time_.emplace(base::TimeTicks::Now());
}
void WebViewFrameWidget::EndCommitCompositorFrame(
base::TimeTicks commit_start_time) {
DCHECK(commit_compositor_frame_start_time_.has_value());
web_view_->Client()->DidCommitCompositorFrameForLocalMainFrame(
commit_start_time);
web_view_->UpdatePreferredSize();
// TODO(https://crbug.com/1139104): Remove these CHECKS.
CHECK(web_view_);
CHECK(web_view_->MainFrameImpl());
CHECK(web_view_->MainFrameImpl()->GetFrame());
CHECK(web_view_->MainFrameImpl()->GetFrame()->View());
web_view_->MainFrameImpl()
->GetFrame()
->View()
->EnsureUkmAggregator()
.RecordImplCompositorSample(commit_compositor_frame_start_time_.value(),
commit_start_time, base::TimeTicks::Now());
commit_compositor_frame_start_time_.reset();
}
void WebViewFrameWidget::UpdateLifecycle(WebLifecycleUpdate requested_update,
DocumentUpdateReason reason) {
web_view_->UpdateLifecycle(requested_update, reason);
......
......@@ -107,11 +107,8 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase {
float GetEmulatorScale() override;
// WidgetBaseClient overrides:
void DidBeginMainFrame() override;
void ApplyViewportChanges(const cc::ApplyViewportChangesArgs& args) override;
void RecordManipulationTypeCounts(cc::ManipulationInfo info) override;
void BeginCommitCompositorFrame() override;
void EndCommitCompositorFrame(base::TimeTicks commit_start_time) override;
void FocusChanged(bool enabled) override;
float GetDeviceScaleFactorForTesting() override;
gfx::Rect ViewportVisibleRect() override;
......@@ -152,7 +149,6 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase {
void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
scoped_refptr<WebViewImpl> web_view_;
base::Optional<base::TimeTicks> commit_compositor_frame_start_time_;
// Web tests override the zoom factor in the renderer with this. We store it
// to keep the override if the browser passes along VisualProperties with the
......
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