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

Unified Diff: content/public/browser/push_messaging_service.cc

Issue 1851423003: Make Web Push use InstanceID tokens instead of GCM registrations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iid4default
Patch Set: Rebase (main conflics in browsertest and PMMF) Created 4 years, 7 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/public/browser/push_messaging_service.cc
diff --git a/content/public/browser/push_messaging_service.cc b/content/public/browser/push_messaging_service.cc
index e43e9f94414408f0d775b9c01c0811f0db25be27..02d1013b692982a63f57d99e7043d9e822d4883a 100644
--- a/content/public/browser/push_messaging_service.cc
+++ b/content/public/browser/push_messaging_service.cc
@@ -59,6 +59,22 @@ void ClearPushSubscriptionIDOnIO(
base::Bind(&CallClosureFromIO, callback));
}
+void StorePushSubscriptionOnIOForTesting(
+ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
+ int64_t service_worker_registration_id,
+ const GURL& origin,
+ const std::string& subscription_id,
+ const std::string& sender_id,
+ const base::Closure& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ service_worker_context->StoreRegistrationUserData(
+ service_worker_registration_id, origin,
+ {{kPushRegistrationIdServiceWorkerKey, subscription_id},
+ {kPushSenderIdServiceWorkerKey, sender_id}},
+ base::Bind(&CallClosureFromIO, callback));
+}
+
scoped_refptr<ServiceWorkerContextWrapper> GetServiceWorkerContext(
BrowserContext* browser_context, const GURL& origin) {
StoragePartition* partition =
@@ -102,4 +118,25 @@ void PushMessagingService::ClearPushSubscriptionID(
callback));
}
+// static
+void PushMessagingService::StorePushSubscriptionForTesting(
+ BrowserContext* browser_context,
+ const GURL& origin,
+ int64_t service_worker_registration_id,
+ const std::string& subscription_id,
+ const std::string& sender_id,
+ const base::Closure& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&StorePushSubscriptionOnIOForTesting,
+ GetServiceWorkerContext(browser_context, origin),
+ service_worker_registration_id,
+ origin,
+ subscription_id,
+ sender_id,
+ callback));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698