Index: cc/scheduler/begin_frame_source.h |
diff --git a/cc/scheduler/begin_frame_source.h b/cc/scheduler/begin_frame_source.h |
index d845dacd8e417505e27b3663246ae38c53234285..a1b7c20b0afecda7fe8b11996898662a1cfe409c 100644 |
--- a/cc/scheduler/begin_frame_source.h |
+++ b/cc/scheduler/begin_frame_source.h |
@@ -86,6 +86,37 @@ class CC_EXPORT BeginFrameObserverMixIn : public BeginFrameObserver { |
int64_t dropped_begin_frame_args_; |
}; |
+// A "virtual" frame observer which forwards any received BeginFrame messages |
+// to all registered observers. Also provides a callback allowing detection of |
+// observers existing. |
+class CC_EXPORT BeginFrameObserverMultiplexer : public BeginFrameObserverMixIn { |
simonhong
2015/03/25 02:03:22
As dana said, how about subclassing BeginFrameObse
mithro-old
2015/03/25 02:34:47
Implementing BeginFrameObserver means duplicating
|
+ public: |
+ using HasObserversCallback = base::Callback<void(bool has_observers)>; |
+ |
+ static scoped_ptr<BeginFrameObserverMultiplexer> Create(); |
+ ~BeginFrameObserverMultiplexer() override; |
+ |
+ void AddObserver(BeginFrameObserver* obs); |
+ void RemoveObserver(BeginFrameObserver* obs); |
+ bool HasObservers(); |
+ void SetHasObserverCallback(const HasObserversCallback& cb); |
+ |
+ void AsValueInto(base::trace_event::TracedValue* dict) const override; |
+ |
+ protected: |
+ BeginFrameObserverMultiplexer(); |
+ |
+ bool last_callback_state_; |
+ HasObserversCallback has_observers_callback_; |
+ void CallCallbackOnChange(); |
+ void CallCallback(bool has_observers); |
+ |
+ // BeginFrameObserverMixIn |
+ bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override; |
+ |
+ ObserverList<BeginFrameObserver> observer_list_; |
+}; |
+ |
// Interface for a class which produces BeginFrame calls to a |
// BeginFrameObserver. |
// |