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

Unified Diff: components/ntp_snippets/ntp_snippets_fetcher.cc

Issue 1961943002: [NTP Snippets] Add histogram with fetch time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@json_to_fetcher_5
Patch Set: Rebased. Created 4 years, 7 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
Index: components/ntp_snippets/ntp_snippets_fetcher.cc
diff --git a/components/ntp_snippets/ntp_snippets_fetcher.cc b/components/ntp_snippets/ntp_snippets_fetcher.cc
index eb5b629cb90a56b4e6649d6d1abe41f29ce3e736..1ef402feaf68d233a5bbcc120f2ee2c797dfe077 100644
--- a/components/ntp_snippets/ntp_snippets_fetcher.cc
+++ b/components/ntp_snippets/ntp_snippets_fetcher.cc
@@ -13,6 +13,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "base/time/default_tick_clock.h"
#include "base/values.h"
#include "components/data_use_measurement/core/data_use_user_data.h"
#include "components/ntp_snippets/switches.h"
@@ -99,6 +100,7 @@ NTPSnippetsFetcher::NTPSnippetsFetcher(
: url_request_context_getter_(url_request_context_getter),
parse_json_callback_(parse_json_callback),
is_stable_channel_(is_stable_channel),
+ tick_clock_(new base::DefaultTickClock()),
weak_ptr_factory_(this) {}
NTPSnippetsFetcher::~NTPSnippetsFetcher() {}
@@ -111,6 +113,7 @@ void NTPSnippetsFetcher::SetCallback(
void NTPSnippetsFetcher::FetchSnippetsFromHosts(
const std::set<std::string>& hosts, int count) {
std::string host_restricts;
+ fetch_start_time_ = tick_clock_->NowTicks();
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDontRestrict)) {
if (hosts.empty()) {
@@ -209,9 +212,13 @@ void NTPSnippetsFetcher::FetchFinished(OptionalSnippets snippets,
const std::string& extra_message) {
DCHECK(result == FetchResult::SUCCESS || !snippets);
last_status_ = FetchResultToString(result) + extra_message;
+
+ UMA_HISTOGRAM_TIMES("NewTabPage.Snippets.FetchTime",
+ tick_clock_->NowTicks() - fetch_start_time_);
UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult",
static_cast<int>(result),
static_cast<int>(FetchResult::RESULT_MAX));
+
if (!snippets_available_callback_.is_null())
snippets_available_callback_.Run(std::move(snippets));
}
« no previous file with comments | « components/ntp_snippets/ntp_snippets_fetcher.h ('k') | components/ntp_snippets/ntp_snippets_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698