| 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 54eb72287557b824d2459de2ac7a771ccaa6a1aa..b0cb8a45aa21f9b552ee8d147069ca1005bcb267 100644
|
| --- a/content/browser/push_messaging/push_messaging_message_filter.cc
|
| +++ b/content/browser/push_messaging/push_messaging_message_filter.cc
|
| @@ -75,7 +75,8 @@ class PushMessagingMessageFilter::Core
|
| // Called via PostTask from IO thread.
|
| void UnregisterFromService(int request_id,
|
| int64 service_worker_registration_id,
|
| - const GURL& requesting_origin);
|
| + const GURL& requesting_origin,
|
| + const std::string& sender_id);
|
|
|
| // Public GetRegistration methods on UI thread -------------------------------
|
|
|
| @@ -450,18 +451,45 @@ void PushMessagingMessageFilter::OnUnregister(
|
| service_worker_context_->context()->storage()->GetUserData(
|
| service_worker_registration_id,
|
| kPushRegistrationIdServiceWorkerKey,
|
| - base::Bind(&PushMessagingMessageFilter::DoUnregister,
|
| - weak_factory_io_to_io_.GetWeakPtr(),
|
| - request_id,
|
| - service_worker_registration_id,
|
| - service_worker_registration->pattern().GetOrigin()));
|
| + base::Bind(
|
| + &PushMessagingMessageFilter::UnregisterHavingGottenPushRegistrationId,
|
| + weak_factory_io_to_io_.GetWeakPtr(), request_id,
|
| + service_worker_registration_id,
|
| + service_worker_registration->pattern().GetOrigin()));
|
| }
|
|
|
| -void PushMessagingMessageFilter::DoUnregister(
|
| +void PushMessagingMessageFilter::UnregisterHavingGottenPushRegistrationId(
|
| 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
|
| + 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::UnregisterHavingGottenSenderId,
|
| + 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.
|
| + UnregisterHavingGottenSenderId(request_id, service_worker_registration_id,
|
| + requesting_origin, "" /* sender_id */,
|
| + service_worker_status);
|
| + }
|
| +}
|
| +
|
| +void PushMessagingMessageFilter::UnregisterHavingGottenSenderId(
|
| + 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);
|
|
|
| @@ -470,7 +498,8 @@ void PushMessagingMessageFilter::DoUnregister(
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&Core::UnregisterFromService, ui_core_, request_id,
|
| - service_worker_registration_id, requesting_origin));
|
| + service_worker_registration_id, requesting_origin,
|
| + sender_id));
|
| return;
|
| case SERVICE_WORKER_ERROR_NOT_FOUND:
|
| // We did not find a registration, stop here and notify the renderer that
|
| @@ -503,7 +532,8 @@ void PushMessagingMessageFilter::DoUnregister(
|
| void PushMessagingMessageFilter::Core::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()) {
|
| BrowserThread::PostTask(
|
| @@ -514,7 +544,7 @@ void PushMessagingMessageFilter::Core::UnregisterFromService(
|
| }
|
|
|
| service()->Unregister(
|
| - requesting_origin, service_worker_registration_id,
|
| + requesting_origin, service_worker_registration_id, sender_id,
|
| false /* retry_on_failure */,
|
| base::Bind(&Core::DidUnregisterFromService,
|
| weak_factory_ui_to_ui_.GetWeakPtr(),
|
|
|