Chromium Code Reviews| Index: ui/base/compositor/begin_frame_manager.h |
| diff --git a/ui/base/compositor/begin_frame_manager.h b/ui/base/compositor/begin_frame_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8cb95a3f8c52b4ada44583c2505833e49fbf1a02 |
| --- /dev/null |
| +++ b/ui/base/compositor/begin_frame_manager.h |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2014 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 UI_BASE_COMPOSITOR_BEGIN_FRAME_MANAGER_H_ |
| +#define UI_BASE_COMPOSITOR_BEGIN_FRAME_MANAGER_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/observer_list.h" |
| +#include "base/threading/non_thread_safe.h" |
| +#include "base/time/time.h" |
| +#include "ui/base/ui_base_export.h" |
| + |
| +namespace ui { |
| + |
| +// This class delivers a BeginFrame request from the Compositor to its |
| +// observers. It also handles next BeginFrame scheduling via its delegate. |
| +// Browser compositor will own this. |
| +// This class will be run only on main thread. |
| +class UI_BASE_EXPORT BeginFrameManager : public base::NonThreadSafe { |
| + public: |
| + // Subclass should deliver BeginFrame to its client. |
| + class Observer { |
| + public: |
| + virtual void OnSendBeginFrame(base::TimeTicks timebase, |
| + base::TimeDelta interval) = 0; |
| + }; |
| + |
| + // Subclass should implement howto schedule next BeginFrame. |
| + class Delegate { |
| + public: |
| + virtual void RequestBeginFrame() = 0; |
| + }; |
| + |
| + BeginFrameManager(); |
| + ~BeginFrameManager(); |
| + |
| + void SendBeginFrame(base::TimeTicks timebase, base::TimeDelta interval); |
|
brianderson
2014/07/28 21:13:47
Would BeginFrameArgs work better than timebase+int
simonhong
2014/07/28 23:37:40
IMO, RWHV is more better place to calculate deadli
|
| + void RequestBeginFrame() const; |
| + |
| + void AddObserver(Observer* observer); |
| + void RemoveObserver(Observer* observer); |
| + |
| + void set_delegate(Delegate* delegate) { |
| + delegate_ = delegate; |
| + } |
| + |
| + private: |
| + // Not owned by this class. |
| + Delegate* delegate_; |
| + ObserverList<BeginFrameManager::Observer> observer_list_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BeginFrameManager); |
| +}; |
| + |
| +} // namespace ui |
| + |
| +#endif // UI_BASE_COMPOSITOR_BEGIN_FRAME_MANAGER_H_ |