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

Unified Diff: content/shell/browser/layout_test/layout_test_push_messaging_service.cc

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: content/shell/browser/layout_test/layout_test_push_messaging_service.cc
diff --git a/content/shell/browser/layout_test/layout_test_push_messaging_service.cc b/content/shell/browser/layout_test/layout_test_push_messaging_service.cc
index 59d298fc24c8572ac7a033aad0510536f3195bf0..d4f709d7fe7f2de30d9c115552e7b0b60fd2dbbb 100644
--- a/content/shell/browser/layout_test/layout_test_push_messaging_service.cc
+++ b/content/shell/browser/layout_test/layout_test_push_messaging_service.cc
@@ -89,6 +89,7 @@ void LayoutTestPushMessagingService::SubscribeFromWorker(
std::vector<uint8_t> auth(
kAuthentication, kAuthentication + arraysize(kAuthentication));
+ is_subscribed_ = true;
callback.Run("layoutTestRegistrationId", p256dh, auth,
PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE);
} else {
@@ -129,7 +130,14 @@ void LayoutTestPushMessagingService::Unsubscribe(
int64_t service_worker_registration_id,
const std::string& sender_id,
const UnregisterCallback& callback) {
- callback.Run(PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED);
+ ClearPushSubscriptionId(
+ LayoutTestContentBrowserClient::Get()->browser_context(),
+ requesting_origin, service_worker_registration_id,
+ base::Bind(callback,
+ is_subscribed_
+ ? PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED
+ : PUSH_UNREGISTRATION_STATUS_SUCCESS_WAS_NOT_REGISTERED));
+ is_subscribed_ = false;
}
} // namespace content
« no previous file with comments | « content/shell/browser/layout_test/layout_test_push_messaging_service.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698