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..0f5fa597a6b0a92256dc7b8251a518085856ce43 |
--- /dev/null |
+++ b/ui/base/compositor/begin_frame_manager.h |
@@ -0,0 +1,61 @@ |
+// 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::TimeTicks deadline, |
+ base::TimeDelta interval) = 0; |
+ }; |
+ |
+ // Subclass should implement howto schedule next BeginFrame. |
+ class Delegate { |
+ public: |
+ virtual void RequestBeginFrame() = 0; |
+ }; |
+ |
+ BeginFrameManager(); |
+ ~BeginFrameManager(); |
+ |
+ void SendBeginFrame(base::TimeTicks frame_time, |
brianderson
2014/07/30 19:44:29
Please use BeginFrameArgs instead.
simonhong
2014/07/31 00:18:03
Done.
|
+ base::TimeTicks deadline, |
+ base::TimeDelta interval); |
+ 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_ |