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

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

Issue 2387483002: Push API: Refactor and fix unsubscribe API (Closed)
Patch Set: Added enum reuse comments Created 4 years, 3 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
Index: chrome/browser/push_messaging/push_messaging_service_impl.h
diff --git a/chrome/browser/push_messaging/push_messaging_service_impl.h b/chrome/browser/push_messaging/push_messaging_service_impl.h
index 1203d68b86a40279ee3a6a21837ae6d6cc42cc3e..05a2f19a75ab769dc6b7a1619e4e993e0ba5cdf1 100644
--- a/chrome/browser/push_messaging/push_messaging_service_impl.h
+++ b/chrome/browser/push_messaging/push_messaging_service_impl.h
@@ -78,29 +78,24 @@ class PushMessagingServiceImpl : public content::PushMessagingService,
// content::PushMessagingService implementation:
GURL GetEndpoint(bool standard_protocol) const override;
- void SubscribeFromDocument(
- const GURL& requesting_origin,
- int64_t service_worker_registration_id,
- int renderer_id,
- int render_frame_id,
- const content::PushSubscriptionOptions& options,
- const content::PushMessagingService::RegisterCallback& callback) override;
- void SubscribeFromWorker(
- const GURL& requesting_origin,
- int64_t service_worker_registration_id,
- const content::PushSubscriptionOptions& options,
- const content::PushMessagingService::RegisterCallback& callback) override;
- void GetEncryptionInfo(
- const GURL& origin,
- int64_t service_worker_registration_id,
- const std::string& sender_id,
- const content::PushMessagingService::EncryptionInfoCallback& callback)
- override;
- void Unsubscribe(
- const GURL& requesting_origin,
- int64_t service_worker_registration_id,
- const std::string& sender_id,
- const content::PushMessagingService::UnregisterCallback&) override;
+ void SubscribeFromDocument(const GURL& requesting_origin,
+ int64_t service_worker_registration_id,
+ int renderer_id,
+ int render_frame_id,
+ const content::PushSubscriptionOptions& options,
+ const RegisterCallback& callback) override;
+ void SubscribeFromWorker(const GURL& requesting_origin,
+ int64_t service_worker_registration_id,
+ const content::PushSubscriptionOptions& options,
+ const RegisterCallback& callback) override;
+ void GetEncryptionInfo(const GURL& origin,
+ int64_t service_worker_registration_id,
+ const std::string& sender_id,
+ const EncryptionInfoCallback& callback) override;
+ void Unsubscribe(const GURL& requesting_origin,
+ int64_t service_worker_registration_id,
+ const std::string& sender_id,
+ const UnregisterCallback&) override;
blink::WebPushPermissionStatus GetPermissionStatus(
const GURL& origin,
bool user_visible) override;
@@ -147,70 +142,72 @@ class PushMessagingServiceImpl : public content::PushMessagingService,
// Subscribe methods ---------------------------------------------------------
- void DoSubscribe(
- const PushMessagingAppIdentifier& app_identifier,
- const content::PushSubscriptionOptions& options,
- const content::PushMessagingService::RegisterCallback& callback,
- blink::mojom::PermissionStatus permission_status);
+ void DoSubscribe(const PushMessagingAppIdentifier& app_identifier,
+ const content::PushSubscriptionOptions& options,
+ const RegisterCallback& callback,
+ blink::mojom::PermissionStatus permission_status);
- void SubscribeEnd(
- const content::PushMessagingService::RegisterCallback& callback,
- const std::string& subscription_id,
- const std::vector<uint8_t>& p256dh,
- const std::vector<uint8_t>& auth,
- content::PushRegistrationStatus status);
+ void SubscribeEnd(const RegisterCallback& callback,
+ const std::string& subscription_id,
+ const std::vector<uint8_t>& p256dh,
+ const std::vector<uint8_t>& auth,
+ content::PushRegistrationStatus status);
- void SubscribeEndWithError(
- const content::PushMessagingService::RegisterCallback& callback,
- content::PushRegistrationStatus status);
+ void SubscribeEndWithError(const RegisterCallback& callback,
+ content::PushRegistrationStatus status);
- void DidSubscribe(
- const PushMessagingAppIdentifier& app_identifier,
- const std::string& sender_id,
- const content::PushMessagingService::RegisterCallback& callback,
- const std::string& subscription_id,
- instance_id::InstanceID::Result result);
+ void DidSubscribe(const PushMessagingAppIdentifier& app_identifier,
+ const std::string& sender_id,
+ const RegisterCallback& callback,
+ const std::string& subscription_id,
+ instance_id::InstanceID::Result result);
void DidSubscribeWithEncryptionInfo(
const PushMessagingAppIdentifier& app_identifier,
- const content::PushMessagingService::RegisterCallback& callback,
+ const RegisterCallback& callback,
const std::string& subscription_id,
const std::string& p256dh,
const std::string& auth_secret);
// GetEncryptionInfo method --------------------------------------------------
- void DidGetEncryptionInfo(
- const PushMessagingService::EncryptionInfoCallback& callback,
- const std::string& p256dh,
- const std::string& auth_secret) const;
+ void DidGetEncryptionInfo(const EncryptionInfoCallback& callback,
+ const std::string& p256dh,
+ const std::string& auth_secret) const;
// Unsubscribe methods -------------------------------------------------------
- void Unsubscribe(const std::string& app_id,
- const std::string& sender_id,
- const content::PushMessagingService::UnregisterCallback&);
+ // |origin|, |service_worker_registration_id| and |app_id| should be provided
+ // whenever they can be obtained. It's valid for |origin| to be empty and
+ // |service_worker_registration_id| to be kInvalidServiceWorkerRegistrationId,
+ // or for app_id to be empty, but not both at once.
+ void UnsubscribeInternal(content::PushUnregistrationReason reason,
+ const GURL& origin,
+ int64_t service_worker_registration_id,
+ const std::string& app_id,
+ const std::string& sender_id,
+ const UnregisterCallback& callback);
+
+ void DidClearPushSubscriptionId(content::PushUnregistrationReason reason,
+ const std::string& app_id,
+ const std::string& sender_id,
+ const UnregisterCallback& callback);
void DidDeleteID(const std::string& app_id,
bool was_subscribed,
- const content::PushMessagingService::UnregisterCallback&,
+ const UnregisterCallback&,
instance_id::InstanceID::Result result);
- void DidUnsubscribeInstanceID(
- const std::string& app_id,
- bool was_subscribed,
- const content::PushMessagingService::UnregisterCallback&,
- instance_id::InstanceID::Result result);
-
- void DidUnsubscribe(bool was_subscribed,
- const content::PushMessagingService::UnregisterCallback&,
- gcm::GCMClient::Result result);
+ void DidUnsubscribe(const std::string& app_id_when_instance_id,
+ bool was_subscribed,
+ const UnregisterCallback& callback,
+ content::PushUnregistrationStatus status);
// OnContentSettingChanged methods -------------------------------------------
void UnsubscribeBecausePermissionRevoked(
const PushMessagingAppIdentifier& app_identifier,
- const base::Closure& closure,
+ const UnregisterCallback& callback,
const std::string& sender_id,
bool success,
bool not_found);

Powered by Google App Engine
This is Rietveld 408576698