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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/history/core/browser/history_backend.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_
6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/containers/hash_tables.h"
13 #include "base/containers/mru_cache.h" 14 #include "base/containers/mru_cache.h"
14 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
15 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
16 #include "base/memory/memory_pressure_listener.h" 17 #include "base/memory/memory_pressure_listener.h"
17 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
18 #include "base/observer_list.h" 19 #include "base/observer_list.h"
19 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
20 #include "base/supports_user_data.h" 21 #include "base/supports_user_data.h"
21 #include "base/task/cancelable_task_tracker.h" 22 #include "base/task/cancelable_task_tracker.h"
22 #include "components/favicon_base/favicon_usage_data.h" 23 #include "components/favicon_base/favicon_usage_data.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // Persists any in-flight state, without actually shutting down the history 195 // Persists any in-flight state, without actually shutting down the history
195 // system. This is intended for use when the application is backgrounded. 196 // system. This is intended for use when the application is backgrounded.
196 void PersistState(); 197 void PersistState();
197 #endif 198 #endif
198 199
199 void ClearCachedDataForContextID(ContextID context_id); 200 void ClearCachedDataForContextID(ContextID context_id);
200 201
201 // Computes the |num_hosts| most-visited hostnames in the past 30 days. See 202 // Computes the |num_hosts| most-visited hostnames in the past 30 days. See
202 // history_service.h for details. Returns an empty list if db_ is not 203 // history_service.h for details. Returns an empty list if db_ is not
203 // initialized. 204 // initialized.
205 //
206 // As a side effect, caches the list of top hosts for the purposes of
207 // generating internal metrics.
204 TopHostsList TopHosts(int num_hosts) const; 208 TopHostsList TopHosts(int num_hosts) const;
205 209
206 // Navigation ---------------------------------------------------------------- 210 // Navigation ----------------------------------------------------------------
207 211
208 // |request.time| must be unique with high probability. 212 // |request.time| must be unique with high probability.
209 void AddPage(const HistoryAddPageArgs& request); 213 void AddPage(const HistoryAddPageArgs& request);
210 virtual void SetPageTitle(const GURL& url, const base::string16& title); 214 virtual void SetPageTitle(const GURL& url, const base::string16& title);
211 void AddPageNoVisitForBookmark(const GURL& url, const base::string16& title); 215 void AddPageNoVisitForBookmark(const GURL& url, const base::string16& title);
212 void UpdateWithPageEndTime(ContextID context_id, 216 void UpdateWithPageEndTime(ContextID context_id,
213 int nav_entry_id, 217 int nav_entry_id,
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired); 515 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired);
512 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 516 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
513 UpdateFaviconMappingsAndFetchNoDB); 517 UpdateFaviconMappingsAndFetchNoDB);
514 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs); 518 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs);
515 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts); 519 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts);
516 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_ElidePortAndScheme); 520 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_ElidePortAndScheme);
517 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_ElideWWW); 521 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_ElideWWW);
518 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_OnlyLast30Days); 522 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_OnlyLast30Days);
519 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_MaxNumHosts); 523 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_MaxNumHosts);
520 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_IgnoreUnusualURLs); 524 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_IgnoreUnusualURLs);
525 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RecordTopHostsMetrics);
521 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration); 526 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration);
522 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExpireHistoryForTimes); 527 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExpireHistoryForTimes);
523 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteFTSIndexDatabases); 528 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteFTSIndexDatabases);
524 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTypedUrlTest, 529 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTypedUrlTest,
525 ProcessUserChangeRemove); 530 ProcessUserChangeRemove);
526 friend class ::TestingProfile; 531 friend class ::TestingProfile;
527 532
528 // Computes the name of the specified database on disk. 533 // Computes the name of the specified database on disk.
529 base::FilePath GetArchivedFileName() const; 534 base::FilePath GetArchivedFileName() const;
530 base::FilePath GetThumbnailFileName() const; 535 base::FilePath GetThumbnailFileName() const;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 void NotifyURLVisited(ui::PageTransition transition, 725 void NotifyURLVisited(ui::PageTransition transition,
721 const URLRow& row, 726 const URLRow& row,
722 const RedirectList& redirects, 727 const RedirectList& redirects,
723 base::Time visit_time) override; 728 base::Time visit_time) override;
724 void NotifyURLsModified(const URLRows& rows) override; 729 void NotifyURLsModified(const URLRows& rows) override;
725 void NotifyURLsDeleted(bool all_history, 730 void NotifyURLsDeleted(bool all_history,
726 bool expired, 731 bool expired,
727 const URLRows& rows, 732 const URLRows& rows,
728 const std::set<GURL>& favicon_urls) override; 733 const std::set<GURL>& favicon_urls) override;
729 734
735 void RecordTopHostsMetrics(const GURL& url);
736
730 // Deleting all history ------------------------------------------------------ 737 // Deleting all history ------------------------------------------------------
731 738
732 // Deletes all history. This is a special case of deleting that is separated 739 // Deletes all history. This is a special case of deleting that is separated
733 // from our normal dependency-following method for performance reasons. The 740 // from our normal dependency-following method for performance reasons. The
734 // logic lives here instead of ExpireHistoryBackend since it will cause 741 // logic lives here instead of ExpireHistoryBackend since it will cause
735 // re-initialization of some databases (e.g. Thumbnails) that could fail. 742 // re-initialization of some databases (e.g. Thumbnails) that could fail.
736 // When these databases are not valid, our pointers must be null, so we need 743 // When these databases are not valid, our pointers must be null, so we need
737 // to handle this type of operation to keep the pointers in sync. 744 // to handle this type of operation to keep the pointers in sync.
738 void DeleteAllHistory(); 745 void DeleteAllHistory();
739 746
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 // of inheritance from base::SupportsUserData). 832 // of inheritance from base::SupportsUserData).
826 scoped_ptr<HistoryBackendHelper> supports_user_data_helper_; 833 scoped_ptr<HistoryBackendHelper> supports_user_data_helper_;
827 834
828 // Used to manage syncing of the typed urls datatype. This will be null before 835 // Used to manage syncing of the typed urls datatype. This will be null before
829 // Init is called. 836 // Init is called.
830 scoped_ptr<TypedUrlSyncableService> typed_url_syncable_service_; 837 scoped_ptr<TypedUrlSyncableService> typed_url_syncable_service_;
831 838
832 // Listens for the system being under memory pressure. 839 // Listens for the system being under memory pressure.
833 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; 840 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_;
834 841
842 // Map from host to 1-based index in the TopHosts list.
843 mutable base::hash_map<std::string, int> host_ranks_;
844
835 // List of observers 845 // List of observers
836 base::ObserverList<HistoryBackendObserver> observers_; 846 base::ObserverList<HistoryBackendObserver> observers_;
837 847
838 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); 848 DISALLOW_COPY_AND_ASSIGN(HistoryBackend);
839 }; 849 };
840 850
841 } // namespace history 851 } // namespace history
842 852
843 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ 853 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_
OLDNEW
« 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