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

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

Issue 1135743002: Check the size of ResourceRecords in ServiceWorkerDatabase::ReadRegistration() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK in ServiceWorkerStorage::ReturnFoundRegistration() Created 5 years, 7 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_storage.cc
diff --git a/content/browser/service_worker/service_worker_storage.cc b/content/browser/service_worker/service_worker_storage.cc
index c8a11c39fb3e805332083e5430795a8724fa698e..540a2e373aba76ca727be839097590252e3257b3 100644
--- a/content/browser/service_worker/service_worker_storage.cc
+++ b/content/browser/service_worker/service_worker_storage.cc
@@ -539,6 +539,11 @@ void ServiceWorkerStorage::StoreRegistration(
ResourceList resources;
version->script_cache_map()->GetResources(&resources);
+ if (resources.empty()) {
+ RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED));
+ return;
+ }
+
uint64 resources_total_size_bytes = 0;
for (const auto& resource : resources) {
resources_total_size_bytes += resource.size_bytes;
@@ -1094,6 +1099,7 @@ void ServiceWorkerStorage::ReturnFoundRegistration(
const FindRegistrationCallback& callback,
const ServiceWorkerDatabase::RegistrationData& data,
const ResourceList& resources) {
+ DCHECK(!resources.empty());
scoped_refptr<ServiceWorkerRegistration> registration =
GetOrCreateRegistration(data, resources);
CompleteFindNow(registration, SERVICE_WORKER_OK, callback);

Powered by Google App Engine
This is Rietveld 408576698