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 154b02d2a988cb69dfd65d136655bf84c1b29968..4ac8e09aff6d6443ed159f471ce7904a3d25b429 100644 |
--- a/content/public/browser/push_messaging_service.cc |
+++ b/content/public/browser/push_messaging_service.cc |
@@ -5,18 +5,20 @@ |
#include "content/public/browser/push_messaging_service.h" |
#include "content/browser/service_worker/service_worker_context_wrapper.h" |
+#include "content/public/browser/browser_context.h" |
#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/storage_partition.h" |
+ |
+namespace content { |
namespace { |
const char kNotificationsShownServiceWorkerKey[] = |
"notifications_shown_by_last_few_pushes"; |
+const char kPushRegistrationIdServiceWorkerKey[] = |
+ "push_registration_id"; |
johnme
2015/02/16 20:27:45
Please add an extern declaration for the one in co
mlamouri (slow - plz ping)
2015/02/16 20:46:03
Done.
|
-} // namespace |
- |
-namespace content { |
- |
-static void CallGetNotificationsShownCallbackFromIO( |
+void CallGetNotificationsShownCallbackFromIO( |
const PushMessagingService::GetNotificationsShownCallback& callback, |
const std::string& data, |
ServiceWorkerStatusCode service_worker_status) { |
@@ -27,7 +29,7 @@ static void CallGetNotificationsShownCallbackFromIO( |
base::Bind(callback, data, success, not_found)); |
} |
-static void CallResultCallbackFromIO( |
+void CallResultCallbackFromIO( |
const ServiceWorkerContext::ResultCallback& callback, |
ServiceWorkerStatusCode service_worker_status) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
@@ -36,7 +38,7 @@ static void CallResultCallbackFromIO( |
base::Bind(callback, success)); |
} |
-static void GetNotificationsShownOnIO( |
+void GetNotificationsShownOnIO( |
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_wrapper, |
int64 service_worker_registration_id, |
const PushMessagingService::GetNotificationsShownCallback& callback) { |
@@ -46,7 +48,7 @@ static void GetNotificationsShownOnIO( |
base::Bind(&CallGetNotificationsShownCallbackFromIO, callback)); |
} |
-static void SetNotificationsShownOnIO( |
+void SetNotificationsShownOnIO( |
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_wrapper, |
int64 service_worker_registration_id, const GURL& origin, |
const std::string& data, |
@@ -58,6 +60,22 @@ static void SetNotificationsShownOnIO( |
base::Bind(&CallResultCallbackFromIO, callback)); |
} |
+void OnClearPushRegistrationServiceWorkerKey(ServiceWorkerStatusCode status) { |
+} |
+ |
+void ClearPushRegistrationIDOnIO( |
+ int64 service_worker_registration_id, |
+ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { |
johnme
2015/02/16 20:27:45
Nit: Please swap the argument order, for consisten
mlamouri (slow - plz ping)
2015/02/16 20:46:03
I guess PushMessagingRouter isn't consistent with
|
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ |
+ service_worker_context->context()->storage()->ClearUserData( |
+ service_worker_registration_id, |
+ kPushRegistrationIdServiceWorkerKey, |
+ base::Bind(&OnClearPushRegistrationServiceWorkerKey)); |
+} |
+ |
+} // anonymous namespace |
+ |
// static |
void PushMessagingService::GetNotificationsShownByLastFewPushes( |
ServiceWorkerContext* service_worker_context, |
@@ -92,4 +110,24 @@ void PushMessagingService::SetNotificationsShownByLastFewPushes( |
callback)); |
} |
+// static |
+void PushMessagingService::ClearPushRegistrationID( |
+ BrowserContext* browser_context, |
+ const GURL& origin, |
+ int64 service_worker_registration_id) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ StoragePartition* partition = |
+ BrowserContext::GetStoragePartitionForSite(browser_context, origin); |
+ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context = |
+ static_cast<ServiceWorkerContextWrapper*>( |
+ partition->GetServiceWorkerContext()); |
+ |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, |
+ FROM_HERE, |
+ base::Bind(&ClearPushRegistrationIDOnIO, |
+ service_worker_registration_id, |
+ service_worker_context)); |
+} |
+ |
} // namespace content |