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

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

Issue 2524533002: Added UMA for usage of BudgetAPI calls. (Closed)
Patch Set: Code review comments Created 4 years 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..9b14a38518ae5758afb10f6028748a2257f7fc80 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,20 @@ 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.
+ double budget_at = error != blink::mojom::BudgetServiceErrorType::NONE
+ ? 0
+ : budget[0]->budget_at;
Alexei Svitkine (slow) 2016/12/01 18:25:10 Nit: This looks a bit messy to me. How about: dou
harkness 2016/12/02 13:12:38 Done.
+ UMA_HISTOGRAM_COUNTS_100("BudgetAPI.QueryBudget", budget_at);
+
+ callback.Run(error, std::move(budget));
+}
+
void BudgetManager::DidConsume(const ConsumeCallback& callback,
blink::mojom::BudgetServiceErrorType error,
bool success) {
@@ -142,5 +158,7 @@ void BudgetManager::DidReserve(const url::Origin& origin,
if (success && error == blink::mojom::BudgetServiceErrorType::NONE)
reservation_map_[origin]++;
+ UMA_HISTOGRAM_BOOLEAN("BudgetAPI.Reserve", success);
+
callback.Run(error, success);
}
« no previous file with comments | « chrome/browser/budget_service/budget_manager.h ('k') | chrome/browser/budget_service/budget_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698