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

Unified Diff: chrome/browser/push_messaging/push_messaging_notification_manager.cc

Issue 1861683002: Background service worker push message processing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switched the key to origin and added tests. Created 4 years, 8 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_notification_manager.cc
diff --git a/chrome/browser/push_messaging/push_messaging_notification_manager.cc b/chrome/browser/push_messaging/push_messaging_notification_manager.cc
index 40db513ff68c350ced42d8e0f21dca4bd0c6dbbc..29bbcb46bda2fd2f9f69ffe3112c5265a8fc83d4 100644
--- a/chrome/browser/push_messaging/push_messaging_notification_manager.cc
+++ b/chrome/browser/push_messaging/push_messaging_notification_manager.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/notifications/platform_notification_service_impl.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/push_messaging/background_budget_service.h"
#include "chrome/browser/push_messaging/push_messaging_constants.h"
#include "chrome/common/features.h"
#include "chrome/common/pref_names.h"
@@ -192,16 +193,13 @@ void PushMessagingNotificationManager::DidGetNotificationsFromDatabase(
// Don't track push messages that didn't show a notification but were exempt
// from needing to do so.
if (notification_shown || notification_needed) {
- ServiceWorkerContext* service_worker_context =
- GetStoragePartition(profile_, origin)->GetServiceWorkerContext();
-
- PushMessagingService::GetNotificationsShownByLastFewPushes(
- service_worker_context, service_worker_registration_id,
- base::Bind(&PushMessagingNotificationManager::
- DidGetNotificationsShownAndNeeded,
+ chrome::BackgroundBudgetService::GetBudget(
+ profile_, origin,
+ base::Bind(&PushMessagingNotificationManager::DidGetBudget,
weak_factory_.GetWeakPtr(), origin,
service_worker_registration_id, notification_shown,
notification_needed, message_handled_closure));
+
} else {
RecordUserVisibleStatus(
content::PUSH_USER_VISIBLE_STATUS_NOT_REQUIRED_AND_NOT_SHOWN);
@@ -242,18 +240,14 @@ bool PushMessagingNotificationManager::IsTabVisible(
return visible_url.GetOrigin() == origin;
}
-void PushMessagingNotificationManager::DidGetNotificationsShownAndNeeded(
+void PushMessagingNotificationManager::DidGetBudget(
const GURL& origin,
int64_t service_worker_registration_id,
bool notification_shown,
bool notification_needed,
const base::Closure& message_handled_closure,
- const std::string& data,
- bool success,
- bool not_found) {
+ const std::string& data) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- ServiceWorkerContext* service_worker_context =
- GetStoragePartition(profile_, origin)->GetServiceWorkerContext();
// We remember whether the last (up to) 10 pushes showed notifications.
const size_t MISSED_NOTIFICATIONS_LENGTH = 10;
@@ -270,9 +264,8 @@ void PushMessagingNotificationManager::DidGetNotificationsShownAndNeeded(
missed_notifications[0] = needed_but_not_shown;
std::string updated_data(missed_notifications.
to_string<char, std::string::traits_type, std::string::allocator_type>());
- PushMessagingService::SetNotificationsShownByLastFewPushes(
- service_worker_context, service_worker_registration_id, origin,
- updated_data,
+ chrome::BackgroundBudgetService::StoreBudget(
+ profile_, origin, updated_data,
base::Bind(&IgnoreResult)); // This is a heuristic; ignore failure.
if (notification_shown) {

Powered by Google App Engine
This is Rietveld 408576698