Commit d4945d2d authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Commit Bot

Add DCHECK for ServiceWorkerVersion::Observer methods in ServiceworkerContextCore

These methods should be called only when |version->context()| points
to |this|.

This is a follow-up CL of crrev.com/c/2093971.

Bug: N/A
Change-Id: Iedf925b75c974097a3dd3ff692c533e62ea2b02d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2099344
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749526}
parent d58519eb
......@@ -827,9 +827,7 @@ void ServiceWorkerContextCore::OnMainScriptResponseSet(
void ServiceWorkerContextCore::OnRunningStateChanged(
ServiceWorkerVersion* version) {
if (!version->context())
return;
DCHECK_EQ(this, version->context().get());
switch (version->running_status()) {
case EmbeddedWorkerStatus::STOPPED:
observer_list_->Notify(FROM_HERE,
......@@ -857,6 +855,7 @@ void ServiceWorkerContextCore::OnRunningStateChanged(
void ServiceWorkerContextCore::OnVersionStateChanged(
ServiceWorkerVersion* version) {
DCHECK_EQ(this, version->context().get());
observer_list_->Notify(
FROM_HERE, &ServiceWorkerContextCoreObserver::OnVersionStateChanged,
version->version_id(), version->scope(), version->status());
......@@ -864,6 +863,7 @@ void ServiceWorkerContextCore::OnVersionStateChanged(
void ServiceWorkerContextCore::OnDevToolsRoutingIdChanged(
ServiceWorkerVersion* version) {
DCHECK_EQ(this, version->context().get());
if (!version->embedded_worker())
return;
observer_list_->Notify(
......@@ -879,6 +879,7 @@ void ServiceWorkerContextCore::OnErrorReported(
int line_number,
int column_number,
const GURL& source_url) {
DCHECK_EQ(this, version->context().get());
observer_list_->Notify(
FROM_HERE, &ServiceWorkerContextCoreObserver::OnErrorReported,
version->version_id(),
......@@ -894,6 +895,7 @@ void ServiceWorkerContextCore::OnReportConsoleMessage(
int line_number,
const GURL& source_url) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_EQ(this, version->context().get());
// NOTE: This differs slightly from
// RenderFrameHostImpl::DidAddMessageToConsole, which also asks the
// content embedder whether to classify the message as a builtin component.
......@@ -915,6 +917,7 @@ void ServiceWorkerContextCore::OnControlleeAdded(
ServiceWorkerVersion* version,
const std::string& client_uuid,
const ServiceWorkerClientInfo& client_info) {
DCHECK_EQ(this, version->context().get());
observer_list_->Notify(
FROM_HERE, &ServiceWorkerContextCoreObserver::OnControlleeAdded,
version->version_id(), version->scope(), client_uuid, client_info);
......@@ -923,12 +926,14 @@ void ServiceWorkerContextCore::OnControlleeAdded(
void ServiceWorkerContextCore::OnControlleeRemoved(
ServiceWorkerVersion* version,
const std::string& client_uuid) {
DCHECK_EQ(this, version->context().get());
observer_list_->Notify(FROM_HERE,
&ServiceWorkerContextCoreObserver::OnControlleeRemoved,
version->version_id(), version->scope(), client_uuid);
}
void ServiceWorkerContextCore::OnNoControllees(ServiceWorkerVersion* version) {
DCHECK_EQ(this, version->context().get());
observer_list_->Notify(FROM_HERE,
&ServiceWorkerContextCoreObserver::OnNoControllees,
version->version_id(), version->scope());
......
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