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( ...@@ -827,9 +827,7 @@ void ServiceWorkerContextCore::OnMainScriptResponseSet(
void ServiceWorkerContextCore::OnRunningStateChanged( void ServiceWorkerContextCore::OnRunningStateChanged(
ServiceWorkerVersion* version) { ServiceWorkerVersion* version) {
if (!version->context()) DCHECK_EQ(this, version->context().get());
return;
switch (version->running_status()) { switch (version->running_status()) {
case EmbeddedWorkerStatus::STOPPED: case EmbeddedWorkerStatus::STOPPED:
observer_list_->Notify(FROM_HERE, observer_list_->Notify(FROM_HERE,
...@@ -857,6 +855,7 @@ void ServiceWorkerContextCore::OnRunningStateChanged( ...@@ -857,6 +855,7 @@ void ServiceWorkerContextCore::OnRunningStateChanged(
void ServiceWorkerContextCore::OnVersionStateChanged( void ServiceWorkerContextCore::OnVersionStateChanged(
ServiceWorkerVersion* version) { ServiceWorkerVersion* version) {
DCHECK_EQ(this, version->context().get());
observer_list_->Notify( observer_list_->Notify(
FROM_HERE, &ServiceWorkerContextCoreObserver::OnVersionStateChanged, FROM_HERE, &ServiceWorkerContextCoreObserver::OnVersionStateChanged,
version->version_id(), version->scope(), version->status()); version->version_id(), version->scope(), version->status());
...@@ -864,6 +863,7 @@ void ServiceWorkerContextCore::OnVersionStateChanged( ...@@ -864,6 +863,7 @@ void ServiceWorkerContextCore::OnVersionStateChanged(
void ServiceWorkerContextCore::OnDevToolsRoutingIdChanged( void ServiceWorkerContextCore::OnDevToolsRoutingIdChanged(
ServiceWorkerVersion* version) { ServiceWorkerVersion* version) {
DCHECK_EQ(this, version->context().get());
if (!version->embedded_worker()) if (!version->embedded_worker())
return; return;
observer_list_->Notify( observer_list_->Notify(
...@@ -879,6 +879,7 @@ void ServiceWorkerContextCore::OnErrorReported( ...@@ -879,6 +879,7 @@ void ServiceWorkerContextCore::OnErrorReported(
int line_number, int line_number,
int column_number, int column_number,
const GURL& source_url) { const GURL& source_url) {
DCHECK_EQ(this, version->context().get());
observer_list_->Notify( observer_list_->Notify(
FROM_HERE, &ServiceWorkerContextCoreObserver::OnErrorReported, FROM_HERE, &ServiceWorkerContextCoreObserver::OnErrorReported,
version->version_id(), version->version_id(),
...@@ -894,6 +895,7 @@ void ServiceWorkerContextCore::OnReportConsoleMessage( ...@@ -894,6 +895,7 @@ void ServiceWorkerContextCore::OnReportConsoleMessage(
int line_number, int line_number,
const GURL& source_url) { const GURL& source_url) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId()); DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_EQ(this, version->context().get());
// NOTE: This differs slightly from // NOTE: This differs slightly from
// RenderFrameHostImpl::DidAddMessageToConsole, which also asks the // RenderFrameHostImpl::DidAddMessageToConsole, which also asks the
// content embedder whether to classify the message as a builtin component. // content embedder whether to classify the message as a builtin component.
...@@ -915,6 +917,7 @@ void ServiceWorkerContextCore::OnControlleeAdded( ...@@ -915,6 +917,7 @@ void ServiceWorkerContextCore::OnControlleeAdded(
ServiceWorkerVersion* version, ServiceWorkerVersion* version,
const std::string& client_uuid, const std::string& client_uuid,
const ServiceWorkerClientInfo& client_info) { const ServiceWorkerClientInfo& client_info) {
DCHECK_EQ(this, version->context().get());
observer_list_->Notify( observer_list_->Notify(
FROM_HERE, &ServiceWorkerContextCoreObserver::OnControlleeAdded, FROM_HERE, &ServiceWorkerContextCoreObserver::OnControlleeAdded,
version->version_id(), version->scope(), client_uuid, client_info); version->version_id(), version->scope(), client_uuid, client_info);
...@@ -923,12 +926,14 @@ void ServiceWorkerContextCore::OnControlleeAdded( ...@@ -923,12 +926,14 @@ void ServiceWorkerContextCore::OnControlleeAdded(
void ServiceWorkerContextCore::OnControlleeRemoved( void ServiceWorkerContextCore::OnControlleeRemoved(
ServiceWorkerVersion* version, ServiceWorkerVersion* version,
const std::string& client_uuid) { const std::string& client_uuid) {
DCHECK_EQ(this, version->context().get());
observer_list_->Notify(FROM_HERE, observer_list_->Notify(FROM_HERE,
&ServiceWorkerContextCoreObserver::OnControlleeRemoved, &ServiceWorkerContextCoreObserver::OnControlleeRemoved,
version->version_id(), version->scope(), client_uuid); version->version_id(), version->scope(), client_uuid);
} }
void ServiceWorkerContextCore::OnNoControllees(ServiceWorkerVersion* version) { void ServiceWorkerContextCore::OnNoControllees(ServiceWorkerVersion* version) {
DCHECK_EQ(this, version->context().get());
observer_list_->Notify(FROM_HERE, observer_list_->Notify(FROM_HERE,
&ServiceWorkerContextCoreObserver::OnNoControllees, &ServiceWorkerContextCoreObserver::OnNoControllees,
version->version_id(), version->scope()); 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