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 @@ ...@@ -24,6 +24,7 @@
#include "third_party/blink/public/web/web_local_frame_client.h" #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_plugin.h"
#include "third_party/blink/public/web/web_settings.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/public/web/web_widget_client.h"
#include "third_party/blink/renderer/core/content_capture/content_capture_manager.h" #include "third_party/blink/renderer/core/content_capture/content_capture_manager.h"
#include "third_party/blink/renderer/core/dom/element.h" #include "third_party/blink/renderer/core/dom/element.h"
...@@ -878,6 +879,8 @@ WebFrameWidgetBase::AllocateNewLayerTreeFrameSink() { ...@@ -878,6 +879,8 @@ WebFrameWidgetBase::AllocateNewLayerTreeFrameSink() {
void WebFrameWidgetBase::DidBeginMainFrame() { void WebFrameWidgetBase::DidBeginMainFrame() {
Client()->DidBeginMainFrame(); Client()->DidBeginMainFrame();
DCHECK(LocalRootImpl()->GetFrame());
PageWidgetDelegate::DidBeginFrame(*LocalRootImpl()->GetFrame());
} }
void WebFrameWidgetBase::WillBeginMainFrame() { void WebFrameWidgetBase::WillBeginMainFrame() {
...@@ -1262,6 +1265,32 @@ void WebFrameWidgetBase::BeginMainFrame(base::TimeTicks last_frame_time) { ...@@ -1262,6 +1265,32 @@ void WebFrameWidgetBase::BeginMainFrame(base::TimeTicks last_frame_time) {
GetPage()->GetValidationMessageClient().LayoutOverlay(); 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( void WebFrameWidgetBase::RecordDispatchRafAlignedInputTime(
base::TimeTicks raf_aligned_input_start_time) { base::TimeTicks raf_aligned_input_start_time) {
if (LocalRootImpl()) { if (LocalRootImpl()) {
......
...@@ -349,6 +349,8 @@ class CORE_EXPORT WebFrameWidgetBase ...@@ -349,6 +349,8 @@ class CORE_EXPORT WebFrameWidgetBase
// WidgetBaseClient methods. // WidgetBaseClient methods.
void BeginMainFrame(base::TimeTicks last_frame_time) override; void BeginMainFrame(base::TimeTicks last_frame_time) override;
void BeginCommitCompositorFrame() override;
void EndCommitCompositorFrame(base::TimeTicks commit_start_time) override;
void RecordDispatchRafAlignedInputTime( void RecordDispatchRafAlignedInputTime(
base::TimeTicks raf_aligned_input_start_time) override; base::TimeTicks raf_aligned_input_start_time) override;
void SetSuppressFrameRequestsWorkaroundFor704763Only(bool) override; void SetSuppressFrameRequestsWorkaroundFor704763Only(bool) override;
...@@ -800,6 +802,9 @@ class CORE_EXPORT WebFrameWidgetBase ...@@ -800,6 +802,9 @@ class CORE_EXPORT WebFrameWidgetBase
// Set when a measurement begins, reset when the measurement is taken. // Set when a measurement begins, reset when the measurement is taken.
base::Optional<base::TimeTicks> update_layers_start_time_; 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 WebViewImpl;
friend class ReportTimeSwapPromise; friend class ReportTimeSwapPromise;
}; };
......
...@@ -308,15 +308,6 @@ void WebFrameWidgetImpl::UpdateMainFrameLayoutSize() { ...@@ -308,15 +308,6 @@ void WebFrameWidgetImpl::UpdateMainFrameLayoutSize() {
view->SetLayoutSize(WebSize(layout_size)); 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() { bool WebFrameWidgetImpl::ShouldHandleImeEvents() {
// TODO(ekaramad): WebViewWidgetImpl returns true only if it has focus. // TODO(ekaramad): WebViewWidgetImpl returns true only if it has focus.
// We track page focus in all RenderViews on the page but // We track page focus in all RenderViews on the page but
...@@ -328,25 +319,6 @@ bool WebFrameWidgetImpl::ShouldHandleImeEvents() { ...@@ -328,25 +319,6 @@ bool WebFrameWidgetImpl::ShouldHandleImeEvents() {
return LocalRootImpl(); 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, void WebFrameWidgetImpl::UpdateLifecycle(WebLifecycleUpdate requested_update,
DocumentUpdateReason reason) { DocumentUpdateReason reason) {
TRACE_EVENT0("blink", "WebFrameWidgetImpl::updateAllLifecyclePhases"); TRACE_EVENT0("blink", "WebFrameWidgetImpl::updateAllLifecyclePhases");
......
...@@ -141,9 +141,6 @@ class WebFrameWidgetImpl final : public WebFrameWidgetBase { ...@@ -141,9 +141,6 @@ class WebFrameWidgetImpl final : public WebFrameWidgetBase {
bool ShouldHandleImeEvents() override; bool ShouldHandleImeEvents() override;
// WidgetBaseClient overrides: // WidgetBaseClient overrides:
void BeginCommitCompositorFrame() override;
void EndCommitCompositorFrame(base::TimeTicks commit_start_time) override;
void DidBeginMainFrame() override;
void FocusChanged(bool enable) override; void FocusChanged(bool enable) override;
gfx::Rect ViewportVisibleRect() override; gfx::Rect ViewportVisibleRect() override;
void DidCompletePageScaleAnimation() override; void DidCompletePageScaleAnimation() override;
...@@ -181,7 +178,6 @@ class WebFrameWidgetImpl final : public WebFrameWidgetBase { ...@@ -181,7 +178,6 @@ class WebFrameWidgetImpl final : public WebFrameWidgetBase {
// Metrics gathering timing information // Metrics gathering timing information
base::Optional<base::TimeTicks> update_layers_start_time_; base::Optional<base::TimeTicks> update_layers_start_time_;
base::Optional<base::TimeTicks> commit_compositor_frame_start_time_;
bool did_suspend_parsing_ = false; bool did_suspend_parsing_ = false;
......
...@@ -92,39 +92,6 @@ void WebViewFrameWidget::Resize(const gfx::Size& size) { ...@@ -92,39 +92,6 @@ void WebViewFrameWidget::Resize(const gfx::Size& size) {
web_view_->Resize(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, void WebViewFrameWidget::UpdateLifecycle(WebLifecycleUpdate requested_update,
DocumentUpdateReason reason) { DocumentUpdateReason reason) {
web_view_->UpdateLifecycle(requested_update, reason); web_view_->UpdateLifecycle(requested_update, reason);
......
...@@ -107,11 +107,8 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase { ...@@ -107,11 +107,8 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase {
float GetEmulatorScale() override; float GetEmulatorScale() override;
// WidgetBaseClient overrides: // WidgetBaseClient overrides:
void DidBeginMainFrame() override;
void ApplyViewportChanges(const cc::ApplyViewportChangesArgs& args) override; void ApplyViewportChanges(const cc::ApplyViewportChangesArgs& args) override;
void RecordManipulationTypeCounts(cc::ManipulationInfo info) override; void RecordManipulationTypeCounts(cc::ManipulationInfo info) override;
void BeginCommitCompositorFrame() override;
void EndCommitCompositorFrame(base::TimeTicks commit_start_time) override;
void FocusChanged(bool enabled) override; void FocusChanged(bool enabled) override;
float GetDeviceScaleFactorForTesting() override; float GetDeviceScaleFactorForTesting() override;
gfx::Rect ViewportVisibleRect() override; gfx::Rect ViewportVisibleRect() override;
...@@ -152,7 +149,6 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase { ...@@ -152,7 +149,6 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase {
void SetWindowRectSynchronously(const gfx::Rect& new_window_rect); void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
scoped_refptr<WebViewImpl> web_view_; 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 // 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 // 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