Commit de680cfd authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Chromium LUCI CQ

Rename ObserverList::has_observers to ObserverList::empty

Bug: 1155308
Change-Id: I6dc2ef187ccd5ab06b6b9b27b9d6ee2880ca8489
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2617203Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843121}
parent 597ee040
...@@ -319,7 +319,7 @@ class ObserverList { ...@@ -319,7 +319,7 @@ class ObserverList {
observers_count_ = 0; observers_count_ = 0;
} }
bool has_observers() const { return observers_count_ > 0; } bool empty() const { return !observers_count_; }
// Deprecated: use |has_observers()|. // Deprecated: use |has_observers()|.
// TODO(1155308): migrate all callers and make this test only. // TODO(1155308): migrate all callers and make this test only.
......
...@@ -364,7 +364,7 @@ TYPED_TEST(ObserverListTest, CompactsWhenNoActiveIterator) { ...@@ -364,7 +364,7 @@ TYPED_TEST(ObserverListTest, CompactsWhenNoActiveIterator) {
EXPECT_TRUE(col.HasObserver(&a)); EXPECT_TRUE(col.HasObserver(&a));
EXPECT_FALSE(col.HasObserver(&c)); EXPECT_FALSE(col.HasObserver(&c));
EXPECT_TRUE(col.has_observers()); EXPECT_TRUE(!col.empty());
EXPECT_TRUE(col.might_have_observers()); EXPECT_TRUE(col.might_have_observers());
using It = typename ObserverListConstFoo::const_iterator; using It = typename ObserverListConstFoo::const_iterator;
...@@ -380,55 +380,55 @@ TYPED_TEST(ObserverListTest, CompactsWhenNoActiveIterator) { ...@@ -380,55 +380,55 @@ TYPED_TEST(ObserverListTest, CompactsWhenNoActiveIterator) {
EXPECT_EQ(itb, it); EXPECT_EQ(itb, it);
EXPECT_EQ(++it, col.end()); EXPECT_EQ(++it, col.end());
EXPECT_TRUE(col.has_observers()); EXPECT_TRUE(!col.empty());
EXPECT_TRUE(col.might_have_observers()); EXPECT_TRUE(col.might_have_observers());
EXPECT_EQ(&*ita, &a); EXPECT_EQ(&*ita, &a);
EXPECT_EQ(&*itb, &b); EXPECT_EQ(&*itb, &b);
ol.RemoveObserver(&a); ol.RemoveObserver(&a);
EXPECT_TRUE(col.has_observers()); EXPECT_TRUE(!col.empty());
EXPECT_TRUE(col.might_have_observers()); EXPECT_TRUE(col.might_have_observers());
EXPECT_FALSE(col.HasObserver(&a)); EXPECT_FALSE(col.HasObserver(&a));
EXPECT_EQ(&*itb, &b); EXPECT_EQ(&*itb, &b);
ol.RemoveObserver(&b); ol.RemoveObserver(&b);
EXPECT_FALSE(col.has_observers()); EXPECT_FALSE(!col.empty());
EXPECT_TRUE(col.might_have_observers()); EXPECT_TRUE(col.might_have_observers());
EXPECT_FALSE(col.HasObserver(&a)); EXPECT_FALSE(col.HasObserver(&a));
EXPECT_FALSE(col.HasObserver(&b)); EXPECT_FALSE(col.HasObserver(&b));
it = It(); it = It();
ita = It(); ita = It();
EXPECT_FALSE(col.has_observers()); EXPECT_FALSE(!col.empty());
EXPECT_TRUE(col.might_have_observers()); EXPECT_TRUE(col.might_have_observers());
ita = itb; ita = itb;
itb = It(); itb = It();
EXPECT_FALSE(col.has_observers()); EXPECT_FALSE(!col.empty());
EXPECT_TRUE(col.might_have_observers()); EXPECT_TRUE(col.might_have_observers());
ita = It(); ita = It();
EXPECT_FALSE(col.has_observers()); EXPECT_FALSE(!col.empty());
EXPECT_FALSE(col.might_have_observers()); EXPECT_FALSE(col.might_have_observers());
} }
ol.AddObserver(&a); ol.AddObserver(&a);
ol.AddObserver(&b); ol.AddObserver(&b);
EXPECT_TRUE(col.has_observers()); EXPECT_TRUE(!col.empty());
EXPECT_TRUE(col.might_have_observers()); EXPECT_TRUE(col.might_have_observers());
ol.Clear(); ol.Clear();
EXPECT_FALSE(col.has_observers()); EXPECT_FALSE(!col.empty());
EXPECT_FALSE(col.might_have_observers()); EXPECT_FALSE(col.might_have_observers());
ol.AddObserver(&a); ol.AddObserver(&a);
ol.AddObserver(&b); ol.AddObserver(&b);
EXPECT_TRUE(col.has_observers()); EXPECT_TRUE(!col.empty());
EXPECT_TRUE(col.might_have_observers()); EXPECT_TRUE(col.might_have_observers());
{ {
const It it = col.begin(); const It it = col.begin();
ol.Clear(); ol.Clear();
EXPECT_FALSE(col.has_observers()); EXPECT_FALSE(!col.empty());
EXPECT_TRUE(col.might_have_observers()); EXPECT_TRUE(col.might_have_observers());
} }
EXPECT_FALSE(col.has_observers()); EXPECT_FALSE(!col.empty());
EXPECT_FALSE(col.might_have_observers()); EXPECT_FALSE(col.might_have_observers());
} }
...@@ -1013,7 +1013,7 @@ TEST_F(CheckedObserverListTest, CheckedObserver) { ...@@ -1013,7 +1013,7 @@ TEST_F(CheckedObserverListTest, CheckedObserver) {
// On the non-death fork, no UAF occurs since the deleted observer is never // On the non-death fork, no UAF occurs since the deleted observer is never
// notified, but also the observer list still has |l2| in it. Check that. // notified, but also the observer list still has |l2| in it. Check that.
list->RemoveObserver(&l1); list->RemoveObserver(&l1);
EXPECT_TRUE(list->has_observers()); EXPECT_TRUE(!list->empty());
EXPECT_TRUE(list->might_have_observers()); EXPECT_TRUE(list->might_have_observers());
// Now (in the non-death fork()) there's a problem. To delete |it|, we need // Now (in the non-death fork()) there's a problem. To delete |it|, we need
......
...@@ -576,7 +576,7 @@ bool Compositor::HasObserver(const CompositorObserver* observer) const { ...@@ -576,7 +576,7 @@ bool Compositor::HasObserver(const CompositorObserver* observer) const {
} }
void Compositor::AddAnimationObserver(CompositorAnimationObserver* observer) { void Compositor::AddAnimationObserver(CompositorAnimationObserver* observer) {
if (!animation_observer_list_.has_observers()) { if (animation_observer_list_.empty()) {
for (auto& obs : observer_list_) for (auto& obs : observer_list_)
obs.OnFirstAnimationStarted(this); obs.OnFirstAnimationStarted(this);
} }
...@@ -589,7 +589,7 @@ void Compositor::RemoveAnimationObserver( ...@@ -589,7 +589,7 @@ void Compositor::RemoveAnimationObserver(
if (!animation_observer_list_.HasObserver(observer)) if (!animation_observer_list_.HasObserver(observer))
return; return;
animation_observer_list_.RemoveObserver(observer); animation_observer_list_.RemoveObserver(observer);
if (!animation_observer_list_.has_observers()) { if (animation_observer_list_.empty()) {
for (auto& obs : observer_list_) for (auto& obs : observer_list_)
obs.OnLastAnimationEnded(this); obs.OnLastAnimationEnded(this);
} }
......
...@@ -71,7 +71,7 @@ TotalAnimationThroughputReporter::TotalAnimationThroughputReporter( ...@@ -71,7 +71,7 @@ TotalAnimationThroughputReporter::TotalAnimationThroughputReporter(
report_once_callback_.is_null()); report_once_callback_.is_null());
compositor_->AddObserver(this); compositor_->AddObserver(this);
if (compositor->animation_observer_list_.has_observers()) if (!compositor->animation_observer_list_.empty())
OnFirstAnimationStarted(compositor_); OnFirstAnimationStarted(compositor_);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment