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

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: Use HistogramTester to eliminate test brittleness. 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
« no previous file with comments | « no previous file | components/history/core/browser/history_backend.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 76d4b50b0b0c64248453f8b46bd3a76228dcc150..14332bded3cd5566cfb4f9f4938145948a8d793a 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"
@@ -201,6 +202,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 ----------------------------------------------------------------
@@ -518,6 +522,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);
@@ -727,6 +732,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
@@ -832,6 +839,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 1-based index in the TopHosts list.
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698