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

Unified Diff: components/history/core/browser/history_backend.h

Issue 1179953005: Add History.TopHostsVisitsByRank UMA metric. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@is_allowed
Patch Set: Make History.TopHostsVisitsByRank 1-based again. Created 5 years, 6 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/history_backend.h
diff --git a/components/history/core/browser/history_backend.h b/components/history/core/browser/history_backend.h
index 303847502e6d92ef849e1042dfb818c5eb9b84f4..49f891ec8958bf0afa96faebb5475fd357c39e17 100644
--- a/components/history/core/browser/history_backend.h
+++ b/components/history/core/browser/history_backend.h
@@ -10,6 +10,7 @@
#include <utility>
#include <vector>
+#include "base/containers/hash_tables.h"
#include "base/containers/mru_cache.h"
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
@@ -202,6 +203,9 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
// Computes the |num_hosts| most-visited hostnames in the past 30 days. See
// history_service.h for details. Returns an empty list if db_ is not
// initialized.
+ //
+ // As a side effect, caches the list of top hosts for the purposes of
+ // generating internal metrics.
TopHostsList TopHosts(int num_hosts) const;
// Navigation ----------------------------------------------------------------
@@ -521,6 +525,7 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_OnlyLast30Days);
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_MaxNumHosts);
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_IgnoreUnusualURLs);
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RecordTopHostsMetrics);
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration);
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExpireHistoryForTimes);
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteFTSIndexDatabases);
@@ -738,6 +743,8 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
const URLRows& rows,
const std::set<GURL>& favicon_urls) override;
+ void RecordTopHostsMetrics(const GURL& url);
+
// Deleting all history ------------------------------------------------------
// Deletes all history. This is a special case of deleting that is separated
@@ -836,6 +843,9 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
// Listens for the system being under memory pressure.
scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_;
+ // Map from host to index in the TopHosts list.
sky 2015/07/01 16:53:32 Add a comment that this map is not necessarily up
twifkak 2015/07/01 19:58:40 Done.
+ mutable base::hash_map<std::string, int> host_ranks_;
+
// List of observers
base::ObserverList<HistoryBackendObserver> observers_;
« no previous file with comments | « no previous file | components/history/core/browser/history_backend.cc » ('j') | components/history/core/browser/url_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698