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

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

Issue 1146913004: Service Worker: Add ServiceWorkerContainer.getRegistrations() method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add database unittests for reading resources list; Rebase to ToT. Created 5 years, 6 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_database.cc
diff --git a/content/browser/service_worker/service_worker_database.cc b/content/browser/service_worker/service_worker_database.cc
index 4da2ca77aa7de0fda7db944507d15f7e467bc4e5..b78ac89368b260352eff9a2c5e362648fdd320ec 100644
--- a/content/browser/service_worker/service_worker_database.cc
+++ b/content/browser/service_worker/service_worker_database.cc
@@ -449,7 +449,8 @@ ServiceWorkerDatabase::GetOriginsWithRegistrations(std::set<GURL>* origins) {
ServiceWorkerDatabase::Status ServiceWorkerDatabase::GetRegistrationsForOrigin(
const GURL& origin,
- std::vector<RegistrationData>* registrations) {
+ std::vector<RegistrationData>* registrations,
+ std::vector<std::vector<ResourceRecord>>* opt_resources_list) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
DCHECK(registrations->empty());
@@ -480,6 +481,17 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::GetRegistrationsForOrigin(
return status;
}
registrations->push_back(registration);
+
+ if (opt_resources_list) {
+ std::vector<ResourceRecord> resources;
+ status = ReadResourceRecords(registration.version_id, &resources);
+ if (status != STATUS_OK) {
+ HandleReadResult(FROM_HERE, status);
falken 2015/06/09 07:37:51 Maybe we should do registrations->clear() here als
+ opt_resources_list->clear();
+ return status;
+ }
+ opt_resources_list->push_back(resources);
+ }
}
HandleReadResult(FROM_HERE, status);
@@ -735,7 +747,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteRegistration(
// |registration_id| is the only one for |origin|.
// TODO(nhiroki): Check the uniqueness by more efficient way.
std::vector<RegistrationData> registrations;
- status = GetRegistrationsForOrigin(origin, &registrations);
+ status = GetRegistrationsForOrigin(origin, &registrations, nullptr);
if (status != STATUS_OK)
return status;
@@ -952,7 +964,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteAllDataForOrigins(
batch.Delete(CreateUniqueOriginKey(origin));
std::vector<RegistrationData> registrations;
- status = GetRegistrationsForOrigin(origin, &registrations);
+ status = GetRegistrationsForOrigin(origin, &registrations, nullptr);
if (status != STATUS_OK)
return status;

Powered by Google App Engine
This is Rietveld 408576698