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

Unified Diff: chrome/browser/services/gcm/push_messaging_service_impl.cc

Issue 793403002: Implement WebPushProvider.unregister() in Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mvan_2
Patch Set: browsertests and override fix Created 6 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
Index: chrome/browser/services/gcm/push_messaging_service_impl.cc
diff --git a/chrome/browser/services/gcm/push_messaging_service_impl.cc b/chrome/browser/services/gcm/push_messaging_service_impl.cc
index 80051f95a980c0820f098d9e6bf85442952a446d..0de93529b394a034fa4f1aa32eaa2b6b5bcb6dad 100644
--- a/chrome/browser/services/gcm/push_messaging_service_impl.cc
+++ b/chrome/browser/services/gcm/push_messaging_service_impl.cc
@@ -158,7 +158,7 @@ void PushMessagingServiceImpl::OnMessage(
if (!HasPermission(application_id.origin)) {
// The |origin| lost push permission. We need to unregister and drop this
// message.
- Unregister(application_id);
+ Unregister(application_id, UnregisterCallback());
return;
}
@@ -197,7 +197,7 @@ void PushMessagingServiceImpl::DeliverMessageCallback(
case content::PUSH_DELIVERY_STATUS_EVENT_WAITUNTIL_REJECTED:
break;
case content::PUSH_DELIVERY_STATUS_NO_SERVICE_WORKER:
- Unregister(application_id);
+ Unregister(application_id, UnregisterCallback());
break;
}
}
@@ -414,22 +414,36 @@ void PushMessagingServiceImpl::DidRequestPermission(
}
void PushMessagingServiceImpl::Unregister(
- const PushMessagingApplicationId& application_id) {
+ const GURL& requesting_origin,
+ int64 service_worker_registration_id,
+ const content::PushMessagingService::UnregisterCallback& callback) {
+ DCHECK(gcm_profile_service_->driver());
+
+ PushMessagingApplicationId application_id = PushMessagingApplicationId(
+ requesting_origin, service_worker_registration_id);
+ DCHECK(application_id.IsValid());
+
+ Unregister(application_id, callback);
+}
+
+void PushMessagingServiceImpl::Unregister(
+ const PushMessagingApplicationId& application_id,
+ const content::PushMessagingService::UnregisterCallback& callback) {
DCHECK(gcm_profile_service_->driver());
gcm_profile_service_->driver()->Unregister(
application_id.ToString(),
base::Bind(&PushMessagingServiceImpl::DidUnregister,
- weak_factory_.GetWeakPtr()));
+ weak_factory_.GetWeakPtr(), callback));
}
-void PushMessagingServiceImpl::DidUnregister(GCMClient::Result result) {
- if (result != GCMClient::SUCCESS) {
- DVLOG(1) << "GCM unregistration failed.";
- return;
- }
+void PushMessagingServiceImpl::DidUnregister(
+ const content::PushMessagingService::UnregisterCallback& callback,
+ GCMClient::Result result) {
+ callback.Run(result == GCMClient::SUCCESS);
- DecreasePushRegistrationCount(1);
+ if (result == GCMClient::SUCCESS)
+ DecreasePushRegistrationCount(1);
}
bool PushMessagingServiceImpl::HasPermission(const GURL& origin) {

Powered by Google App Engine
This is Rietveld 408576698