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

Issue 2387483002: Push API: Refactor and fix unsubscribe API (Closed)

Created:
4 years, 2 months ago by johnme
Modified:
4 years, 2 months ago
CC:
chromium-reviews, mlamouri+watch-content_chromium.org, mlamouri+watch-test-runner_chromium.org, zea+watch_chromium.org, Peter Beverloo, johnme+watch_chromium.org, jam, darin-cc_chromium.org, asvitkine+watch_chromium.org, einbinder+watch-test-runner_chromium.org, harkness+watch_chromium.org, jochen+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Push API: Refactor and fix unsubscribe API Before this patch, 4 high-level codepaths for unsubscribe had evolved: a) JS-initiated unsubscribe where PushMessagingMessageFilter's UnsubscribeHavingGottenIds would skip talking to the PushMessagingServiceImpl because it could not find the subscription in the Service Worker database. b) JS-initiated unsubscribe where PushMessagingMessageFilter did talk to the PushMessagingServiceImpl, then directly removed the subscription from the Service Worker database in PushMessagingMessageFilter's Core::DidUnregisterFromService. c) Automatic unsubscribe after revoked permission where PushMessagingServiceImpl::UnsubscribeBecausePermissionRevoked would call PushMessagingService::ClearPushSubscriptionID to ask the content layer to remove the subscription from the Service Worker database. d) Automatic unsubscribe after bad incoming messages where PushMessagingServiceImpl would never remove the subscription from the Service Worker database. This patch unifies them, such that all unsubscription requests go via PushMessagingServiceImpl::UnsubscribeInternal, and this method is now responsible for calling PushMessagingService::ClearPushSubscriptionID in all cases to remove the subscription from the Service Worker database. - Eliminating (d) fixes the PUSH_DELIVERY_STATUS_PERMISSION_DENIED case, where previously we would automatically unsubscribe but never remove the corresponding subscription from the Service Worker database (this situation occurs for users that had been hit by crbug.com/633310). - Eliminating (a) makes us more robust against any cases where a subscription had been removed from the Service Worker database but not from the PushMessagingAppIdentifier map (e.g. due to race conditions where processes are killed partway through writing state to disk). - This adds UMA logging for the reason that caused unsubscription. This will be useful in tracking down https://crbug.com/642139 - This adds tests for each of the reasons that can trigger automatic unsubscription. Previously many of these had no coverage. - This fixes PushMessagingBrowserTest.UnsubscribeSuccess and LegacyUnsubscribeSuccess which were failing to test what they intended to test (instead of calling unsubscribe on old references to unsubscribed PushSubscriptions and PushSubscriptions from unregistered Service Workers, they were trying and failing to get a fresh reference, and considering that failure to mean that unsubscribe had succeeded); and I added a test where the Service Worker is replaced, since unregistering a Service Worker isn't actually enough to stop it controlling the current page. - This merges the DidUnsubscribeInstanceID and DidUnsubscribe methods in PushMessagingServiceImpl to avoid duplication of logic. BUG=646426, 642139, 633310 NOTRY=true (remaining trybot failures are flake) Committed: https://crrev.com/92ef94f69eb941d144e31f6cac45c6e3ce8a8720 Cr-Commit-Position: refs/heads/master@{#422330}

Patch Set 1 #

Total comments: 24

Patch Set 2 : Address peter's review comments #

Total comments: 4

