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

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

Issue 2413063002: content/blimp: Set up hooks for enabling LTHRemote in the renderer. (Closed)
Patch Set: Addressed comments 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
« no previous file with comments | « blimp/engine/renderer/blimp_remote_compositor_bridge.cc ('k') | blimp/engine/renderer/scheduler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/engine/renderer/scheduler.h
diff --git a/blimp/engine/renderer/scheduler.h b/blimp/engine/renderer/scheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..b437b577d07c9f46dda6b4719a095266e2b9576b
--- /dev/null
+++ b/blimp/engine/renderer/scheduler.h
@@ -0,0 +1,86 @@
+// 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_SCHEDULER_H_
+#define BLIMP_ENGINE_RENDERER_SCHEDULER_H_
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/timer/timer.h"
+
+namespace blimp {
+namespace engine {
+
+class SchedulerClient {
+ public:
+ virtual ~SchedulerClient() {}
+
+ // Used to notify the SchedulerClient to synchronously start the requested
+ // frame.
Wez 2016/10/19 22:01:34 Sorry, meant to comment last time; it's not clear
Khushal 2016/10/20 01:29:33 I wanted to write synchronously because the assump
+ 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 user provides the SchedulerClient to be notified of when a frame update
Wez 2016/10/19 22:01:34 nit: s/user/caller s/the/a
Khushal 2016/10/20 01:29:33 Done.
Khushal 2016/10/20 01:29:33 Done.
+// should be produced. The SchedulerClient must outlive this class.
+class Scheduler {
Wez 2016/10/19 22:01:34 nit: Scheduler seems awfully generic for something
Khushal 2016/10/20 01:29:33 I renamed it to FrameScheduler. I think FrameSched
+ public:
+ Scheduler(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ SchedulerClient* client);
+ virtual ~Scheduler();
+
+ // Called when the |client| wants to start a frame update on the engine.
+ void SetNeedsFrameUpdate();
+
+ // 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_; }
+
+ protected:
+ // protected for testing.
+ Scheduler(base::TimeDelta frame_delay,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ SchedulerClient* client);
+
+ private:
+ void ScheduleMainFrameIfNecessary();
+
+ // Returns true if a main frame update can be started. The Scheduler can not
+ // produce new frames either if there is no request for main frames pending
+ // or we are waiting for an ack for a frame previously sent to the client.
+ bool CanProduceMainFrames() const;
+
+ void StartMainFrame();
+
+ // 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_;
+
+ SchedulerClient* client_;
+
+ DISALLOW_COPY_AND_ASSIGN(Scheduler);
+};
+
+} // namespace engine
+} // namespace blimp
+
+#endif // BLIMP_ENGINE_RENDERER_SCHEDULER_H_
« no previous file with comments | « blimp/engine/renderer/blimp_remote_compositor_bridge.cc ('k') | blimp/engine/renderer/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698