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

Side by Side 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, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BLIMP_ENGINE_RENDERER_FRAME_SCHEDULER_H_
6 #define BLIMP_ENGINE_RENDERER_FRAME_SCHEDULER_H_
7
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/timer/timer.h"
11
12 namespace blimp {
13 namespace engine {
14
15 class FrameSchedulerClient {
16 public:
17 virtual ~FrameSchedulerClient() {}
18
19 // Used to notify the SchedulerClient to start the requested frame update.
20 // Calling this method marks the completion of the frame update request made
21 // to the scheduler. Any calls to schedule a frame after this will result in
22 // a new frame update.
23 // The frame update must be run synchronously, and if it results in any
24 // content changes sent to the blimp client, the scheduler must be informed
25 // using DidSendFrameUpdateToClient.
26 virtual void StartFrameUpdate() = 0;
27 };
28
29 // Responsible for scheduling frame updates sent to the client.
30 // The Scheduler uses the state of frames sent to the client and the
31 // acknowledgements for these frames from the client to make decisions regarding
32 // when a frame should be produced on the engine.
33 // The caller provides a FrameSchedulerClient to be notified when a frame update
34 // should be produced. The FrameSchedulerClient must outlive this class.
35 class FrameScheduler {
36 public:
37 FrameScheduler(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
38 FrameSchedulerClient* client);
39 virtual ~FrameScheduler();
40
41 // Called when the |client| wants to start a frame update on the engine.
42 // |client->StartFrameUpdate() will be called back asynchronously when the
43 // scheduler is ready for the next frame to be started.
44 void ScheduleFrameUpdate();
45
46 // Called when a frame update is sent to the client. This must be called only
47 // when the |client| is producing a frame update in
48 // FrameSchedulerClient::StartFrameUpdate and must be followed with a
49 // DidReceiveFrameUpdateAck when the frame sent is ack-ed by the client.
50 void DidSendFrameUpdateToClient();
51
52 // Called when an Ack is received for a frame sent to the client.
53 void DidReceiveFrameUpdateAck();
54
55 protected:
56 // protected for testing.
57 FrameScheduler(base::TimeDelta frame_delay,
58 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
59 FrameSchedulerClient* client);
60
61 private:
62 void ScheduleFrameUpdateIfNecessary();
63
64 // Returns true if a frame update can be started. The Scheduler can not
65 // produce new frames either if there is no request for frames pending or we
66 // are waiting for an ack for a frame previously sent to the client.
67 bool ShouldProduceFrameUpdates() const;
68
69 void StartFrameUpdate();
70
71 // Set to true if the |client_| has requested us to schedule frames.
72 bool needs_frame_update_ = false;
73
74 // Set to true if a frame update was sent to the client and the ack is
75 // pending.
76 bool frame_ack_pending_ = false;
77
78 bool in_frame_update_ = false;
79
80 // The time at which the next main frame update can be run.
81 base::TimeTicks next_frame_time_;
82
83 // The delay to use between consecutive frames.
84 base::TimeDelta frame_delay_;
85
86 base::OneShotTimer frame_tick_timer_;
87
88 FrameSchedulerClient* client_;
89
90 DISALLOW_COPY_AND_ASSIGN(FrameScheduler);
91 };
92
93 } // namespace engine
94 } // namespace blimp
95
96 #endif // BLIMP_ENGINE_RENDERER_FRAME_SCHEDULER_H_
OLDNEW
« no previous file with comments | « blimp/engine/renderer/blimp_remote_compositor_bridge.cc ('k') | blimp/engine/renderer/frame_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698