Patch Set 3 : Added enum reuse comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+610 lines, -329 lines) Patch
M chrome/browser/push_messaging/push_messaging_browsertest.cc View 1 21 chunks +228 lines, -35 lines 0 comments Download
M chrome/browser/push_messaging/push_messaging_service_impl.h View 1 2 chunks +59 lines, -62 lines 0 comments Download
M chrome/browser/push_messaging/push_messaging_service_impl.cc View 1 17 chunks +172 lines, -106 lines 0 comments Download
M chrome/test/data/push_messaging/push_test.js View 1 3 chunks +50 lines, -1 line 0 comments Download
A + chrome/test/data/push_messaging/service_worker_with_skipWaiting_claim.js View 1 chunk +2 lines, -6 lines 0 comments Download
M components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h View 1 chunk +4 lines, -1 line 0 comments Download
M components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.cc View 1 chunk +3 lines, -0 lines 0 comments Download
M content/browser/push_messaging/push_messaging_message_filter.h View 1 chunk +2 lines, -11 lines 0 comments Download
M content/browser/push_messaging/push_messaging_message_filter.cc View 2 chunks +17 lines, -95 lines 0 comments Download
M content/public/browser/push_messaging_service.h View 1 chunk +1 line, -1 line 0 comments Download
M content/public/browser/push_messaging_service.cc View 2 chunks +5 lines, -7 lines 0 comments Download
M content/public/common/push_messaging_status.h View 1 2 5 chunks +36 lines, -1 line 0 comments Download
M content/shell/browser/layout_test/layout_test_push_messaging_service.h View 1 chunk +2 lines, -0 lines 0 comments Download
M content/shell/browser/layout_test/layout_test_push_messaging_service.cc View 2 chunks +9 lines, -1 line 0 comments Download
M tools/metrics/histograms/histograms.xml View 1 3 chunks +20 lines, -2 lines 0 comments Download

Messages

Total messages: 32 (19 generated)
johnme
4 years, 2 months ago (2016-09-29 21:30:00 UTC) #2
Peter Beverloo
This is a great patch John, thank you!! LGTM https://codereview.chromium.org/2387483002/diff/1/chrome/browser/push_messaging/push_messaging_browsertest.cc File chrome/browser/push_messaging/push_messaging_browsertest.cc (right): https://codereview.chromium.org/2387483002/diff/1/chrome/browser/push_messaging/push_messaging_browsertest.cc#newcode806 chrome/browser/push_messaging/push_messaging_browsertest.cc:806: ...
4 years, 2 months ago (2016-09-30 14:26:07 UTC) #7
johnme
Addressed review comments - thanks! https://codereview.chromium.org/2387483002/diff/1/chrome/browser/push_messaging/push_messaging_browsertest.cc File chrome/browser/push_messaging/push_messaging_browsertest.cc (right): https://codereview.chromium.org/2387483002/diff/1/chrome/browser/push_messaging/push_messaging_browsertest.cc#newcode806 chrome/browser/push_messaging/push_messaging_browsertest.cc:806: // that isn't yet ...
4 years, 2 months ago (2016-09-30 17:02:10 UTC) #8
johnme
avi: please review content/public/ mpearson: please review histograms.xml Thanks!
4 years, 2 months ago (2016-09-30 17:06:23 UTC) #12
Avi (use Gerrit)
LGTM! Nice.
4 years, 2 months ago (2016-09-30 17:19:26 UTC) #13
Mark P
histograms.xml lgtm once you revise per comment #1 and assuming comment #2's answer is "just ...
4 years, 2 months ago (2016-09-30 22:39:04 UTC) #16
johnme
Added warning comments about renumbering/reusing deleted enum values - thanks :) https://codereview.chromium.org/2387483002/diff/20001/content/public/common/push_messaging_status.h File content/public/common/push_messaging_status.h (right): ...
4 years, 2 months ago (2016-09-30 23:10:41 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2387483002/40001
4 years, 2 months ago (2016-09-30 23:11:09 UTC) #20
commit-bot: I haz the power
Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_ng/builds/303348)
4 years, 2 months ago (2016-10-01 01:07:28 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2387483002/40001
4 years, 2 months ago (2016-10-01 21:12:31 UTC) #24
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2387483002/40001
4 years, 2 months ago (2016-10-01 21:19:31 UTC) #28
commit-bot: I haz the power
Committed patchset #3 (id:40001)
4 years, 2 months ago (2016-10-01 21:25:10 UTC) #30
commit-bot: I haz the power
4 years, 2 months ago (2016-10-01 21:26:56 UTC) #32
Message was sent while issue was closed.
Patchset 3 (id:??) landed as
https://crrev.com/92ef94f69eb941d144e31f6cac45c6e3ce8a8720
Cr-Commit-Position: refs/heads/master@{#422330}

Powered by Google App Engine
This is Rietveld 408576698