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

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: Added check logic in ServiceWorkerStorage and updated tests. 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..ef5740ce4a9ebf90579b94b512f4b143d3540b7b 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()) {
michaeln 2015/05/14 03:27:59 thnx!
+ 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,12 @@ void ServiceWorkerStorage::ReturnFoundRegistration(
const FindRegistrationCallback& callback,
const ServiceWorkerDatabase::RegistrationData& data,
const ResourceList& resources) {
+ if (resources.empty()) {
michaeln 2015/05/14 03:27:59 Is this code reachable with your changes to servic
horo 2015/05/14 03:46:50 Ah, yes. It should be DCHECK(!resources.empty());
+ ScheduleDeleteAndStartOver();
+ callback.Run(SERVICE_WORKER_ERROR_FAILED,
+ scoped_refptr<ServiceWorkerRegistration>());
+ return;
+ }
scoped_refptr<ServiceWorkerRegistration> registration =
GetOrCreateRegistration(data, resources);
CompleteFindNow(registration, SERVICE_WORKER_OK, callback);

Powered by Google App Engine
This is Rietveld 408576698