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

Unified Diff: blimp/engine/renderer/frame_scheduler.h

Issue 2413063002: content/blimp: Set up hooks for enabling LTHRemote in the renderer. (Closed)
Patch Set: Rebase Created 4 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: blimp/engine/renderer/frame_scheduler.h
diff --git a/blimp/engine/renderer/frame_scheduler.h b/blimp/engine/renderer/frame_scheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..5f9dc79e622a64a349da1c37883b2acd52acba75
--- /dev/null
+++ b/blimp/engine/renderer/frame_scheduler.h
@@ -0,0 +1,88 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BLIMP_ENGINE_RENDERER_FRAME_SCHEDULER_H_
+#define BLIMP_ENGINE_RENDERER_FRAME_SCHEDULER_H_
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/timer/timer.h"
+
+namespace blimp {
+namespace engine {
+
+class FrameSchedulerClient {
+ public:
+ virtual ~FrameSchedulerClient() {}
+
+ // Used to notify the SchedulerClient to start the requested frame update.
Wez 2016/10/20 23:53:27 nit: SchedulerClient naming, here and elsewhere.
Wez 2016/10/25 21:50:09 Pingy
Khushal 2016/10/26 00:01:40 Done.
+ // Calling this method marks the completion of the frame update request made
+ // to the scheduler. Any calls to schedule a frame after this will result in
+ // a new frame update.
+ virtual void StartFrameUpdate() = 0;
+};
+
+// Responsible for scheduling frame updates sent to the client.
+// The Scheduler uses the state of frames sent to the client and the
+// acknowledgements for these frames from the client to make decisions regarding
+// when a frame should be produced on the engine.
+// The caller provides a SchedulerClient to be notified when a frame update
+// should be produced. The SchedulerClient must outlive this class.
+class FrameScheduler {
+ public:
+ FrameScheduler(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ FrameSchedulerClient* client);
+ virtual ~FrameScheduler();
+
+ // Called when the |client| wants to start a frame update on the engine.
+ void ScheduleFrameUpdate();
+
+ // Called when a frame update is sent to the client.
+ void DidSendFrameUpdateToClient();
+
+ // Called when an Ack is received for a frame sent to the client.
+ void DidReceiveFrameUpdateAck();
+
+ base::TimeTicks next_frame_time() const { return next_frame_time_; }
Wez 2016/10/20 23:53:27 Can this be removed? I can't see anything using it
Khushal 2016/10/21 00:03:11 Oh, I think some test was. Will remove.
Khushal 2016/10/24 22:49:09 Done.
+
+ protected:
+ // protected for testing.
+ FrameScheduler(base::TimeDelta frame_delay,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ FrameSchedulerClient* client);
+
+ private:
+ void ScheduleFrameUpdateIfNecessary();
+
+ // Returns true if a frame update can be started. The Scheduler can not
+ // produce new frames either if there is no request for frames pending or we
+ // are waiting for an ack for a frame previously sent to the client.
+ bool ShouldProduceFrameUpdates() const;
+
+ void StartFrameUpdate();
+
+ // Set to true if the |client_| has requested us to schedule frames.
+ bool needs_frame_update_ = false;
+
+ // Set to true if a frame update was sent to the client and the ack is
+ // pending.
+ bool frame_ack_pending_ = false;
+
+ // The time at which the next main frame update can be run.
+ base::TimeTicks next_frame_time_;
+
+ // The delay to use between consecutive frames.
+ base::TimeDelta frame_delay_;
+
+ base::OneShotTimer frame_tick_timer_;
+
+ FrameSchedulerClient* client_;
+
+ DISALLOW_COPY_AND_ASSIGN(FrameScheduler);
+};
+
+} // namespace engine
+} // namespace blimp
+
+#endif // BLIMP_ENGINE_RENDERER_FRAME_SCHEDULER_H_

Powered by Google App Engine
This is Rietveld 408576698