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

Unified Diff: chrome/browser/push_messaging/push_messaging_service_impl.cc

Issue 990283002: Push API: Prevent DCHECK when clear permissions after clear SW DB (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@retrycallback
Patch Set: Fix typo Created 5 years, 9 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
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/push_messaging/push_messaging_service_impl.cc
diff --git a/chrome/browser/push_messaging/push_messaging_service_impl.cc b/chrome/browser/push_messaging/push_messaging_service_impl.cc
index da017ae9308b3500412c942cf04f82253c41560d..20c0597fe46b2772df74f93fefa1a69a73d71961 100644
--- a/chrome/browser/push_messaging/push_messaging_service_impl.cc
+++ b/chrome/browser/push_messaging/push_messaging_service_impl.cc
@@ -649,8 +649,12 @@ void PushMessagingServiceImpl::Unregister(
was_registered, callback);
#if defined(OS_ANDROID)
// On Android the backend is different, and requires the original sender_id.
- GetGCMDriver()->UnregisterWithSenderId(app_id_guid, sender_id,
- unregister_callback);
+ // UnregisterBecausePermissionRevoked sometimes calls us with an empty one.
+ if (sender_id.empty())
+ unregister_callback.Run(gcm::GCMClient::INVALID_PARAMETER);
+ else
+ GetGCMDriver()->UnregisterWithSenderId(app_id_guid, sender_id,
+ unregister_callback);
#else
GetGCMDriver()->Unregister(app_id_guid, unregister_callback);
#endif
@@ -741,6 +745,12 @@ void PushMessagingServiceImpl::UnregisterBecausePermissionRevoked(
base::Closure barrier_closure = base::BarrierClosure(2, closure);
// Unregister the PushMessagingApplicationId with the push service.
+ // It's possible for GetSenderId to have failed and sender_id to be empty, if
+ // cookies (and the SW database) for an origin got cleared before permissions
+ // are cleared for the origin. In that case Unregister will just delete the
+ // application ID to block future messages.
+ // TODO(johnme): Auto-unregister before SW DB is cleared
+ // (https://crbug.com/402458).
Unregister(id.app_id_guid(), sender_id,
base::Bind(&UnregisterCallbackToClosure, barrier_closure));
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698