Push API: Grace - allow one in ten pushes to show no notification.
commit8b5b00d6cc8f02139c1d15209612ab4126de5add
authorjohnme <johnme@chromium.org>
Thu, 5 Feb 2015 19:16:20 +0000 (5 11:16 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 5 Feb 2015 19:18:11 +0000 (5 19:18 +0000)
treeebdf8d50ea280e8cce95d5457718a51e83e485e3
parentfa5c5a845244858359e137057118aead3faf324c
Push API: Grace - allow one in ten pushes to show no notification.

For developers who have opted in to showing a user-visible UI change on
every push (in exchange for showing the user a less scary permission
prompt), we currently[1] enforce that each push shows a notification.

This patch allows one in ten pushes to show no notification, so
occasional bugs in developer push handlers don't needlessly spam the
user.

Specifically, it keeps track of whether the last (up to) 10 push
messages showed a notification (ignoring pushes didn't show a
notification but were exempt, e.g. due to https://crrev.com/866443003)
and only shows a forced notification if one of those (up to) 10 also
failed to show a notification.

[1]: (since https://crrev.com/842233003)

BUG=437277

Review URL: https://codereview.chromium.org/883743002

Cr-Commit-Position: refs/heads/master@{#314851}
chrome/browser/services/gcm/push_messaging_browsertest.cc
chrome/browser/services/gcm/push_messaging_service_impl.cc
chrome/browser/services/gcm/push_messaging_service_impl.h
content/content_browser.gypi
content/public/browser/push_messaging_service.cc [new file with mode: 0644]
content/public/browser/push_messaging_service.h