Commit f9236cd2 authored by Patrick Monette's avatar Patrick Monette Committed by Commit Bot

[PM] Add DCHECKs to OnControlleeAdded() and OnControlleeRemoved()

The goal of this CL is to collect crashes from a DCHECK-enabled build.
It is meant to be reverted within days of being committed and it will
not affect other builds.

Bug: 1086944, 1088353
Change-Id: Ie6fde9428793f1ae1f18af804e2390292dea76b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2417292
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Auto-Submit: Patrick Monette <pmonette@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809034}
parent 78ff7987
...@@ -275,8 +275,10 @@ void ServiceWorkerContextAdapter::OnControlleeAdded( ...@@ -275,8 +275,10 @@ void ServiceWorkerContextAdapter::OnControlleeAdded(
// notification is dropped. // notification is dropped.
bool inserted = bool inserted =
service_worker_clients_[version_id].insert(client_uuid).second; service_worker_clients_[version_id].insert(client_uuid).second;
if (!inserted) if (!inserted) {
NOTREACHED();
return; return;
}
for (auto& observer : observer_list_) for (auto& observer : observer_list_)
observer.OnControlleeAdded(version_id, client_uuid, client_info); observer.OnControlleeAdded(version_id, client_uuid, client_info);
...@@ -288,12 +290,16 @@ void ServiceWorkerContextAdapter::OnControlleeRemoved( ...@@ -288,12 +290,16 @@ void ServiceWorkerContextAdapter::OnControlleeRemoved(
// If |client_uuid| is not already marked as a client of |version_id|, the // If |client_uuid| is not already marked as a client of |version_id|, the
// notification is dropped. // notification is dropped.
auto it = service_worker_clients_.find(version_id); auto it = service_worker_clients_.find(version_id);
if (it == service_worker_clients_.end()) if (it == service_worker_clients_.end()) {
NOTREACHED();
return; return;
}
size_t removed = it->second.erase(client_uuid); size_t removed = it->second.erase(client_uuid);
if (!removed) if (!removed) {
NOTREACHED();
return; return;
}
// If a service worker no longer has any clients, it is removed entirely from // If a service worker no longer has any clients, it is removed entirely from
// |service_worker_clients_|. // |service_worker_clients_|.
...@@ -312,10 +318,23 @@ void ServiceWorkerContextAdapter::OnNoControllees(int64_t version_id, ...@@ -312,10 +318,23 @@ void ServiceWorkerContextAdapter::OnNoControllees(int64_t version_id,
void ServiceWorkerContextAdapter::OnControlleeNavigationCommitted( void ServiceWorkerContextAdapter::OnControlleeNavigationCommitted(
int64_t version_id, int64_t version_id,
const std::string& uuid, const std::string& client_uuid,
content::GlobalFrameRoutingId render_frame_host_id) { content::GlobalFrameRoutingId render_frame_host_id) {
// The navigation committed notification should not be sent if the frame is
// not already a client of |version_id|.
auto it = service_worker_clients_.find(version_id);
if (it == service_worker_clients_.end()) {
NOTREACHED();
return;
}
if (it->second.find(client_uuid) == it->second.end()) {
NOTREACHED();
return;
}
for (auto& observer : observer_list_) for (auto& observer : observer_list_)
observer.OnControlleeNavigationCommitted(version_id, uuid, observer.OnControlleeNavigationCommitted(version_id, client_uuid,
render_frame_host_id); render_frame_host_id);
} }
......
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