Index: components/history/core/browser/top_sites_backend.h |
diff --git a/components/history/core/browser/top_sites_backend.h b/components/history/core/browser/top_sites_backend.h |
index d3c054b81032026a27077b0837323c028fba7eaf..7f34470075315c24900de8872048b25f2def8230 100644 |
--- a/components/history/core/browser/top_sites_backend.h |
+++ b/components/history/core/browser/top_sites_backend.h |
@@ -26,6 +26,43 @@ class TopSitesDatabase; |
// thread. |
class TopSitesBackend : public base::RefCountedThreadSafe<TopSitesBackend> { |
public: |
+ // TODO(yiyaoliu): Remove the enums and related code when crbug/223430 is |
+ // fixed. |
+ |
+ // An enum representing different situations under which function |
+ // TopSitesImpl::SetTopSites and TopSitesBackend::UpdateTopSites can be |
+ // initiated. |
+ // This is needed because a histogram is used to record speed related metrics |
+ // when TopSitesImpl::SetTopSites and TopSitesBackend::UpdateTopSites are |
+ // initiated from TopSitesImpl::OnGotMostVisitedThumbnails, which usually |
+ // happens early and might affect Chrome startup speed. |
+ enum CallLocation { |
+ // SetTopSites is called when MostVisitedThumbnails is available (function |
+ // TopSitesImpl::OnGotMostVisitedThumbnails). |
+ CALL_LOCATION_FROM_ON_GOT_MOST_VISITED_THUMBNAILS, |
+ // All other situations. |
+ CALL_LOCATION_FROM_OTHER_PLACES |
+ }; |
+ |
+ // An enum representing the histogram recording status used by class |
+ // TopSitesImpl and class TopSitesBackend. The purpose is to make sure that |
+ // TopSitesImpl and TopSitesBackend records the relevant histograms at most |
+ // once during startup. |
+ // The initial value will be HISTOGRAM_RECORDING_NOT_YET. TopSitesImpl will |
+ // change it to HISTOGRAM_RECORDING_IN_PROGRESS and records a histogram. |
+ // TopSitesBackend will only records the value if this enum is |
+ // HISTOGRAM_RECORDING_IN_PROGRESS and after that it changes the enum value to |
+ // HISTOGRAM_RECORDING_DONE. |
+ enum HistogramRecording { |
+ HISTOGRAM_RECORDING_NOT_YET, |
+ HISTOGRAM_RECORDING_IN_PROGRESS, |
+ HISTOGRAM_RECORDING_DONE |
+ }; |
+ |
+ // Move the histogram recording status to the next step. |
+ static void IncraseHistogramRecordingStatus(); |
sky
2015/04/16 16:05:10
Increase
Why does this need to be public? Doesn't
|
+ static HistogramRecording histogram_recorded() { return histogram_recorded_; } |
+ |
// The boolean parameter indicates if the DB existed on disk or needs to be |
// migrated. |
typedef base::Callback<void(const scoped_refptr<MostVisitedThumbnails>&)> |
@@ -45,7 +82,9 @@ class TopSitesBackend : public base::RefCountedThreadSafe<TopSitesBackend> { |
base::CancelableTaskTracker* tracker); |
// Updates top sites database from the specified delta. |
- void UpdateTopSites(const TopSitesDelta& delta); |
+ // TODO(yiyaoliu): Remove the 2nd parameter when crbug/223430 is fixed. |
+ void UpdateTopSites(const TopSitesDelta& delta, |
+ const CallLocation location); |
// Sets the thumbnail. |
void SetPageThumbnail(const MostVisitedURL& url, |
@@ -77,7 +116,9 @@ class TopSitesBackend : public base::RefCountedThreadSafe<TopSitesBackend> { |
scoped_refptr<MostVisitedThumbnails> thumbnails); |
// Updates top sites. |
- void UpdateTopSitesOnDBThread(const TopSitesDelta& delta); |
+ // TODO(yiyaoliu): Remove the 2nd parameter when crbug/223430 is fixed. |
+ void UpdateTopSitesOnDBThread(const TopSitesDelta& delta, |
+ const CallLocation location); |
// Sets the thumbnail. |
void SetPageThumbnailOnDBThread(const MostVisitedURL& url, |
@@ -92,6 +133,8 @@ class TopSitesBackend : public base::RefCountedThreadSafe<TopSitesBackend> { |
scoped_ptr<TopSitesDatabase> db_; |
scoped_refptr<base::SingleThreadTaskRunner> db_task_runner_; |
+ static HistogramRecording histogram_recorded_; |
+ |
DISALLOW_COPY_AND_ASSIGN(TopSitesBackend); |
}; |