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

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

Issue 2569353003: Make ServiceWorkerStorage's UserData functions call LazyInitialize (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_storage_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 adfca9c0f12f0fcb4116e994676670d0530cc757..b973019663fcf004c30415178a9904fb2f6f5146 100644
--- a/content/browser/service_worker/service_worker_storage.cc
+++ b/content/browser/service_worker/service_worker_storage.cc
@@ -627,11 +627,14 @@ void ServiceWorkerStorage::StoreUserData(
const GURL& origin,
const std::vector<std::pair<std::string, std::string>>& key_value_pairs,
const StatusCallback& callback) {
- DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_;
- if (IsDisabled()) {
- RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
+ if (!LazyInitialize(base::Bind(&ServiceWorkerStorage::StoreUserData,
+ weak_factory_.GetWeakPtr(), registration_id,
+ origin, key_value_pairs, callback))) {
+ if (state_ != INITIALIZING)
+ RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
return;
}
+ DCHECK_EQ(INITIALIZED, state_);
if (registration_id == kInvalidServiceWorkerRegistrationId ||
key_value_pairs.empty()) {
@@ -657,12 +660,16 @@ void ServiceWorkerStorage::StoreUserData(
void ServiceWorkerStorage::GetUserData(int64_t registration_id,
const std::vector<std::string>& keys,
const GetUserDataCallback& callback) {
- DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_;
- if (IsDisabled()) {
- RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(),
- SERVICE_WORKER_ERROR_ABORT));
+ if (!LazyInitialize(base::Bind(&ServiceWorkerStorage::GetUserData,
+ weak_factory_.GetWeakPtr(), registration_id,
+ keys, 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 || keys.empty()) {
RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(),
@@ -688,7 +695,15 @@ void ServiceWorkerStorage::GetUserData(int64_t registration_id,
void ServiceWorkerStorage::ClearUserData(int64_t registration_id,
const std::vector<std::string>& keys,
const StatusCallback& callback) {
- DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_;
+ if (!LazyInitialize(base::Bind(&ServiceWorkerStorage::ClearUserData,
+ weak_factory_.GetWeakPtr(), registration_id,
+ keys, callback))) {
+ if (state_ != INITIALIZING)
+ RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
+ return;
+ }
+ DCHECK_EQ(INITIALIZED, state_);
+
if (IsDisabled()) {
RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
return;
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_storage_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698