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

Unified Diff: components/history/core/browser/top_sites_backend.cc

Issue 1005873011: Only record the execution time during startup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use a static member to make sure the histogram is recorded only once. Created 5 years, 8 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/history/core/browser/top_sites_backend.cc
diff --git a/components/history/core/browser/top_sites_backend.cc b/components/history/core/browser/top_sites_backend.cc
index 2383c1c9d213510dc217bc28465667d05dda2392..dc0773c8e7934e19ca8250924862cac9f1671719 100644
--- a/components/history/core/browser/top_sites_backend.cc
+++ b/components/history/core/browser/top_sites_backend.cc
@@ -19,6 +19,18 @@
namespace history {
+TopSitesBackend::HistogramRecording TopSitesBackend::histogram_recorded_ =
+ HISTOGRAM_RECORDING_NOT_YET;
+
+// static
+void TopSitesBackend::IncraseHistogramRecordingStatus() {
+ if (histogram_recorded_ == HISTOGRAM_RECORDING_NOT_YET) {
+ histogram_recorded_ = HISTOGRAM_RECORDING_IN_PROGRESS;
+ } else if (histogram_recorded_ == HISTOGRAM_RECORDING_IN_PROGRESS) {
+ histogram_recorded_ = HISTOGRAM_RECORDING_DONE;
+ }
+}
+
TopSitesBackend::TopSitesBackend(
const scoped_refptr<base::SingleThreadTaskRunner>& db_task_runner)
: db_(new TopSitesDatabase()), db_task_runner_(db_task_runner) {
@@ -47,10 +59,12 @@ void TopSitesBackend::GetMostVisitedThumbnails(
base::Bind(callback, thumbnails));
}
-void TopSitesBackend::UpdateTopSites(const TopSitesDelta& delta) {
+void TopSitesBackend::UpdateTopSites(const TopSitesDelta& delta,
+ const CallLocation location) {
db_task_runner_->PostTask(
FROM_HERE,
- base::Bind(&TopSitesBackend::UpdateTopSitesOnDBThread, this, delta));
+ base::Bind(&TopSitesBackend::UpdateTopSitesOnDBThread, this, delta,
+ location));
}
void TopSitesBackend::SetPageThumbnail(const MostVisitedURL& url,
@@ -101,7 +115,8 @@ void TopSitesBackend::GetMostVisitedThumbnailsOnDBThread(
}
}
-void TopSitesBackend::UpdateTopSitesOnDBThread(const TopSitesDelta& delta) {
+void TopSitesBackend::UpdateTopSitesOnDBThread(
+ const TopSitesDelta& delta, const CallLocation location) {
TRACE_EVENT0("startup", "history::TopSitesBackend::UpdateTopSitesOnDBThread");
if (!db_)
@@ -120,8 +135,15 @@ void TopSitesBackend::UpdateTopSitesOnDBThread(const TopSitesDelta& delta) {
for (size_t i = 0; i < delta.moved.size(); ++i)
db_->UpdatePageRank(delta.moved[i].url, delta.moved[i].rank);
- UMA_HISTOGRAM_TIMES("History.UpdateTopSitesOnDBThreadTime",
- base::TimeTicks::Now() - begin_time);
+ // If this is initiated from TopSitesImpl::OnGotMostVisitedThumbnails, and
+ // |histogram_recorded_| indicates that the histogram recording is in
+ // progress, records the function execution time.
+ if (location == CALL_LOCATION_FROM_ON_GOT_MOST_VISITED_THUMBNAILS &&
+ histogram_recorded_ == HISTOGRAM_RECORDING_IN_PROGRESS) {
+ UMA_HISTOGRAM_TIMES("History.UpdateTopSitesOnDBThread_Startup_Time",
+ base::TimeTicks::Now() - begin_time);
+ IncraseHistogramRecordingStatus();
+ }
}
void TopSitesBackend::SetPageThumbnailOnDBThread(const MostVisitedURL& url,

Powered by Google App Engine
This is Rietveld 408576698