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

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

Issue 2058523003: Make BackgroundBudgetService calls asynchronous. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More test code cleanup Created 4 years, 6 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') | no next file » | 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 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;
}
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_notification_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698