Index: cc/scheduler/begin_frame_source.cc |
diff --git a/cc/scheduler/begin_frame_source.cc b/cc/scheduler/begin_frame_source.cc |
index c245bd63fc380e855ed3f1ff7457376690713bf1..9676e2498edf5693269aa1f53572d087a1b7ff9e 100644 |
--- a/cc/scheduler/begin_frame_source.cc |
+++ b/cc/scheduler/begin_frame_source.cc |
@@ -137,6 +137,52 @@ void BeginFrameSourceMixIn::AsValueInto(base::debug::TracedValue* dict) const { |
dict->SetBoolean("needs_begin_frames", NeedsBeginFrames()); |
} |
+// ProxyBeginFrameSource |
+ProxyBeginFrameSource::ProxyBeginFrameSource() : delegate_(nullptr) { |
+} |
+ |
+ProxyBeginFrameSource::~ProxyBeginFrameSource() { |
+ DCHECK(!observer_list_.might_have_observers()); |
+} |
+ |
+bool ProxyBeginFrameSource::NeedsBeginFrames() const { |
+ return observer_list_.might_have_observers(); |
+} |
+ |
+void ProxyBeginFrameSource::AddObserver(BeginFrameObserver* obs) { |
+ // If |missed_begin_frame_args_| is still effective, send it to the new |
+ // |obs| immediately. |
+ if (!obs->LastUsedBeginFrameArgs().deadline.is_null() && |
+ obs->LastUsedBeginFrameArgs() != missed_begin_frame_args_) { |
+ missed_begin_frame_args_.type = BeginFrameArgs::MISSED; |
+ obs->OnBeginFrame(missed_begin_frame_args_); |
+ } |
+ |
+ if (!observer_list_.might_have_observers() && delegate_) |
+ delegate_->SetChildrenNeedBeginFrames(true); |
+ observer_list_.AddObserver(obs); |
+} |
+ |
+void ProxyBeginFrameSource::RemoveObserver(BeginFrameObserver* obs) { |
+ DCHECK(observer_list_.HasObserver(obs)); |
+ observer_list_.RemoveObserver(obs); |
+ |
+ if (!observer_list_.might_have_observers() && delegate_) |
+ delegate_->SetChildrenNeedBeginFrames(false); |
+} |
+ |
+void ProxyBeginFrameSource::AsValueInto(base::debug::TracedValue* dict) const { |
+ dict->SetString("type", "ProxyBeginFrameSource"); |
+ dict->SetBoolean("has_observers", observer_list_.might_have_observers()); |
+} |
+ |
+void ProxyBeginFrameSource::BeginFrames(const BeginFrameArgs& args) { |
+ FOR_EACH_OBSERVER(BeginFrameObserver, |
+ observer_list_, |
+ OnBeginFrame(args)); |
+ missed_begin_frame_args_ = args; |
+} |
+ |
// BackToBackBeginFrameSourceMixIn -------------------------------------------- |
scoped_ptr<BackToBackBeginFrameSource> BackToBackBeginFrameSource::Create( |
base::SingleThreadTaskRunner* task_runner) { |