Index: content/browser/service_worker/service_worker_database.cc |
diff --git a/content/browser/service_worker/service_worker_database.cc b/content/browser/service_worker/service_worker_database.cc |
index 2e69f621fe41e7be321c86f47f2e439cd5673091..370733302787d31fa5629bd7a838c6e1a73a61d2 100644 |
--- a/content/browser/service_worker/service_worker_database.cc |
+++ b/content/browser/service_worker/service_worker_database.cc |
@@ -973,6 +973,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteResourceIdsInBatch( |
// Value should be empty. |
batch->Put(CreateResourceIdKey(id_key_prefix, *itr), ""); |
} |
+ BumpNextResourceIdIfNeeded(ids, batch); |
michaeln
2014/07/09 02:36:10
lions and tigers and bears, thnx for fixing this
nhiroki
2014/07/09 03:43:10
Great catch! Thank you :)
|
return STATUS_OK; |
} |
@@ -1054,6 +1055,22 @@ void ServiceWorkerDatabase::BumpNextRegistrationIdIfNeeded( |
} |
} |
+void ServiceWorkerDatabase::BumpNextResourceIdIfNeeded( |
+ const std::set<int64>& used_ids, |
+ leveldb::WriteBatch* batch) { |
+ DCHECK(batch); |
+ int64 old_id = next_avail_resource_id_; |
+ for (std::set<int64>::const_iterator itr = used_ids.begin(); |
nhiroki
2014/07/09 03:43:10
IIUC, std::set is always sorted and the last eleme
falken
2014/07/09 04:31:14
Ah, looks right. Switched to look at the last elem
|
+ itr != used_ids.end(); |
+ ++itr) { |
+ if (next_avail_resource_id_ <= *itr) |
+ next_avail_resource_id_ = *itr + 1; |
+ } |
+ |
+ if (next_avail_resource_id_ != old_id) |
+ batch->Put(kNextResIdKey, base::Int64ToString(next_avail_resource_id_)); |
+} |
+ |
void ServiceWorkerDatabase::BumpNextVersionIdIfNeeded( |
int64 used_id, leveldb::WriteBatch* batch) { |
DCHECK(batch); |