Index: content/browser/push_messaging/push_messaging_message_filter.cc |
diff --git a/content/browser/push_messaging/push_messaging_message_filter.cc b/content/browser/push_messaging/push_messaging_message_filter.cc |
index 8e151d73c6caf543bb8d33f888366eb34bbfa47f..8d12c53a57b898bd18e9da795330e9ec7808908f 100644 |
--- a/content/browser/push_messaging/push_messaging_message_filter.cc |
+++ b/content/browser/push_messaging/push_messaging_message_filter.cc |
@@ -367,18 +367,45 @@ void PushMessagingMessageFilter::OnUnregister( |
service_worker_context_->context()->storage()->GetUserData( |
service_worker_registration_id, |
kPushRegistrationIdServiceWorkerKey, |
- base::Bind(&PushMessagingMessageFilter::DoUnregister, |
+ base::Bind(&PushMessagingMessageFilter::UnregisterWithPushRegistrationId, |
weak_factory_io_to_io_.GetWeakPtr(), |
request_id, |
service_worker_registration_id, |
service_worker_registration->pattern().GetOrigin())); |
} |
-void PushMessagingMessageFilter::DoUnregister( |
+void PushMessagingMessageFilter::UnregisterWithPushRegistrationId( |
int request_id, |
int64 service_worker_registration_id, |
const GURL& requesting_origin, |
- const std::string& push_registration_id, |
+ const std::string& push_registration_id, // Unused, we just want the status |
Peter Beverloo
2015/02/17 18:49:36
I find it odd that the method is called "Unregiste
johnme
2015/02/17 21:24:07
I went with UnregisterHavingGottenPushRegistration
|
+ ServiceWorkerStatusCode service_worker_status) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ |
+ if (service_worker_status == SERVICE_WORKER_OK) { |
+ service_worker_context_->context()->storage()->GetUserData( |
+ service_worker_registration_id, |
+ kSenderIdServiceWorkerKey, |
+ base::Bind( |
+ &PushMessagingMessageFilter::UnregisterWithSenderId, |
+ weak_factory_io_to_io_.GetWeakPtr(), |
+ request_id, |
+ service_worker_registration_id, |
+ requesting_origin)); |
+ } else { |
+ // Errors are handled the same, whether we were trying to get the |
+ // push_registration_id or the sender_id. |
+ UnregisterWithSenderId(request_id, service_worker_registration_id, |
+ requesting_origin, "" /* sender_id */, |
+ service_worker_status); |
+ } |
+} |
+ |
+void PushMessagingMessageFilter::UnregisterWithSenderId( |
+ int request_id, |
+ int64 service_worker_registration_id, |
+ const GURL& requesting_origin, |
+ const std::string& sender_id, |
ServiceWorkerStatusCode service_worker_status) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
@@ -390,7 +417,8 @@ void PushMessagingMessageFilter::DoUnregister( |
this, |
request_id, |
service_worker_registration_id, |
- requesting_origin)); |
+ requesting_origin, |
+ sender_id)); |
return; |
case SERVICE_WORKER_ERROR_NOT_FOUND: |
// We did not find a registration, stop here and notify the renderer that |
@@ -423,7 +451,8 @@ void PushMessagingMessageFilter::DoUnregister( |
void PushMessagingMessageFilter::UnregisterFromService( |
int request_id, |
int64 service_worker_registration_id, |
- const GURL& requesting_origin) { |
+ const GURL& requesting_origin, |
+ const std::string& sender_id) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
if (!service()) { |
DidUnregister(request_id, PUSH_UNREGISTRATION_STATUS_UNKNOWN_ERROR); |
@@ -431,7 +460,7 @@ void PushMessagingMessageFilter::UnregisterFromService( |
} |
service()->Unregister( |
- requesting_origin, service_worker_registration_id, |
+ requesting_origin, service_worker_registration_id, sender_id, |
false /* retry_on_failure */, |
base::Bind(&PushMessagingMessageFilter::DidUnregisterFromService, |
weak_factory_ui_to_ui_.GetWeakPtr(), |