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

Unified Diff: chrome/browser/budget_service/budget_manager.cc

Issue 2524533002: Added UMA for usage of BudgetAPI calls. (Closed)
Patch Set: Created 4 years, 1 month 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/budget_service/budget_manager.cc
diff --git a/chrome/browser/budget_service/budget_manager.cc b/chrome/browser/budget_service/budget_manager.cc
index cdf4fd71c885c1600d30b938cd913f3f32728e69..60de27bbe0d08bef685df9828341f23a61774b7e 100644
--- a/chrome/browser/budget_service/budget_manager.cc
+++ b/chrome/browser/budget_service/budget_manager.cc
@@ -74,7 +74,9 @@ void BudgetManager::GetBudget(const url::Origin& origin,
mojo::Array<blink::mojom::BudgetStatePtr>());
return;
}
- db_.GetBudgetDetails(origin, callback);
+ db_.GetBudgetDetails(origin,
+ base::Bind(&BudgetManager::DidGetBudget,
+ weak_ptr_factory_.GetWeakPtr(), callback));
}
void BudgetManager::Reserve(const url::Origin& origin,
@@ -122,6 +124,21 @@ void BudgetManager::Consume(const url::Origin& origin,
weak_ptr_factory_.GetWeakPtr(), callback));
}
+void BudgetManager::DidGetBudget(
+ const GetBudgetCallback& callback,
+ const blink::mojom::BudgetServiceErrorType error,
+ mojo::Array<blink::mojom::BudgetStatePtr> budget) {
+ // If there was an error, just record a budget of 0, so the API query is still
+ // counted.
+ if (error != blink::mojom::BudgetServiceErrorType::NONE)
+ UMA_HISTOGRAM_COUNTS_100("PushMessaging.BudgetAPIQuery", 0);
+ else
+ UMA_HISTOGRAM_COUNTS_100("PushMessaging.BudgetAPIQuery",
+ budget[0]->budget_at);
Peter Beverloo 2016/11/28 10:59:00 What is the added value of recording the immediate
harkness 2016/11/28 13:58:04 I'd like to have an idea of whether the people who
Peter Beverloo 2016/11/28 14:14:06 But since UMA gives us aggregated data, we have no
harkness 2016/11/28 16:09:09 My gut feel for the API is that it will be used by
Peter Beverloo 2016/11/28 18:22:04 We have three variables for values in this histogr
harkness 2016/11/29 15:27:21 Discussed in person, summarizing here. The budget
+
+ callback.Run(error, std::move(budget));
+}
+
void BudgetManager::DidConsume(const ConsumeCallback& callback,
blink::mojom::BudgetServiceErrorType error,
bool success) {
@@ -142,5 +159,7 @@ void BudgetManager::DidReserve(const url::Origin& origin,
if (success && error == blink::mojom::BudgetServiceErrorType::NONE)
reservation_map_[origin]++;
+ UMA_HISTOGRAM_BOOLEAN("PushMessaging.BudgetAPIReserve", success);
+
callback.Run(error, success);
}

Powered by Google App Engine
This is Rietveld 408576698