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

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: dcheck ordering 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
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_notification_manager.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c95c250bbde8f83bd2d5d7adb446ecce289fc8ce 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"
@@ -85,8 +86,6 @@ NotificationDatabaseData CreateDatabaseData(
return database_data;
}
-void IgnoreResult(bool unused) {}
-
} // namespace
PushMessagingNotificationManager::PushMessagingNotificationManager(
@@ -192,16 +191,11 @@ 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,
- weak_factory_.GetWeakPtr(), origin,
- service_worker_registration_id, notification_shown,
- notification_needed, message_handled_closure));
+ std::string notification_history =
+ BackgroundBudgetService::GetBudget(profile_, origin);
+ DidGetBudget(origin, service_worker_registration_id, notification_shown,
+ notification_needed, message_handled_closure,
+ notification_history);
} else {
RecordUserVisibleStatus(
content::PUSH_USER_VISIBLE_STATUS_NOT_REQUIRED_AND_NOT_SHOWN);
@@ -242,18 +236,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,10 +260,7 @@ 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,
- base::Bind(&IgnoreResult)); // This is a heuristic; ignore failure.
+ BackgroundBudgetService::StoreBudget(profile_, origin, updated_data);
if (notification_shown) {
RecordUserVisibleStatus(
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_notification_manager.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698