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

Unified Diff: chrome/browser/history/top_sites_cache.h

Issue 23477033: Implementing URL prefix match for history thumbnail cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding url_utils.*; adding chrome://thumb2; refactoring. Created 7 years, 3 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: chrome/browser/history/top_sites_cache.h
diff --git a/chrome/browser/history/top_sites_cache.h b/chrome/browser/history/top_sites_cache.h
index 822d18903dc00e05ceb538e3975f71b2a6a8e3cf..d8874879108efce328216c0ff897473e94ea0e2e 100644
--- a/chrome/browser/history/top_sites_cache.h
+++ b/chrome/browser/history/top_sites_cache.h
@@ -10,9 +10,31 @@
#include "base/memory/ref_counted.h"
#include "chrome/browser/history/history_types.h"
+#include "chrome/browser/history/url_utils.h"
namespace history {
+// TopSiteCache caches thumbnails for visited pages. Retrieving thumbnails from
+// a given [input URL] is a two-stage process:
+//
+// [input URL] --(map 1)--> [canonical URL] --(map 2)--> image.
+//
+// (map 1) searches [input URL] in |canonical_urls_|. [canonical URL] is
+// assigned to the resulting value if found; else [input URL].
+//
+// (map 2) simply looks up [canonical URL] in |images_|.
+//
+// TopSiteCache also provides GetCanonicalURLsIteratorForPrefix(), which is an
+// alternative implementation of (map 1) that does the following:
+// - if [canonical URL] is a key in |canonical_urls_|, return the value.
+// - else if [canonical URL] is a "URL prefix" (see comment in url_utils.h) of
+// some key in |canonical_urls_|, return the value corresponding to the key.
+// - else return [input URL].
+
+// The entries in CanonicalURLs, see CanonicalURLs for details. The second
+// argument gives the index of the URL into MostVisitedURLs redirects.
+typedef std::pair<MostVisitedURL*, size_t> CanonicalURLEntry;
sky 2013/09/12 21:22:18 Why is this public?
huangs 2013/09/12 23:33:47 A relic from the previous change. Moved back into
+
// TopSitesCache caches the top sites and thumbnails for TopSites.
class TopSitesCache {
public:
@@ -41,9 +63,14 @@ class TopSitesCache {
// there is a thumbnail score for the specified url.
bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score);
- // Returns the canonical URL for |url|.
+ // Returns the [canonical URL] for |url|.
const GURL& GetCanonicalURL(const GURL& url);
+ // Returns the [canonical URL] for |url_prefix| that matches by prefix.
sky 2013/09/12 21:22:18 What's with [all the brackets] ?
huangs 2013/09/12 23:33:47 The purpose is to highlight proper terms -- but I
+ // Multiple matches exst, returns the [canonical URL] for the first
+ // matching entry under lexicographical order.
+ const GURL& GetCanonicalURLForPrefix(const GURL& url_prefix);
+
// Returns true if |url| is known.
bool IsKnownURL(const GURL& url);
@@ -51,17 +78,11 @@ class TopSitesCache {
size_t GetURLIndex(const GURL& url);
private:
- // The entries in CanonicalURLs, see CanonicalURLs for details. The second
- // argument gives the index of the URL into MostVisitedURLs redirects.
- typedef std::pair<MostVisitedURL*, size_t> CanonicalURLEntry;
-
- // Comparator used for CanonicalURLs.
+ // Comparator used for CanonicalURLs. Its main purpose
class CanonicalURLComparator {
public:
bool operator()(const CanonicalURLEntry& e1,
- const CanonicalURLEntry& e2) const {
- return e1.first->redirects[e1.second] < e2.first->redirects[e2.second];
sky 2013/09/12 21:22:18 Why nuke the inlining here?
huangs 2013/09/12 23:33:47 Need to call CanonicalURLStringCompare(), and I wa
- }
+ const CanonicalURLEntry& e2) const;
};
// This is used to map from redirect url to the MostVisitedURL the redirect is
@@ -80,9 +101,14 @@ class TopSitesCache {
// Stores a set of redirects. This is used by GenerateCanonicalURLs.
void StoreRedirectChain(const RedirectList& redirects, size_t destination);
- // Returns the iterator into canconical_urls_ for the specified url.
+ // Returns the iterator into canonical_urls_ for the |url|.
sky 2013/09/12 21:22:18 Style here is || around references to parameters a
huangs 2013/09/12 23:33:47 Done.
CanonicalURLs::iterator GetCanonicalURLsIterator(const GURL& url);
+ // Returns the first iterator into canonical_urls_ for whcih |previx_url|
sky 2013/09/12 21:22:18 |canonical_urls_|. previx->prefix
huangs 2013/09/12 23:33:47 Done, also using the term "URL prefix" for consist
+ // is a path-prefix.
+ CanonicalURLs::iterator GetCanonicalURLsIteratorForPrefix(
+ const GURL& prefix_url);
+
// The top sites.
MostVisitedURLList top_sites_;

Powered by Google App Engine
This is Rietveld 408576698