Chromium Code Reviews| 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 da9d510f10eac493902c0fd86cd5a5978fe7cb19..c14359ba0f108ab5c93911e42a790220f92ceb96 100644 | 
| --- a/content/browser/push_messaging/push_messaging_message_filter.cc | 
| +++ b/content/browser/push_messaging/push_messaging_message_filter.cc | 
| @@ -26,39 +26,39 @@ | 
| namespace content { | 
| const char kPushSenderIdServiceWorkerKey[] = "push_sender_id"; | 
| -const char kPushRegistrationIdServiceWorkerKey[] = "push_registration_id"; | 
| +const char kPushSubscriptionIdServiceWorkerKey[] = "push_registration_id"; | 
| namespace { | 
| // These UMA methods are only called from IO thread, but it would be acceptable | 
| // (even though slightly racy) to call them from UI thread as well, see | 
| // https://groups.google.com/a/chromium.org/d/msg/chromium-dev/FNzZRJtN2aw/Aw0CWAXJJ1kJ | 
| -void RecordRegistrationStatus(PushRegistrationStatus status) { | 
| +void RecordSubscriptionStatus(PushSubscriptionStatus status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| UMA_HISTOGRAM_ENUMERATION("PushMessaging.RegistrationStatus", | 
| status, | 
| - PUSH_REGISTRATION_STATUS_LAST + 1); | 
| + PUSH_SUBSCRIPTION_STATUS_LAST + 1); | 
| } | 
| -void RecordUnregistrationStatus(PushUnregistrationStatus status) { | 
| +void RecordUnsubscriptionStatus(PushUnsubscriptionStatus status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| UMA_HISTOGRAM_ENUMERATION("PushMessaging.UnregistrationStatus", | 
| status, | 
| - PUSH_UNREGISTRATION_STATUS_LAST + 1); | 
| + PUSH_UNSUBSCRIPTION_STATUS_LAST + 1); | 
| } | 
| -void RecordGetRegistrationStatus(PushGetRegistrationStatus status) { | 
| +void RecordGetSubscriptionStatus(PushGetSubscriptionStatus status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| UMA_HISTOGRAM_ENUMERATION("PushMessaging.GetRegistrationStatus", | 
| status, | 
| - PUSH_GETREGISTRATION_STATUS_LAST + 1); | 
| + PUSH_GETSUBSCRIPTION_STATUS_LAST + 1); | 
| } | 
| } // namespace | 
| -struct PushMessagingMessageFilter::RegisterData { | 
| - RegisterData(); | 
| - RegisterData(const RegisterData& other) = default; | 
| +struct PushMessagingMessageFilter::SubscribeData { | 
| + SubscribeData(); | 
| + SubscribeData(const SubscribeData& other) = default; | 
| bool FromDocument() const; | 
| int request_id; | 
| GURL requesting_origin; | 
| @@ -75,18 +75,18 @@ class PushMessagingMessageFilter::Core { | 
| Core(const base::WeakPtr<PushMessagingMessageFilter>& io_parent, | 
| int render_process_id); | 
| - // Public Register methods on UI thread -------------------------------------- | 
| + // Public Subscribe methods on UI thread ------------------------------------- | 
| // Called via PostTask from IO thread. | 
| - void RegisterOnUI(const RegisterData& data, const std::string& sender_id); | 
| + void SubscribeOnUI(const SubscribeData& data, const std::string& sender_id); | 
| - // Public Unregister methods on UI thread ------------------------------------ | 
| + // Public Unsubscribe methods on UI thread ----------------------------------- | 
| // Called via PostTask from IO thread. | 
| - void UnregisterFromService(int request_id, | 
| - int64_t service_worker_registration_id, | 
| - const GURL& requesting_origin, | 
| - const std::string& sender_id); | 
| + void UnsubscribeFromService(int request_id, | 
| + int64_t service_worker_registration_id, | 
| + const GURL& requesting_origin, | 
| + const std::string& sender_id); | 
| // Public GetPermission methods on UI thread --------------------------------- | 
| @@ -109,17 +109,18 @@ class PushMessagingMessageFilter::Core { | 
| ~Core(); | 
| - // Private Register methods on UI thread ------------------------------------- | 
| + // Private Subscribe methods on UI thread ------------------------------------ | 
| - void DidRegister(const RegisterData& data, | 
| - const std::string& push_registration_id, | 
| - PushRegistrationStatus status); | 
| + void DidSubscribe(const SubscribeData& data, | 
| + const std::string& push_subscription_id, | 
| + PushSubscriptionStatus status); | 
| - // Private Unregister methods on UI thread ----------------------------------- | 
| + // Private Unsubscribe methods on UI thread ---------------------------------- | 
| - void DidUnregisterFromService(int request_id, | 
| - int64_t service_worker_registration_id, | 
| - PushUnregistrationStatus unregistration_status); | 
| + void DidUnsubscribeFromService( | 
| + int request_id, | 
| + int64_t service_worker_registration_id, | 
| + PushUnsubscriptionStatus unsubscription_status); | 
| // Private helper methods on UI thread --------------------------------------- | 
| @@ -138,14 +139,14 @@ class PushMessagingMessageFilter::Core { | 
| }; | 
| -PushMessagingMessageFilter::RegisterData::RegisterData() | 
| +PushMessagingMessageFilter::SubscribeData::SubscribeData() | 
| : request_id(0), | 
| service_worker_registration_id(0), | 
| user_visible(false), | 
| render_frame_id(ChildProcessHost::kInvalidUniqueID) { | 
| } | 
| -bool PushMessagingMessageFilter::RegisterData::FromDocument() const { | 
| +bool PushMessagingMessageFilter::SubscribeData::FromDocument() const { | 
| return render_frame_id != ChildProcessHost::kInvalidUniqueID; | 
| } | 
| @@ -191,13 +192,14 @@ bool PushMessagingMessageFilter::OnMessageReceived( | 
| const IPC::Message& message) { | 
| bool handled = true; | 
| IPC_BEGIN_MESSAGE_MAP(PushMessagingMessageFilter, message) | 
| - IPC_MESSAGE_HANDLER(PushMessagingHostMsg_RegisterFromDocument, | 
| - OnRegisterFromDocument) | 
| - IPC_MESSAGE_HANDLER(PushMessagingHostMsg_RegisterFromWorker, | 
| - OnRegisterFromWorker) | 
| - IPC_MESSAGE_HANDLER(PushMessagingHostMsg_Unregister, | 
| - OnUnregister) | 
| - IPC_MESSAGE_HANDLER(PushMessagingHostMsg_GetRegistration, OnGetRegistration) | 
| + IPC_MESSAGE_HANDLER(PushMessagingHostMsg_SubscribeFromDocument, | 
| + OnSubscribeFromDocument) | 
| + IPC_MESSAGE_HANDLER(PushMessagingHostMsg_SubscribeFromWorker, | 
| + OnSubscribeFromWorker) | 
| + IPC_MESSAGE_HANDLER(PushMessagingHostMsg_Unsubscribe, | 
| + OnUnsubscribe) | 
| + IPC_MESSAGE_HANDLER(PushMessagingHostMsg_GetSubscription, | 
| + OnGetSubscription) | 
| IPC_MESSAGE_HANDLER(PushMessagingHostMsg_GetPermissionStatus, | 
| OnGetPermissionStatus) | 
| IPC_MESSAGE_UNHANDLED(handled = false) | 
| @@ -205,11 +207,11 @@ bool PushMessagingMessageFilter::OnMessageReceived( | 
| return handled; | 
| } | 
| -// Register methods on both IO and UI threads, merged in order of use from | 
| +// Subscription methods on both IO and UI threads, merged in order of use from | 
| 
 
johnme
2015/05/07 13:31:25
Nit: "Subscribe" for consistency (even though it's
 
 | 
| // PushMessagingMessageFilter and Core. | 
| // ----------------------------------------------------------------------------- | 
| -void PushMessagingMessageFilter::OnRegisterFromDocument( | 
| +void PushMessagingMessageFilter::OnSubscribeFromDocument( | 
| int render_frame_id, | 
| int request_id, | 
| const std::string& sender_id, | 
| @@ -218,7 +220,7 @@ void PushMessagingMessageFilter::OnRegisterFromDocument( | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| // TODO(mvanouwerkerk): Validate arguments? | 
| // TODO(peter): Persist |user_visible| in Service Worker storage. | 
| - RegisterData data; | 
| + SubscribeData data; | 
| data.request_id = request_id; | 
| data.service_worker_registration_id = service_worker_registration_id; | 
| data.render_frame_id = render_frame_id; | 
| @@ -229,7 +231,7 @@ void PushMessagingMessageFilter::OnRegisterFromDocument( | 
| service_worker_registration_id); | 
| if (!service_worker_registration || | 
| !service_worker_registration->active_version()) { | 
| - SendRegisterError(data, PUSH_REGISTRATION_STATUS_NO_SERVICE_WORKER); | 
| + SendSubscribeError(data, PUSH_SUBSCRIPTION_STATUS_NO_SERVICE_WORKER); | 
| return; | 
| } | 
| data.requesting_origin = service_worker_registration->pattern().GetOrigin(); | 
| @@ -244,12 +246,12 @@ void PushMessagingMessageFilter::OnRegisterFromDocument( | 
| data, sender_id)); | 
| } | 
| -void PushMessagingMessageFilter::OnRegisterFromWorker( | 
| +void PushMessagingMessageFilter::OnSubscribeFromWorker( | 
| int request_id, | 
| int64_t service_worker_registration_id, | 
| bool user_visible) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| - RegisterData data; | 
| + SubscribeData data; | 
| data.request_id = request_id; | 
| data.service_worker_registration_id = service_worker_registration_id; | 
| data.user_visible = user_visible; | 
| @@ -258,57 +260,57 @@ void PushMessagingMessageFilter::OnRegisterFromWorker( | 
| service_worker_context_->GetLiveRegistration( | 
| service_worker_registration_id); | 
| if (!service_worker_registration) { | 
| - SendRegisterError(data, PUSH_REGISTRATION_STATUS_NO_SERVICE_WORKER); | 
| + SendSubscribeError(data, PUSH_SUBSCRIPTION_STATUS_NO_SERVICE_WORKER); | 
| return; | 
| } | 
| data.requesting_origin = service_worker_registration->pattern().GetOrigin(); | 
| // This sender_id will be ignored; instead it will be fetched from storage. | 
| - CheckForExistingRegistration(data, std::string() /* sender_id */); | 
| + CheckForExistingSubscription(data, std::string() /* sender_id */); | 
| } | 
| void PushMessagingMessageFilter::DidPersistSenderId( | 
| - const RegisterData& data, | 
| + const SubscribeData& data, | 
| const std::string& sender_id, | 
| ServiceWorkerStatusCode service_worker_status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| if (service_worker_status != SERVICE_WORKER_OK) | 
| - SendRegisterError(data, PUSH_REGISTRATION_STATUS_STORAGE_ERROR); | 
| + SendSubscribeError(data, PUSH_SUBSCRIPTION_STATUS_STORAGE_ERROR); | 
| else | 
| - CheckForExistingRegistration(data, sender_id); | 
| + CheckForExistingSubscription(data, sender_id); | 
| } | 
| -void PushMessagingMessageFilter::CheckForExistingRegistration( | 
| - const RegisterData& data, | 
| +void PushMessagingMessageFilter::CheckForExistingSubscription( | 
| + const SubscribeData& data, | 
| const std::string& sender_id) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| service_worker_context_->GetRegistrationUserData( | 
| data.service_worker_registration_id, | 
| - kPushRegistrationIdServiceWorkerKey, | 
| - base::Bind(&PushMessagingMessageFilter::DidCheckForExistingRegistration, | 
| + kPushSubscriptionIdServiceWorkerKey, | 
| + base::Bind(&PushMessagingMessageFilter::DidCheckForExistingSubscription, | 
| weak_factory_io_to_io_.GetWeakPtr(), data, sender_id)); | 
| } | 
| -void PushMessagingMessageFilter::DidCheckForExistingRegistration( | 
| - const RegisterData& data, | 
| +void PushMessagingMessageFilter::DidCheckForExistingSubscription( | 
| + const SubscribeData& data, | 
| const std::string& sender_id, | 
| - const std::string& push_registration_id, | 
| + const std::string& push_subscription_id, | 
| ServiceWorkerStatusCode service_worker_status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| if (service_worker_status == SERVICE_WORKER_OK) { | 
| - SendRegisterSuccess(data, PUSH_REGISTRATION_STATUS_SUCCESS_FROM_CACHE, | 
| - push_registration_id); | 
| + SendSubscribeSuccess(data, PUSH_SUBSCRIPTION_STATUS_SUCCESS_FROM_CACHE, | 
| + push_subscription_id); | 
| return; | 
| } | 
| - // TODO(johnme): The spec allows the register algorithm to reject with an | 
| + // TODO(johnme): The spec allows the subscription algorithm to reject with an | 
| // AbortError when accessing storage fails. Perhaps we should do that if | 
| // service_worker_status != SERVICE_WORKER_ERROR_NOT_FOUND instead of | 
| - // attempting to do a fresh registration? | 
| - // https://w3c.github.io/push-api/#widl-PushRegistrationManager-register-Promise-PushRegistration | 
| + // attempting to do a fresh subscription? | 
| + // https://w3c.github.io/push-api/#widl-PushManager-subscribe-Promise-PushSubscription--PushSubscriptionOptions-options | 
| if (data.FromDocument()) { | 
| BrowserThread::PostTask( | 
| BrowserThread::UI, FROM_HERE, | 
| - base::Bind(&Core::RegisterOnUI, base::Unretained(ui_core_.get()), | 
| + base::Bind(&Core::SubscribeOnUI, base::Unretained(ui_core_.get()), | 
| data, sender_id)); | 
| } else { | 
| service_worker_context_->GetRegistrationUserData( | 
| @@ -320,22 +322,22 @@ void PushMessagingMessageFilter::DidCheckForExistingRegistration( | 
| } | 
| void PushMessagingMessageFilter::DidGetSenderIdFromStorage( | 
| - const RegisterData& data, | 
| + const SubscribeData& data, | 
| const std::string& sender_id, | 
| ServiceWorkerStatusCode service_worker_status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| if (service_worker_status != SERVICE_WORKER_OK) { | 
| - SendRegisterError(data, PUSH_REGISTRATION_STATUS_NO_SENDER_ID); | 
| + SendSubscribeError(data, PUSH_SUBSCRIPTION_STATUS_NO_SENDER_ID); | 
| return; | 
| } | 
| BrowserThread::PostTask( | 
| BrowserThread::UI, FROM_HERE, | 
| - base::Bind(&Core::RegisterOnUI, base::Unretained(ui_core_.get()), | 
| + base::Bind(&Core::SubscribeOnUI, base::Unretained(ui_core_.get()), | 
| data, sender_id)); | 
| } | 
| -void PushMessagingMessageFilter::Core::RegisterOnUI( | 
| - const PushMessagingMessageFilter::RegisterData& data, | 
| +void PushMessagingMessageFilter::Core::SubscribeOnUI( | 
| + const PushMessagingMessageFilter::SubscribeData& data, | 
| const std::string& sender_id) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::UI); | 
| PushMessagingService* push_service = service(); | 
| @@ -344,9 +346,9 @@ void PushMessagingMessageFilter::Core::RegisterOnUI( | 
| // TODO(johnme): Might be better not to expose the API in this case. | 
| BrowserThread::PostTask( | 
| BrowserThread::IO, FROM_HERE, | 
| - base::Bind(&PushMessagingMessageFilter::SendRegisterError, | 
| + base::Bind(&PushMessagingMessageFilter::SendSubscribeError, | 
| io_parent_, | 
| - data, PUSH_REGISTRATION_STATUS_SERVICE_NOT_AVAILABLE)); | 
| + data, PUSH_SUBSCRIPTION_STATUS_SERVICE_NOT_AVAILABLE)); | 
| } else { | 
| // Prevent websites from detecting incognito mode, by emulating what would | 
| // have happened if we had a PushMessagingService available. | 
| @@ -354,10 +356,10 @@ void PushMessagingMessageFilter::Core::RegisterOnUI( | 
| // Throw a permission denied error under the same circumstances. | 
| BrowserThread::PostTask( | 
| BrowserThread::IO, FROM_HERE, | 
| - base::Bind(&PushMessagingMessageFilter::SendRegisterError, | 
| + base::Bind(&PushMessagingMessageFilter::SendSubscribeError, | 
| io_parent_, | 
| data, | 
| - PUSH_REGISTRATION_STATUS_INCOGNITO_PERMISSION_DENIED)); | 
| + PUSH_SUBSCRIPTION_STATUS_INCOGNITO_PERMISSION_DENIED)); | 
| } | 
| // Else leave the promise hanging forever, to simulate a user ignoring the | 
| // infobar. TODO(johnme): Simulate the user dismissing the infobar after a | 
| @@ -367,135 +369,137 @@ void PushMessagingMessageFilter::Core::RegisterOnUI( | 
| } | 
| if (data.FromDocument()) { | 
| - push_service->RegisterFromDocument( | 
| + push_service->SubscribeFromDocument( | 
| data.requesting_origin, data.service_worker_registration_id, sender_id, | 
| render_process_id_, data.render_frame_id, data.user_visible, | 
| - base::Bind(&Core::DidRegister, weak_factory_ui_to_ui_.GetWeakPtr(), | 
| + base::Bind(&Core::DidSubscribe, weak_factory_ui_to_ui_.GetWeakPtr(), | 
| data)); | 
| } else { | 
| - push_service->RegisterFromWorker( | 
| + push_service->SubscribeFromWorker( | 
| data.requesting_origin, data.service_worker_registration_id, sender_id, | 
| data.user_visible, | 
| - base::Bind(&Core::DidRegister, weak_factory_ui_to_ui_.GetWeakPtr(), | 
| + base::Bind(&Core::DidSubscribe, weak_factory_ui_to_ui_.GetWeakPtr(), | 
| data)); | 
| } | 
| } | 
| -void PushMessagingMessageFilter::Core::DidRegister( | 
| - const RegisterData& data, | 
| - const std::string& push_registration_id, | 
| - PushRegistrationStatus status) { | 
| +void PushMessagingMessageFilter::Core::DidSubscribe( | 
| + const SubscribeData& data, | 
| + const std::string& push_subscription_id, | 
| + PushSubscriptionStatus status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::UI); | 
| - if (status == PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE) { | 
| + if (status == PUSH_SUBSCRIPTION_STATUS_SUCCESS_FROM_PUSH_SERVICE) { | 
| BrowserThread::PostTask( | 
| BrowserThread::IO, FROM_HERE, | 
| - base::Bind(&PushMessagingMessageFilter::PersistRegistrationOnIO, | 
| - io_parent_, data, push_registration_id)); | 
| + base::Bind(&PushMessagingMessageFilter::PersistSubscriptionOnIO, | 
| + io_parent_, data, push_subscription_id)); | 
| } else { | 
| BrowserThread::PostTask( | 
| BrowserThread::IO, FROM_HERE, | 
| - base::Bind(&PushMessagingMessageFilter::SendRegisterError, io_parent_, | 
| + base::Bind(&PushMessagingMessageFilter::SendSubscribeError, io_parent_, | 
| data, status)); | 
| } | 
| } | 
| -void PushMessagingMessageFilter::PersistRegistrationOnIO( | 
| - const RegisterData& data, | 
| - const std::string& push_registration_id) { | 
| +void PushMessagingMessageFilter::PersistSubscriptionOnIO( | 
| + const SubscribeData& data, | 
| + const std::string& push_subscription_id) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| service_worker_context_->StoreRegistrationUserData( | 
| data.service_worker_registration_id, | 
| data.requesting_origin, | 
| - kPushRegistrationIdServiceWorkerKey, | 
| - push_registration_id, | 
| - base::Bind(&PushMessagingMessageFilter::DidPersistRegistrationOnIO, | 
| + kPushSubscriptionIdServiceWorkerKey, | 
| + push_subscription_id, | 
| + base::Bind(&PushMessagingMessageFilter::DidPersistSubscriptionOnIO, | 
| weak_factory_io_to_io_.GetWeakPtr(), | 
| - data, push_registration_id)); | 
| + data, push_subscription_id)); | 
| } | 
| -void PushMessagingMessageFilter::DidPersistRegistrationOnIO( | 
| - const RegisterData& data, | 
| - const std::string& push_registration_id, | 
| +void PushMessagingMessageFilter::DidPersistSubscriptionOnIO( | 
| + const SubscribeData& data, | 
| + const std::string& push_subscription_id, | 
| ServiceWorkerStatusCode service_worker_status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| if (service_worker_status == SERVICE_WORKER_OK) { | 
| - SendRegisterSuccess(data, | 
| - PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE, | 
| - push_registration_id); | 
| + SendSubscribeSuccess(data, | 
| + PUSH_SUBSCRIPTION_STATUS_SUCCESS_FROM_PUSH_SERVICE, | 
| + push_subscription_id); | 
| } else { | 
| - // TODO(johnme): Unregister, so PushMessagingServiceImpl can decrease count. | 
| - SendRegisterError(data, PUSH_REGISTRATION_STATUS_STORAGE_ERROR); | 
| + // TODO(johnme): Unsubscribe, so PushMessagingServiceImpl can decrease | 
| + // count. | 
| + SendSubscribeError(data, PUSH_SUBSCRIPTION_STATUS_STORAGE_ERROR); | 
| } | 
| } | 
| -void PushMessagingMessageFilter::SendRegisterError( | 
| - const RegisterData& data, PushRegistrationStatus status) { | 
| +void PushMessagingMessageFilter::SendSubscribeError( | 
| + const SubscribeData& data, PushSubscriptionStatus status) { | 
| // Only called from IO thread, but would be safe to call from UI thread. | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| if (data.FromDocument()) { | 
| - Send(new PushMessagingMsg_RegisterFromDocumentError( | 
| + Send(new PushMessagingMsg_SubscribeFromDocumentError( | 
| data.render_frame_id, data.request_id, status)); | 
| } else { | 
| - Send(new PushMessagingMsg_RegisterFromWorkerError( | 
| + Send(new PushMessagingMsg_SubscribeFromWorkerError( | 
| data.request_id, status)); | 
| } | 
| - RecordRegistrationStatus(status); | 
| + RecordSubscriptionStatus(status); | 
| } | 
| -void PushMessagingMessageFilter::SendRegisterSuccess( | 
| - const RegisterData& data, | 
| - PushRegistrationStatus status, | 
| - const std::string& push_registration_id) { | 
| +void PushMessagingMessageFilter::SendSubscribeSuccess( | 
| + const SubscribeData& data, | 
| + PushSubscriptionStatus status, | 
| + const std::string& push_subscription_id) { | 
| // Only called from IO thread, but would be safe to call from UI thread. | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| if (push_endpoint_.is_empty()) { | 
| // This shouldn't be possible in incognito mode, since we've already checked | 
| - // that we have an existing registration. Hence it's ok to throw an error. | 
| + // that we have an existing subscription. Hence it's ok to throw an error. | 
| DCHECK(!ui_core_->is_incognito()); | 
| - SendRegisterError(data, PUSH_REGISTRATION_STATUS_SERVICE_NOT_AVAILABLE); | 
| + SendSubscribeError(data, PUSH_SUBSCRIPTION_STATUS_SERVICE_NOT_AVAILABLE); | 
| return; | 
| } | 
| if (data.FromDocument()) { | 
| - Send(new PushMessagingMsg_RegisterFromDocumentSuccess( | 
| + Send(new PushMessagingMsg_SubscribeFromDocumentSuccess( | 
| data.render_frame_id, | 
| - data.request_id, push_endpoint_, push_registration_id)); | 
| + data.request_id, push_endpoint_, push_subscription_id)); | 
| } else { | 
| - Send(new PushMessagingMsg_RegisterFromWorkerSuccess( | 
| - data.request_id, push_endpoint_, push_registration_id)); | 
| + Send(new PushMessagingMsg_SubscribeFromWorkerSuccess( | 
| + data.request_id, push_endpoint_, push_subscription_id)); | 
| } | 
| - RecordRegistrationStatus(status); | 
| + RecordSubscriptionStatus(status); | 
| } | 
| -// Unregister methods on both IO and UI threads, merged in order of use from | 
| +// Unsubscribe methods on both IO and UI threads, merged in order of use from | 
| // PushMessagingMessageFilter and Core. | 
| // ----------------------------------------------------------------------------- | 
| -void PushMessagingMessageFilter::OnUnregister( | 
| +void PushMessagingMessageFilter::OnUnsubscribe( | 
| int request_id, int64_t service_worker_registration_id) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| ServiceWorkerRegistration* service_worker_registration = | 
| service_worker_context_->GetLiveRegistration( | 
| service_worker_registration_id); | 
| if (!service_worker_registration) { | 
| - DidUnregister(request_id, PUSH_UNREGISTRATION_STATUS_NO_SERVICE_WORKER); | 
| + DidUnsubscribe(request_id, PUSH_UNSUBSCRIPTION_STATUS_NO_SERVICE_WORKER); | 
| return; | 
| } | 
| service_worker_context_->GetRegistrationUserData( | 
| service_worker_registration_id, | 
| - kPushRegistrationIdServiceWorkerKey, | 
| + kPushSubscriptionIdServiceWorkerKey, | 
| base::Bind( | 
| - &PushMessagingMessageFilter::UnregisterHavingGottenPushRegistrationId, | 
| + &PushMessagingMessageFilter | 
| + ::UnsubscribeHavingGottenPushSubscriptionId, | 
| weak_factory_io_to_io_.GetWeakPtr(), request_id, | 
| service_worker_registration_id, | 
| service_worker_registration->pattern().GetOrigin())); | 
| } | 
| -void PushMessagingMessageFilter::UnregisterHavingGottenPushRegistrationId( | 
| +void PushMessagingMessageFilter::UnsubscribeHavingGottenPushSubscriptionId( | 
| int request_id, | 
| int64_t service_worker_registration_id, | 
| const GURL& requesting_origin, | 
| - const std::string& push_registration_id, // Unused, we just want the status | 
| + const std::string& push_subscription_id, // Unused, we just want the status | 
| ServiceWorkerStatusCode service_worker_status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| @@ -504,22 +508,22 @@ void PushMessagingMessageFilter::UnregisterHavingGottenPushRegistrationId( | 
| service_worker_registration_id, | 
| kPushSenderIdServiceWorkerKey, | 
| base::Bind( | 
| - &PushMessagingMessageFilter::UnregisterHavingGottenSenderId, | 
| + &PushMessagingMessageFilter::UnsubscribeHavingGottenSenderId, | 
| 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, | 
| - std::string() /* sender_id */, | 
| - service_worker_status); | 
| + // push_subscription_id or the sender_id. | 
| + UnsubscribeHavingGottenSenderId(request_id, service_worker_registration_id, | 
| + requesting_origin, | 
| + std::string() /* sender_id */, | 
| + service_worker_status); | 
| } | 
| } | 
| -void PushMessagingMessageFilter::UnregisterHavingGottenSenderId( | 
| +void PushMessagingMessageFilter::UnsubscribeHavingGottenSenderId( | 
| int request_id, | 
| int64_t service_worker_registration_id, | 
| const GURL& requesting_origin, | 
| @@ -531,20 +535,20 @@ void PushMessagingMessageFilter::UnregisterHavingGottenSenderId( | 
| case SERVICE_WORKER_OK: | 
| BrowserThread::PostTask( | 
| BrowserThread::UI, FROM_HERE, | 
| - base::Bind(&Core::UnregisterFromService, | 
| + base::Bind(&Core::UnsubscribeFromService, | 
| base::Unretained(ui_core_.get()), request_id, | 
| service_worker_registration_id, requesting_origin, | 
| sender_id)); | 
| break; | 
| case SERVICE_WORKER_ERROR_NOT_FOUND: | 
| - // We did not find a registration, stop here and notify the renderer that | 
| - // it was a success even though we did not unregister. | 
| - DidUnregister(request_id, | 
| - PUSH_UNREGISTRATION_STATUS_SUCCESS_WAS_NOT_REGISTERED); | 
| + // We did not find a subscription, stop here and notify the renderer that | 
| + // it was a success even though we did not unsubscribe. | 
| + DidUnsubscribe(request_id, | 
| + PUSH_UNSUBSCRIPTION_STATUS_SUCCESS_WAS_NOT_SUBSCRIBED); | 
| break; | 
| case SERVICE_WORKER_ERROR_FAILED: | 
| - DidUnregister(request_id, | 
| - PUSH_UNREGISTRATION_STATUS_STORAGE_ERROR); | 
| + DidUnsubscribe(request_id, | 
| + PUSH_UNSUBSCRIPTION_STATUS_STORAGE_ERROR); | 
| break; | 
| case SERVICE_WORKER_ERROR_ABORT: | 
| case SERVICE_WORKER_ERROR_START_WORKER_FAILED: | 
| @@ -563,12 +567,12 @@ void PushMessagingMessageFilter::UnregisterHavingGottenSenderId( | 
| case SERVICE_WORKER_ERROR_MAX_VALUE: | 
| NOTREACHED() << "Got unexpected error code: " << service_worker_status | 
| << " " << ServiceWorkerStatusToString(service_worker_status); | 
| - DidUnregister(request_id, PUSH_UNREGISTRATION_STATUS_STORAGE_ERROR); | 
| + DidUnsubscribe(request_id, PUSH_UNSUBSCRIPTION_STATUS_STORAGE_ERROR); | 
| break; | 
| } | 
| } | 
| -void PushMessagingMessageFilter::Core::UnregisterFromService( | 
| +void PushMessagingMessageFilter::Core::UnsubscribeFromService( | 
| int request_id, | 
| int64_t service_worker_registration_id, | 
| const GURL& requesting_origin, | 
| @@ -577,150 +581,150 @@ void PushMessagingMessageFilter::Core::UnregisterFromService( | 
| PushMessagingService* push_service = service(); | 
| if (!push_service) { | 
| // This shouldn't be possible in incognito mode, since we've already checked | 
| - // that we have an existing registration. Hence it's ok to throw an error. | 
| + // that we have an existing subscription. Hence it's ok to throw an error. | 
| DCHECK(!is_incognito()); | 
| BrowserThread::PostTask( | 
| BrowserThread::IO, FROM_HERE, | 
| - base::Bind(&PushMessagingMessageFilter::DidUnregister, io_parent_, | 
| + base::Bind(&PushMessagingMessageFilter::DidUnsubscribe, io_parent_, | 
| request_id, | 
| - PUSH_UNREGISTRATION_STATUS_SERVICE_NOT_AVAILABLE)); | 
| + PUSH_UNSUBSCRIPTION_STATUS_SERVICE_NOT_AVAILABLE)); | 
| return; | 
| } | 
| - push_service->Unregister( | 
| + push_service->Unsubscribe( | 
| requesting_origin, service_worker_registration_id, sender_id, | 
| - base::Bind(&Core::DidUnregisterFromService, | 
| + base::Bind(&Core::DidUnsubscribeFromService, | 
| weak_factory_ui_to_ui_.GetWeakPtr(), | 
| request_id, service_worker_registration_id)); | 
| } | 
| -void PushMessagingMessageFilter::Core::DidUnregisterFromService( | 
| +void PushMessagingMessageFilter::Core::DidUnsubscribeFromService( | 
| int request_id, | 
| int64_t service_worker_registration_id, | 
| - PushUnregistrationStatus unregistration_status) { | 
| + PushUnsubscriptionStatus unsubscription_status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::UI); | 
| - switch (unregistration_status) { | 
| - case PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED: | 
| - case PUSH_UNREGISTRATION_STATUS_SUCCESS_WAS_NOT_REGISTERED: | 
| - case PUSH_UNREGISTRATION_STATUS_PENDING_NETWORK_ERROR: | 
| - case PUSH_UNREGISTRATION_STATUS_PENDING_SERVICE_ERROR: | 
| + switch (unsubscription_status) { | 
| + case PUSH_UNSUBSCRIPTION_STATUS_SUCCESS_UNSUBSCRIBED: | 
| + case PUSH_UNSUBSCRIPTION_STATUS_SUCCESS_WAS_NOT_SUBSCRIBED: | 
| + case PUSH_UNSUBSCRIPTION_STATUS_PENDING_NETWORK_ERROR: | 
| + case PUSH_UNSUBSCRIPTION_STATUS_PENDING_SERVICE_ERROR: | 
| BrowserThread::PostTask( | 
| BrowserThread::IO, FROM_HERE, | 
| - base::Bind(&PushMessagingMessageFilter::ClearRegistrationData, | 
| + base::Bind(&PushMessagingMessageFilter::ClearSubscriptionData, | 
| io_parent_, request_id, service_worker_registration_id, | 
| - unregistration_status)); | 
| + unsubscription_status)); | 
| break; | 
| - case PUSH_UNREGISTRATION_STATUS_NO_SERVICE_WORKER: | 
| - case PUSH_UNREGISTRATION_STATUS_SERVICE_NOT_AVAILABLE: | 
| - case PUSH_UNREGISTRATION_STATUS_STORAGE_ERROR: | 
| - case PUSH_UNREGISTRATION_STATUS_NETWORK_ERROR: | 
| + case PUSH_UNSUBSCRIPTION_STATUS_NO_SERVICE_WORKER: | 
| + case PUSH_UNSUBSCRIPTION_STATUS_SERVICE_NOT_AVAILABLE: | 
| + case PUSH_UNSUBSCRIPTION_STATUS_STORAGE_ERROR: | 
| + case PUSH_UNSUBSCRIPTION_STATUS_NETWORK_ERROR: | 
| NOTREACHED(); | 
| break; | 
| } | 
| } | 
| -void PushMessagingMessageFilter::ClearRegistrationData( | 
| +void PushMessagingMessageFilter::ClearSubscriptionData( | 
| int request_id, | 
| int64_t service_worker_registration_id, | 
| - PushUnregistrationStatus unregistration_status) { | 
| + PushUnsubscriptionStatus unsubscription_status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| service_worker_context_->ClearRegistrationUserData( | 
| service_worker_registration_id, | 
| - kPushRegistrationIdServiceWorkerKey, | 
| - base::Bind(&PushMessagingMessageFilter::DidClearRegistrationData, | 
| + kPushSubscriptionIdServiceWorkerKey, | 
| + base::Bind(&PushMessagingMessageFilter::DidClearSubscriptionData, | 
| weak_factory_io_to_io_.GetWeakPtr(), | 
| - request_id, unregistration_status)); | 
| + request_id, unsubscription_status)); | 
| } | 
| -void PushMessagingMessageFilter::DidClearRegistrationData( | 
| +void PushMessagingMessageFilter::DidClearSubscriptionData( | 
| int request_id, | 
| - PushUnregistrationStatus unregistration_status, | 
| + PushUnsubscriptionStatus unsubscription_status, | 
| ServiceWorkerStatusCode service_worker_status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| if (service_worker_status != SERVICE_WORKER_OK && | 
| service_worker_status != SERVICE_WORKER_ERROR_NOT_FOUND) { | 
| - unregistration_status = PUSH_UNREGISTRATION_STATUS_STORAGE_ERROR; | 
| + unsubscription_status = PUSH_UNSUBSCRIPTION_STATUS_STORAGE_ERROR; | 
| DLOG(WARNING) << "Got unexpected error code: " << service_worker_status | 
| << " " << ServiceWorkerStatusToString(service_worker_status); | 
| } | 
| - DidUnregister(request_id, unregistration_status); | 
| + DidUnsubscribe(request_id, unsubscription_status); | 
| } | 
| -void PushMessagingMessageFilter::DidUnregister( | 
| +void PushMessagingMessageFilter::DidUnsubscribe( | 
| int request_id, | 
| - PushUnregistrationStatus unregistration_status) { | 
| + PushUnsubscriptionStatus unsubscription_status) { | 
| // Only called from IO thread, but would be safe to call from UI thread. | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| - switch (unregistration_status) { | 
| - case PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED: | 
| - case PUSH_UNREGISTRATION_STATUS_PENDING_NETWORK_ERROR: | 
| - case PUSH_UNREGISTRATION_STATUS_PENDING_SERVICE_ERROR: | 
| - Send(new PushMessagingMsg_UnregisterSuccess(request_id, true)); | 
| + switch (unsubscription_status) { | 
| + case PUSH_UNSUBSCRIPTION_STATUS_SUCCESS_UNSUBSCRIBED: | 
| + case PUSH_UNSUBSCRIPTION_STATUS_PENDING_NETWORK_ERROR: | 
| + case PUSH_UNSUBSCRIPTION_STATUS_PENDING_SERVICE_ERROR: | 
| + Send(new PushMessagingMsg_UnsubscribeSuccess(request_id, true)); | 
| break; | 
| - case PUSH_UNREGISTRATION_STATUS_SUCCESS_WAS_NOT_REGISTERED: | 
| - Send(new PushMessagingMsg_UnregisterSuccess(request_id, false)); | 
| + case PUSH_UNSUBSCRIPTION_STATUS_SUCCESS_WAS_NOT_SUBSCRIBED: | 
| + Send(new PushMessagingMsg_UnsubscribeSuccess(request_id, false)); | 
| break; | 
| - case PUSH_UNREGISTRATION_STATUS_NO_SERVICE_WORKER: | 
| - case PUSH_UNREGISTRATION_STATUS_SERVICE_NOT_AVAILABLE: | 
| - case PUSH_UNREGISTRATION_STATUS_STORAGE_ERROR: | 
| - Send(new PushMessagingMsg_UnregisterError( | 
| + case PUSH_UNSUBSCRIPTION_STATUS_NO_SERVICE_WORKER: | 
| + case PUSH_UNSUBSCRIPTION_STATUS_SERVICE_NOT_AVAILABLE: | 
| + case PUSH_UNSUBSCRIPTION_STATUS_STORAGE_ERROR: | 
| + Send(new PushMessagingMsg_UnsubscribeError( | 
| request_id, blink::WebPushError::ErrorTypeAbort, | 
| - PushUnregistrationStatusToString(unregistration_status))); | 
| + PushUnsubscriptionStatusToString(unsubscription_status))); | 
| break; | 
| - case PUSH_UNREGISTRATION_STATUS_NETWORK_ERROR: | 
| + case PUSH_UNSUBSCRIPTION_STATUS_NETWORK_ERROR: | 
| NOTREACHED(); | 
| break; | 
| } | 
| - RecordUnregistrationStatus(unregistration_status); | 
| + RecordUnsubscriptionStatus(unsubscription_status); | 
| } | 
| -// GetRegistration methods on both IO and UI threads, merged in order of use | 
| +// GetSubscription methods on both IO and UI threads, merged in order of use | 
| // from PushMessagingMessageFilter and Core. | 
| // ----------------------------------------------------------------------------- | 
| -void PushMessagingMessageFilter::OnGetRegistration( | 
| +void PushMessagingMessageFilter::OnGetSubscription( | 
| int request_id, | 
| int64_t service_worker_registration_id) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| // TODO(johnme): Validate arguments? | 
| service_worker_context_->GetRegistrationUserData( | 
| service_worker_registration_id, | 
| - kPushRegistrationIdServiceWorkerKey, | 
| - base::Bind(&PushMessagingMessageFilter::DidGetRegistration, | 
| + kPushSubscriptionIdServiceWorkerKey, | 
| + base::Bind(&PushMessagingMessageFilter::DidGetSubscription, | 
| weak_factory_io_to_io_.GetWeakPtr(), request_id)); | 
| } | 
| -void PushMessagingMessageFilter::DidGetRegistration( | 
| +void PushMessagingMessageFilter::DidGetSubscription( | 
| int request_id, | 
| - const std::string& push_registration_id, | 
| + const std::string& push_subscription_id, | 
| ServiceWorkerStatusCode service_worker_status) { | 
| DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| - PushGetRegistrationStatus get_status = | 
| - PUSH_GETREGISTRATION_STATUS_STORAGE_ERROR; | 
| + PushGetSubscriptionStatus get_status = | 
| + PUSH_GETSUBSCRIPTION_STATUS_STORAGE_ERROR; | 
| switch (service_worker_status) { | 
| case SERVICE_WORKER_OK: | 
| if (push_endpoint_.is_empty()) { | 
| // Return not found in incognito mode, so websites can't detect it. | 
| get_status = | 
| ui_core_->is_incognito() | 
| - ? PUSH_GETREGISTRATION_STATUS_INCOGNITO_REGISTRATION_NOT_FOUND | 
| - : PUSH_GETREGISTRATION_STATUS_SERVICE_NOT_AVAILABLE; | 
| + ? PUSH_GETSUBSCRIPTION_STATUS_INCOGNITO_SUBSCRIPTION_NOT_FOUND | 
| + : PUSH_GETSUBSCRIPTION_STATUS_SERVICE_NOT_AVAILABLE; | 
| break; | 
| } | 
| - Send(new PushMessagingMsg_GetRegistrationSuccess(request_id, | 
| + Send(new PushMessagingMsg_GetSubscriptionSuccess(request_id, | 
| push_endpoint_, | 
| - push_registration_id)); | 
| - RecordGetRegistrationStatus(PUSH_GETREGISTRATION_STATUS_SUCCESS); | 
| + push_subscription_id)); | 
| + RecordGetSubscriptionStatus(PUSH_GETSUBSCRIPTION_STATUS_SUCCESS); | 
| return; | 
| case SERVICE_WORKER_ERROR_NOT_FOUND: | 
| - get_status = PUSH_GETREGISTRATION_STATUS_REGISTRATION_NOT_FOUND; | 
| + get_status = PUSH_GETSUBSCRIPTION_STATUS_SUBSCRIPTION_NOT_FOUND; | 
| break; | 
| case SERVICE_WORKER_ERROR_FAILED: | 
| - get_status = PUSH_GETREGISTRATION_STATUS_STORAGE_ERROR; | 
| + get_status = PUSH_GETSUBSCRIPTION_STATUS_STORAGE_ERROR; | 
| break; | 
| case SERVICE_WORKER_ERROR_ABORT: | 
| case SERVICE_WORKER_ERROR_START_WORKER_FAILED: | 
| @@ -739,11 +743,11 @@ void PushMessagingMessageFilter::DidGetRegistration( | 
| case SERVICE_WORKER_ERROR_MAX_VALUE: | 
| NOTREACHED() << "Got unexpected error code: " << service_worker_status | 
| << " " << ServiceWorkerStatusToString(service_worker_status); | 
| - get_status = PUSH_GETREGISTRATION_STATUS_STORAGE_ERROR; | 
| + get_status = PUSH_GETSUBSCRIPTION_STATUS_STORAGE_ERROR; | 
| break; | 
| } | 
| - Send(new PushMessagingMsg_GetRegistrationError(request_id, get_status)); | 
| - RecordGetRegistrationStatus(get_status); | 
| + Send(new PushMessagingMsg_GetSubscriptionError(request_id, get_status)); | 
| + RecordGetSubscriptionStatus(get_status); | 
| } | 
| // GetPermission methods on both IO and UI threads, merged in order of use from |