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

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

Issue 2850203002: PaymentHandler: Implement PaymentInstruments.keys(). (Closed)
Patch Set: PaymentHandler: Implement PaymentInstruments.Keys(). Created 3 years, 8 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 e1adc7c8a168fe766fc6b39b7c1763544210f47b..d87ff7fa3012ec62afa5a5dee9014a6db49036cc 100644
--- a/content/browser/service_worker/service_worker_storage.cc
+++ b/content/browser/service_worker/service_worker_storage.cc
@@ -693,6 +693,41 @@ void ServiceWorkerStorage::GetUserData(int64_t registration_id,
weak_factory_.GetWeakPtr(), callback)));
}
+void ServiceWorkerStorage::GetUserDataByKeyPrefix(
+ int64_t registration_id,
+ const std::string& key_prefix,
+ const GetUserDataCallback& callback) {
+ if (!LazyInitialize(base::Bind(&ServiceWorkerStorage::GetUserDataByKeyPrefix,
+ weak_factory_.GetWeakPtr(), registration_id,
+ key_prefix, callback))) {
+ if (state_ != INITIALIZING) {
+ RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(),
+ SERVICE_WORKER_ERROR_ABORT));
+ }
+ return;
+ }
+ DCHECK_EQ(INITIALIZED, state_);
+
+ if (registration_id == kInvalidServiceWorkerRegistrationId) {
+ RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(),
+ SERVICE_WORKER_ERROR_FAILED));
+ return;
+ }
+ if (key_prefix.empty()) {
+ RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(),
+ SERVICE_WORKER_ERROR_FAILED));
+ return;
+ }
+
+ database_task_manager_->GetTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ServiceWorkerStorage::GetUserDataByKeyPrefixInDB,
+ database_.get(), base::ThreadTaskRunnerHandle::Get(),
+ registration_id, key_prefix,
+ base::Bind(&ServiceWorkerStorage::DidGetUserData,
+ weak_factory_.GetWeakPtr(), callback)));
+}
+
void ServiceWorkerStorage::ClearUserData(int64_t registration_id,
const std::vector<std::string>& keys,
const StatusCallback& callback) {
@@ -1771,6 +1806,19 @@ void ServiceWorkerStorage::GetUserDataInDB(
base::Bind(callback, values, status));
}
+void ServiceWorkerStorage::GetUserDataByKeyPrefixInDB(
+ ServiceWorkerDatabase* database,
+ scoped_refptr<base::SequencedTaskRunner> original_task_runner,
+ int64_t registration_id,
+ const std::string& key_prefix,
+ const GetUserDataInDBCallback& callback) {
+ std::vector<std::string> values;
+ ServiceWorkerDatabase::Status status =
+ database->ReadUserDataByKeyPrefix(registration_id, key_prefix, &values);
+ original_task_runner->PostTask(FROM_HERE,
+ base::Bind(callback, values, status));
+}
+
void ServiceWorkerStorage::GetUserDataForAllRegistrationsInDB(
ServiceWorkerDatabase* database,
scoped_refptr<base::SequencedTaskRunner> original_task_runner,

Powered by Google App Engine
This is Rietveld 408576698