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

Migrate might_have_observers to empty in content/

Bug: 1155308

Change-Id: I05d8df24fabbd9c62b1228052aadf69d92f34699
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2598757
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845212}
parent ff59331d
......@@ -299,14 +299,14 @@ void MediaKeysListenerManagerImpl::UpdateMediaKeysListener() {
bool MediaKeysListenerManagerImpl::ShouldListenToKey(
const ListeningData& listening_data) const {
return listening_data.listeners.might_have_observers() ||
return !listening_data.listeners.empty() ||
(listening_data.active_media_session_controller_listening &&
CanActiveMediaSessionControllerReceiveEvents());
}
bool MediaKeysListenerManagerImpl::AnyDelegatesListening() const {
for (const auto& key_code_listening_data : delegate_map_) {
if (key_code_listening_data.second->listeners.might_have_observers())
if (!key_code_listening_data.second->listeners.empty())
return true;
}
return false;
......
......@@ -84,7 +84,7 @@ void NotificationServiceImpl::RemoveObserver(NotificationObserver* observer,
observers_[type][source.map_key()];
if (observer_list) {
observer_list->RemoveObserver(observer);
if (!observer_list->might_have_observers()) {
if (observer_list->empty()) {
observers_[type].erase(source.map_key());
delete observer_list;
}
......
......@@ -85,7 +85,7 @@ void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() {
for (auto& observer : observers_)
observer.OnRenderWidgetHostViewBaseDestroyed(this);
// All observers are required to disconnect after they are notified.
DCHECK(!observers_.might_have_observers());
DCHECK(observers_.empty());
}
MouseWheelPhaseHandler* RenderWidgetHostViewBase::GetMouseWheelPhaseHandler() {
......
......@@ -66,13 +66,12 @@ ServiceWorkerRegistration::ServiceWorkerRegistration(
ServiceWorkerRegistration::~ServiceWorkerRegistration() {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK(!listeners_.might_have_observers());
DCHECK(listeners_.empty());
// TODO(crbug.com/1159778): Remove once the bug is fixed.
CHECK(!in_activate_waiting_version_)
<< "ServiceWorkerRegistration was destroyed while activating waiting "
"version";
if (context_)
context_->RemoveLiveRegistration(registration_id_);
}
......
......@@ -92,7 +92,7 @@ void SmsProvider::RecordParsingStatus(SmsParsingStatus status) {
}
bool SmsProvider::HasObservers() {
return observers_.might_have_observers();
return !observers_.empty();
}
} // namespace content
......@@ -313,7 +313,7 @@ bool TtsControllerImpl::IsSpeaking() {
}
void TtsControllerImpl::VoicesChanged() {
if (!voices_changed_delegates_.might_have_observers() || TtsPlatformLoading())
if (voices_changed_delegates_.empty() || TtsPlatformLoading())
return;
// Existence of platform tts indicates explicit requests to tts. Since
......
......@@ -177,7 +177,7 @@ void WebRTCInternals::OnAddPeerConnection(int render_process_id,
dict->SetBoolean("isOpen", true);
dict->SetBoolean("connected", false);
if (observers_.might_have_observers())
if (!observers_.empty())
SendUpdate("addPeerConnection", dict->CreateDeepCopy());
peer_connection_data_.Append(std::move(dict));
......@@ -199,7 +199,7 @@ void WebRTCInternals::OnRemovePeerConnection(ProcessId pid, int lid) {
peer_connection_data_.Remove(index, nullptr);
}
if (observers_.might_have_observers()) {
if (!observers_.empty()) {
std::unique_ptr<base::DictionaryValue> id(new base::DictionaryValue());
id->SetInteger("pid", static_cast<int>(pid));
id->SetInteger("lid", lid);
......@@ -227,7 +227,7 @@ void WebRTCInternals::OnUpdatePeerConnection(
}
// Don't update entries if there aren't any observers.
if (!observers_.might_have_observers())
if (observers_.empty())
return;
auto log_entry = std::make_unique<base::DictionaryValue>();
......@@ -252,7 +252,7 @@ void WebRTCInternals::OnUpdatePeerConnection(
void WebRTCInternals::OnAddStandardStats(base::ProcessId pid,
int lid,
base::Value value) {
if (!observers_.might_have_observers())
if (observers_.empty())
return;
auto dict = std::make_unique<base::DictionaryValue>();
......@@ -267,7 +267,7 @@ void WebRTCInternals::OnAddStandardStats(base::ProcessId pid,
void WebRTCInternals::OnAddLegacyStats(base::ProcessId pid,
int lid,
base::Value value) {
if (!observers_.might_have_observers())
if (observers_.empty())
return;
auto dict = std::make_unique<base::DictionaryValue>();
......@@ -304,7 +304,7 @@ void WebRTCInternals::OnGetUserMedia(int rid,
if (video)
dict->SetString("video", video_constraints);
if (observers_.might_have_observers())
if (!observers_.empty())
SendUpdate("addGetUserMedia", dict->CreateDeepCopy());
get_user_media_requests_.Append(std::move(dict));
......@@ -324,7 +324,7 @@ void WebRTCInternals::AddObserver(WebRTCInternalsUIObserver* observer) {
void WebRTCInternals::RemoveObserver(WebRTCInternalsUIObserver* observer) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
observers_.RemoveObserver(observer);
if (observers_.might_have_observers())
if (!observers_.empty())
return;
// Disables event log and audio debug recordings if enabled and the last
......@@ -452,7 +452,7 @@ bool WebRTCInternals::CanToggleEventLogRecordings() const {
void WebRTCInternals::SendUpdate(const char* command,
std::unique_ptr<base::Value> value) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(observers_.might_have_observers());
DCHECK(!observers_.empty());
bool queue_was_empty = pending_updates_.empty();
pending_updates_.push(PendingUpdate(command, std::move(value)));
......@@ -526,7 +526,7 @@ void WebRTCInternals::OnRendererExit(int render_process_id) {
record->GetInteger("rid", &this_rid);
if (this_rid == render_process_id) {
if (observers_.might_have_observers()) {
if (!observers_.empty()) {
int lid = 0, pid = 0;
record->GetInteger("lid", &lid);
record->GetInteger("pid", &pid);
......@@ -559,7 +559,7 @@ void WebRTCInternals::OnRendererExit(int render_process_id) {
}
}
if (found_any && observers_.might_have_observers()) {
if (found_any && !observers_.empty()) {
std::unique_ptr<base::DictionaryValue> update(new base::DictionaryValue());
update->SetInteger("rid", render_process_id);
SendUpdate("removeGetUserMediaForRenderer", std::move(update));
......
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