Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_SCHEDULER_H_ | |
| 6 #define BLIMP_ENGINE_RENDERER_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 SchedulerClient; | |
| 16 | |
| 17 // Responsible for scheduling frame updates sent to the client. | |
|
Wez
2016/10/13 16:53:52
Can you elaborate on *how* it schedules them? All
Khushal
2016/10/13 18:47:27
Added a comment. I don't think we need to get into
Wez
2016/10/18 01:49:42
I'm not asking for details of how we decide when t
Khushal
2016/10/18 05:10:03
Ah, added a comment about using the client interfa
| |
| 18 class Scheduler { | |
| 19 public: | |
| 20 Scheduler(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
| 21 SchedulerClient* client); | |
|
Wez
2016/10/13 16:53:52
Who owns this? What is its lifetime?
Khushal
2016/10/13 18:47:27
I don't know if there is an established pattern fo
Wez
2016/10/18 01:49:42
If it is made explicit that |client| is a caller-s
Khushal
2016/10/18 05:10:03
The class takes the client in its ctor, I thought
Wez
2016/10/19 22:01:34
If you pass a bare pointer to a function, ctor, wh
Khushal
2016/10/20 01:29:32
I understand that in general when you take a bare
| |
| 22 virtual ~Scheduler(); | |
| 23 | |
| 24 void SetNeedsMainFrame(); | |
|
Wez
2016/10/13 16:53:52
What is a "main frame" in the context of this sche
Khushal
2016/10/13 18:47:27
Added a comment. I kept the word main frame mostly
Wez
2016/10/18 01:49:42
Understood. However, I think it would be clearer i
Khushal
2016/10/18 05:10:03
Sure, I don't really have a strong preference on t
Wez
2016/10/19 22:01:34
Perhaps... :P
Can we rename this to indicate what
Khushal
2016/10/20 01:29:33
Actually that comment will not be accurate. Since
| |
| 25 void DidSendFrameUpdateToClient(); | |
| 26 void DidReceiveFrameUpdateAck(); | |
|
Wez
2016/10/13 16:53:52
SetNeedsMainFrame(), at least, needs explaining.
Khushal
2016/10/13 18:47:27
Done.
| |
| 27 | |
| 28 base::TimeTicks next_frame_time() const { return next_frame_time_; } | |
| 29 | |
| 30 protected: | |
| 31 // protected for testing. | |
| 32 Scheduler(base::TimeDelta frame_delay, | |
| 33 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
| 34 SchedulerClient* client); | |
| 35 | |
| 36 private: | |
| 37 void ScheduleMainFrameIfNecessary(); | |
| 38 bool CanProduceMainFrames() const; | |
|
Wez
2016/10/13 16:53:52
Under what circumstance can we _not_ produce "main
Khushal
2016/10/13 18:47:27
Done.
| |
| 39 void StartMainFrame(); | |
| 40 | |
| 41 // Set to true if the |client_| has requested us to schedule main frames. | |
| 42 bool needs_main_frame_ = false; | |
| 43 | |
| 44 // Set to true if a frame update was sent to the client and the ack is | |
| 45 // pending. | |
| 46 bool frame_ack_pending_ = false; | |
| 47 | |
| 48 // The time at which the next main frame update can be run. | |
| 49 base::TimeTicks next_frame_time_; | |
| 50 | |
| 51 // The delay to use between consecutive frames. | |
| 52 base::TimeDelta frame_delay_; | |
| 53 | |
| 54 base::OneShotTimer frame_tick_timer_; | |
| 55 | |
| 56 SchedulerClient* client_; | |
|
Wez
2016/10/13 16:53:52
nit: Initialize to nullptr here, just in case?
Khushal
2016/10/13 18:47:27
The ctor takes it as an argument, so is it necessa
Wez
2016/10/18 01:49:42
No, just suggested for consistency w/ the other me
| |
| 57 | |
| 58 base::WeakPtrFactory<Scheduler> weak_ptr_factory_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(Scheduler); | |
| 61 }; | |
| 62 | |
| 63 } // namespace engine | |
| 64 } // namespace blimp | |
| 65 | |
| 66 #endif // BLIMP_ENGINE_RENDERER_SCHEDULER_H_ | |
| OLD | NEW |