Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4080)

Unified Diff: cc/scheduler/begin_frame_source.cc

Issue 845393002: cc: Create ProxyBeginFrameSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {

Powered by Google App Engine
This is Rietveld 408576698