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 490ecaae401e22f4e8e85076edc7eb0c235b22ac..e80db64effe85f8adc5f90611d4f98bd21dda374 100644 |
--- a/chrome/browser/push_messaging/push_messaging_notification_manager.cc |
+++ b/chrome/browser/push_messaging/push_messaging_notification_manager.cc |
@@ -186,12 +186,24 @@ void PushMessagingNotificationManager::DidGetNotificationsFromDatabase( |
} |
} |
- // Get the budget for the service worker. This will internally record UMA |
- // for budget development work in the future. |
+ // Get the budget for the service worker. |
BackgroundBudgetService* service = |
BackgroundBudgetServiceFactory::GetForProfile(profile_); |
- double budget = service->GetBudget(origin); |
+ service->GetBudget( |
+ origin, |
+ base::Bind(&PushMessagingNotificationManager::DidGetBudget, |
+ weak_factory_.GetWeakPtr(), origin, |
+ service_worker_registration_id, message_handled_closure, |
+ notification_needed, notification_shown)); |
+} |
+void PushMessagingNotificationManager::DidGetBudget( |
+ const GURL& origin, |
+ int64_t service_worker_registration_id, |
+ const base::Closure& message_handled_closure, |
+ bool notification_needed, |
+ bool notification_shown, |
+ const double budget) { |
// Record the budget available any time the budget is queried. |
UMA_HISTOGRAM_COUNTS_100("PushMessaging.BackgroundBudget", budget); |
@@ -275,14 +287,14 @@ void PushMessagingNotificationManager::CheckForMissedNotification( |
double cost = BackgroundBudgetService::GetCost( |
BackgroundBudgetService::CostType::SILENT_PUSH); |
if (budget >= cost) { |
- // Update the stored budget. |
+ RecordUserVisibleStatus( |
+ content::PUSH_USER_VISIBLE_STATUS_REQUIRED_BUT_NOT_SHOWN_USED_GRACE); |
+ |
BackgroundBudgetService* service = |
BackgroundBudgetServiceFactory::GetForProfile(profile_); |
- service->StoreBudget(origin, budget - cost); |
+ // Update the stored budget. |
+ service->StoreBudget(origin, budget - cost, message_handled_closure); |
- RecordUserVisibleStatus( |
- content::PUSH_USER_VISIBLE_STATUS_REQUIRED_BUT_NOT_SHOWN_USED_GRACE); |
- message_handled_closure.Run(); |
return; |
} |