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 2db301c1b627bb2ed9fec1f69b4852c9573194dd..535b6a402700aefe223ee0b4d021fdfb54e32c03 100644 |
--- a/content/browser/service_worker/service_worker_database.cc |
+++ b/content/browser/service_worker/service_worker_database.cc |
@@ -881,6 +881,50 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadUserData( |
return status; |
} |
+ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadUserDataByKeyPrefix( |
+ int64_t registration_id, |
+ const std::string key_prefix, |
+ std::vector<std::string>* user_data_values) { |
+ DCHECK(sequence_checker_.CalledOnValidSequence()); |
+ DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); |
+ DCHECK(user_data_values); |
+ |
+ Status status = LazyOpen(false); |
+ if (IsNewOrNonexistentDatabase(status)) |
+ return STATUS_ERROR_NOT_FOUND; |
+ if (status != STATUS_OK) |
+ return status; |
+ |
+ std::string prefix = CreateUserDataKey(registration_id, key_prefix); |
+ { |
+ std::unique_ptr<leveldb::Iterator> itr( |
+ db_->NewIterator(leveldb::ReadOptions())); |
+ for (itr->Seek(prefix); itr->Valid(); itr->Next()) { |
+ status = LevelDBStatusToStatus(itr->status()); |
+ if (status != STATUS_OK) { |
+ user_data_values->clear(); |
+ break; |
+ } |
+ |
+ if (!itr->key().starts_with(prefix)) |
+ break; |
+ |
+ std::string user_data_value; |
+ status = LevelDBStatusToStatus( |
+ db_->Get(leveldb::ReadOptions(), itr->key(), &user_data_value)); |
+ if (status != STATUS_OK) { |
+ user_data_values->clear(); |
+ break; |
+ } |
+ |
+ user_data_values->push_back(user_data_value); |
+ } |
+ } |
+ |
+ HandleReadResult(FROM_HERE, status); |
+ return status; |
+} |
+ |
ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteUserData( |
int64_t registration_id, |
const GURL& origin, |