Commit 8a364cae authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Commit Bot

service worker: Move some ScheduleDeleteAndStartOver() calls to ServiceWorkerRegistry

This CL moves following ScheduleDeleteAndStartOver() calls to
ServiceWorkerRegistry so that we can reduce ServiceWorkerContextCore
dependency from ServiceWorkerStorage.
* DidGetRegistrationsForOrigin
* DidGetAllRegistrations
* DidStoreRegistration
* DidDeleteRegistration

Bug: 1039200
Change-Id: I06860107927c77431d17637a2f8e406d94d1f5e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032744Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737249}
parent f8224e8c
......@@ -770,6 +770,7 @@ void ServiceWorkerRegistry::DidGetRegistrationsForOrigin(
if (status != blink::ServiceWorkerStatusCode::kOk &&
status != blink::ServiceWorkerStatusCode::kErrorNotFound) {
ScheduleDeleteAndStartOver();
std::move(callback).Run(
status, std::vector<scoped_refptr<ServiceWorkerRegistration>>());
return;
......@@ -806,6 +807,7 @@ void ServiceWorkerRegistry::DidGetAllRegistrations(
std::unique_ptr<RegistrationList> registration_data_list) {
if (status != blink::ServiceWorkerStatusCode::kOk &&
status != blink::ServiceWorkerStatusCode::kErrorNotFound) {
ScheduleDeleteAndStartOver();
std::move(callback).Run(status,
std::vector<ServiceWorkerRegistrationInfo>());
return;
......@@ -894,6 +896,7 @@ void ServiceWorkerRegistry::DidStoreRegistration(
int64_t deleted_version_id,
const std::vector<int64_t>& newly_purgeable_resources) {
if (status != blink::ServiceWorkerStatusCode::kOk) {
ScheduleDeleteAndStartOver();
std::move(callback).Run(status);
return;
}
......@@ -932,6 +935,12 @@ void ServiceWorkerRegistry::DidDeleteRegistration(
blink::ServiceWorkerStatusCode status,
int64_t deleted_version_id,
const std::vector<int64_t>& newly_purgeable_resources) {
if (status != blink::ServiceWorkerStatusCode::kOk) {
ScheduleDeleteAndStartOver();
std::move(callback).Run(status);
return;
}
if (!context_->GetLiveVersion(deleted_version_id))
storage()->PurgeResources(newly_purgeable_resources);
......
......@@ -1006,10 +1006,6 @@ void ServiceWorkerStorage::DidGetRegistrationsForOrigin(
std::unique_ptr<RegistrationList> registration_data_list,
std::unique_ptr<std::vector<ResourceList>> resource_lists,
ServiceWorkerDatabase::Status status) {
if (status != ServiceWorkerDatabase::STATUS_OK &&
status != ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) {
ScheduleDeleteAndStartOver();
}
std::move(callback).Run(DatabaseStatusToStatusCode(status),
std::move(registration_data_list),
std::move(resource_lists));
......@@ -1019,10 +1015,6 @@ void ServiceWorkerStorage::DidGetAllRegistrations(
GetAllRegistrationsCallback callback,
std::unique_ptr<RegistrationList> registration_data_list,
ServiceWorkerDatabase::Status status) {
if (status != ServiceWorkerDatabase::STATUS_OK &&
status != ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) {
ScheduleDeleteAndStartOver();
}
std::move(callback).Run(DatabaseStatusToStatusCode(status),
std::move(registration_data_list));
}
......@@ -1035,7 +1027,6 @@ void ServiceWorkerStorage::DidStoreRegistrationData(
const std::vector<int64_t>& newly_purgeable_resources,
ServiceWorkerDatabase::Status status) {
if (status != ServiceWorkerDatabase::STATUS_OK) {
ScheduleDeleteAndStartOver();
std::move(callback).Run(DatabaseStatusToStatusCode(status),
deleted_version.version_id,
newly_purgeable_resources);
......@@ -1064,7 +1055,6 @@ void ServiceWorkerStorage::DidDeleteRegistration(
const std::vector<int64_t>& newly_purgeable_resources,
ServiceWorkerDatabase::Status status) {
if (status != ServiceWorkerDatabase::STATUS_OK) {
ScheduleDeleteAndStartOver();
std::move(params->callback)
.Run(DatabaseStatusToStatusCode(status), deleted_version.version_id,
newly_purgeable_resources);
......
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