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

Unified Diff: content/public/browser/android/synchronous_compositor.cc

Issue 2347563003: Added FrameFuture class (Closed)
Patch Set: Code review Created 4 years, 3 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/public/browser/android/synchronous_compositor.cc
diff --git a/content/public/browser/android/synchronous_compositor.cc b/content/public/browser/android/synchronous_compositor.cc
index 616530fc7de376d22f2008ab69c58e33307bbb10..fbdc5b23e1cc4b4a7199c6872d3464e02560b3bb 100644
--- a/content/public/browser/android/synchronous_compositor.cc
+++ b/content/public/browser/android/synchronous_compositor.cc
@@ -18,6 +18,28 @@ SynchronousCompositor::Frame::Frame(Frame&& rhs)
: compositor_frame_sink_id(rhs.compositor_frame_sink_id),
frame(std::move(rhs.frame)) {}
+SynchronousCompositor::FrameFuture::FrameFuture()
+ : waitable_event_(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED) {}
+
+SynchronousCompositor::FrameFuture::~FrameFuture() {}
+
+void SynchronousCompositor::FrameFuture::setFrame(
+ std::unique_ptr<Frame> frame) {
+ frame_ = std::move(frame);
+ waitable_event_.Signal();
+}
+
+std::unique_ptr<SynchronousCompositor::Frame>
+SynchronousCompositor::FrameFuture::getFrame() {
+#if DCHECK_IS_ON()
+ DCHECK(!waited_);
+ waited_ = true;
+#endif
+ waitable_event_.Wait();
+ return std::move(frame_);
+}
+
SynchronousCompositor::Frame& SynchronousCompositor::Frame::operator=(
Frame&& rhs) {
compositor_frame_sink_id = rhs.compositor_frame_sink_id;

Powered by Google App Engine
This is Rietveld 408576698