Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Unified Diff: content/browser/renderer_host/begin_frame_observer_proxy.cc

Issue 1408213002: Add hooks for flushing input from BeginFrame dispatch on Aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build for real Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/begin_frame_observer_proxy.cc
diff --git a/content/browser/renderer_host/begin_frame_observer_proxy.cc b/content/browser/renderer_host/begin_frame_observer_proxy.cc
index 06baa18bd2a128390dd6436cf581077043c0f5fc..5789c02ebd8fc743c1008aba71370b4088bbcdc8 100644
--- a/content/browser/renderer_host/begin_frame_observer_proxy.cc
+++ b/content/browser/renderer_host/begin_frame_observer_proxy.cc
@@ -9,9 +9,10 @@ namespace content {
BeginFrameObserverProxy::BeginFrameObserverProxy(
BeginFrameObserverProxyClient* client)
: needs_begin_frames_(false),
+ needs_one_begin_frame_(false),
+ observing_begin_frames_(false),
client_(client),
- compositor_(nullptr) {
-}
+ compositor_(nullptr) {}
BeginFrameObserverProxy::~BeginFrameObserverProxy() {
DCHECK(!compositor_);
@@ -22,16 +23,15 @@ void BeginFrameObserverProxy::SetNeedsBeginFrames(bool needs_begin_frames) {
return;
needs_begin_frames_ = needs_begin_frames;
+ UpdateBeginFrameObservation();
+}
- // In some cases, BeginFrame message is requested before |client_|'s window is
- // added in the root window hierarchy.
- if (!compositor_)
+void BeginFrameObserverProxy::SetNeedsOneBeginFrame() {
+ if (needs_one_begin_frame_)
return;
- if (needs_begin_frames)
- StartObservingBeginFrames();
- else
- StopObservingBeginFrames();
+ needs_one_begin_frame_ = true;
+ UpdateBeginFrameObservation();
}
void BeginFrameObserverProxy::SetCompositor(ui::Compositor* compositor) {
@@ -40,23 +40,26 @@ void BeginFrameObserverProxy::SetCompositor(ui::Compositor* compositor) {
compositor_ = compositor;
compositor_->AddObserver(this);
- if (needs_begin_frames_)
- StartObservingBeginFrames();
+ UpdateBeginFrameObservation();
}
void BeginFrameObserverProxy::ResetCompositor() {
if (!compositor_)
return;
compositor_->RemoveObserver(this);
-
- if (needs_begin_frames_)
- StopObservingBeginFrames();
+ StopObservingBeginFrames();
compositor_ = nullptr;
}
void BeginFrameObserverProxy::OnSendBeginFrame(const cc::BeginFrameArgs& args) {
- if (last_sent_begin_frame_args_.frame_time != args.frame_time)
+ DCHECK(needs_one_begin_frame_ || needs_begin_frames_);
+ if (last_sent_begin_frame_args_.frame_time != args.frame_time) {
+ // Don't immediately unsubscribe in case BeginFrame dispatch triggers
+ // another request.
+ needs_one_begin_frame_ = false;
client_->SendBeginFrame(args);
+ UpdateBeginFrameObservation();
+ }
last_sent_begin_frame_args_ = args;
}
@@ -65,14 +68,34 @@ void BeginFrameObserverProxy::OnCompositingShuttingDown(
ResetCompositor();
}
+void BeginFrameObserverProxy::UpdateBeginFrameObservation() {
+ // In some cases, BeginFrame message is requested before |client_|'s window is
+ // added in the root window hierarchy.
+ if (!compositor_) {
+ DCHECK(!observing_begin_frames_);
+ return;
+ }
+
+ if (needs_begin_frames_ || needs_one_begin_frame_)
+ StartObservingBeginFrames();
+ else
+ StopObservingBeginFrames();
+}
+
void BeginFrameObserverProxy::StartObservingBeginFrames() {
DCHECK(compositor_);
- compositor_->AddBeginFrameObserver(this);
+ if (!observing_begin_frames_) {
+ observing_begin_frames_ = true;
+ compositor_->AddBeginFrameObserver(this);
+ }
}
void BeginFrameObserverProxy::StopObservingBeginFrames() {
DCHECK(compositor_);
- compositor_->RemoveBeginFrameObserver(this);
+ if (observing_begin_frames_) {
+ observing_begin_frames_ = false;
+ compositor_->RemoveBeginFrameObserver(this);
+ }
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698