Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(655)

Unified Diff: content/browser/service_worker/service_worker_context_core.cc

Issue 1693303002: ServiceWorker: Make ServiceWorkerStorage more self-defensive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_context_core.cc
diff --git a/content/browser/service_worker/service_worker_context_core.cc b/content/browser/service_worker/service_worker_context_core.cc
index d2ffb5c4274c2eb21a11cf4f5ea2215b00bf7f33..6ef5ee375ce7a6fffe10f2e940de85ee265a5042 100644
--- a/content/browser/service_worker/service_worker_context_core.cc
+++ b/content/browser/service_worker/service_worker_context_core.cc
@@ -104,8 +104,9 @@ class ClearAllServiceWorkersHelper
void DidGetAllRegistrations(
const base::WeakPtr<ServiceWorkerContextCore>& context,
+ ServiceWorkerStatusCode status,
const std::vector<ServiceWorkerRegistrationInfo>& registrations) {
- if (!context)
+ if (!context || status != SERVICE_WORKER_OK)
return;
// Make a copy of live versions map because StopWorker() removes the version
// from it when we were starting up and don't have a process yet.
@@ -367,12 +368,6 @@ void ServiceWorkerContextCore::RegisterServiceWorker(
const RegistrationCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
was_service_worker_registered_ = true;
- if (storage()->IsDisabled()) {
- callback.Run(SERVICE_WORKER_ERROR_ABORT, std::string(),
- kInvalidServiceWorkerRegistrationId);
- return;
- }
-
job_coordinator_->Register(
pattern,
script_url,
@@ -387,9 +382,6 @@ void ServiceWorkerContextCore::UpdateServiceWorker(
ServiceWorkerRegistration* registration,
bool force_bypass_cache) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (storage()->IsDisabled())
- return;
-
job_coordinator_->Update(registration, force_bypass_cache);
}
@@ -400,12 +392,6 @@ void ServiceWorkerContextCore::UpdateServiceWorker(
ServiceWorkerProviderHost* provider_host,
const UpdateCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (storage()->IsDisabled()) {
- callback.Run(SERVICE_WORKER_ERROR_ABORT, std::string(),
- kInvalidServiceWorkerRegistrationId);
- return;
- }
-
job_coordinator_->Update(registration, force_bypass_cache,
skip_script_comparison, provider_host,
base::Bind(&ServiceWorkerContextCore::UpdateComplete,
@@ -433,11 +419,6 @@ void ServiceWorkerContextCore::UnregisterServiceWorker(
const GURL& pattern,
const UnregistrationCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (storage()->IsDisabled()) {
- callback.Run(SERVICE_WORKER_ERROR_ABORT);
- return;
- }
-
job_coordinator_->Unregister(
pattern,
base::Bind(&ServiceWorkerContextCore::UnregistrationComplete,
@@ -450,12 +431,6 @@ void ServiceWorkerContextCore::UnregisterServiceWorkers(
const GURL& origin,
const UnregistrationCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (storage()->IsDisabled()) {
- // Not posting as new task to match implementations above.
- callback.Run(SERVICE_WORKER_ERROR_ABORT);
- return;
- }
-
storage()->GetAllRegistrationsInfos(base::Bind(
&ServiceWorkerContextCore::DidGetAllRegistrationsForUnregisterForOrigin,
AsWeakPtr(), callback, origin));
@@ -464,7 +439,12 @@ void ServiceWorkerContextCore::UnregisterServiceWorkers(
void ServiceWorkerContextCore::DidGetAllRegistrationsForUnregisterForOrigin(
const UnregistrationCallback& result,
const GURL& origin,
+ ServiceWorkerStatusCode status,
const std::vector<ServiceWorkerRegistrationInfo>& registrations) {
+ if (status != SERVICE_WORKER_OK) {
+ result.Run(status);
+ return;
+ }
std::set<GURL> scopes;
for (const auto& registration_info : registrations) {
if (origin == registration_info.pattern.GetOrigin()) {

Powered by Google App Engine
This is Rietveld 408576698