| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BLIMP_ENGINE_RENDERER_FRAME_SCHEDULER_H_ | 5 #ifndef BLIMP_ENGINE_RENDERER_FRAME_SCHEDULER_H_ |
| 6 #define BLIMP_ENGINE_RENDERER_FRAME_SCHEDULER_H_ | 6 #define BLIMP_ENGINE_RENDERER_FRAME_SCHEDULER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 // Called when a frame update is sent to the client. This must be called only | 48 // Called when a frame update is sent to the client. This must be called only |
| 49 // when the |client| is producing a frame update in | 49 // when the |client| is producing a frame update in |
| 50 // FrameSchedulerClient::StartFrameUpdate and must be followed with a | 50 // FrameSchedulerClient::StartFrameUpdate and must be followed with a |
| 51 // DidReceiveFrameUpdateAck when the frame sent is ack-ed by the client. | 51 // DidReceiveFrameUpdateAck when the frame sent is ack-ed by the client. |
| 52 void DidSendFrameUpdateToClient(); | 52 void DidSendFrameUpdateToClient(); |
| 53 | 53 |
| 54 // Called when an Ack is received for a frame sent to the client. | 54 // Called when an Ack is received for a frame sent to the client. |
| 55 void DidReceiveFrameUpdateAck(); | 55 void DidReceiveFrameUpdateAck(); |
| 56 | 56 |
| 57 protected: | 57 bool needs_frame_update() const { return needs_frame_update_; } |
| 58 // protected for testing. | 58 |
| 59 FrameScheduler(base::TimeDelta frame_delay, | 59 void set_frame_delay_for_testing(base::TimeDelta frame_delay) { |
| 60 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 60 frame_delay_ = frame_delay; |
| 61 FrameSchedulerClient* client); | 61 } |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 void ScheduleFrameUpdateIfNecessary(); | 64 void ScheduleFrameUpdateIfNecessary(); |
| 65 | 65 |
| 66 // Returns true if a frame update can be started. The Scheduler can not | 66 // Returns true if a frame update can be started. The Scheduler can not |
| 67 // produce new frames either if there is no request for frames pending or we | 67 // produce new frames either if there is no request for frames pending or we |
| 68 // are waiting for an ack for a frame previously sent to the client. | 68 // are waiting for an ack for a frame previously sent to the client. |
| 69 bool ShouldProduceFrameUpdates() const; | 69 bool ShouldProduceFrameUpdates() const; |
| 70 | 70 |
| 71 void StartFrameUpdate(); | 71 void StartFrameUpdate(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 89 | 89 |
| 90 FrameSchedulerClient* client_; | 90 FrameSchedulerClient* client_; |
| 91 | 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(FrameScheduler); | 92 DISALLOW_COPY_AND_ASSIGN(FrameScheduler); |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 } // namespace engine | 95 } // namespace engine |
| 96 } // namespace blimp | 96 } // namespace blimp |
| 97 | 97 |
| 98 #endif // BLIMP_ENGINE_RENDERER_FRAME_SCHEDULER_H_ | 98 #endif // BLIMP_ENGINE_RENDERER_FRAME_SCHEDULER_H_ |
| OLD | NEW |