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

Unified Diff: chrome/browser/history/top_sites_impl.cc

Issue 23477033: Implementing URL prefix match for history thumbnail cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Inlining; comment fixes. 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_impl.cc
diff --git a/chrome/browser/history/top_sites_impl.cc b/chrome/browser/history/top_sites_impl.cc
index 3a1077a75c155aedfce26ea9e36ab53edaf8da06..8920e1b0737a1528991089f2c69781006ec6fbd4 100644
--- a/chrome/browser/history/top_sites_impl.cc
+++ b/chrome/browser/history/top_sites_impl.cc
@@ -212,8 +212,11 @@ void TopSitesImpl::GetMostVisitedURLs(
}
bool TopSitesImpl::GetPageThumbnail(
- const GURL& url, scoped_refptr<base::RefCountedMemory>* bytes) {
+ const GURL& url,
+ bool prefix_match,
+ scoped_refptr<base::RefCountedMemory>* bytes) {
// WARNING: this may be invoked on any thread.
+ // Perform exact match.
{
base::AutoLock lock(lock_);
if (thread_safe_cache_->GetPageThumbnail(url, bytes))
@@ -231,6 +234,18 @@ bool TopSitesImpl::GetPageThumbnail(
}
}
+ if (prefix_match) {
+ // Still not found, so strip "?query#ref", and perform prefix match.
+ GURL::Replacements replacements;
+ replacements.ClearQuery();
+ replacements.ClearRef();
+ GURL url_stripped(url.ReplaceComponents(replacements));
+ base::AutoLock lock(lock_);
+ GURL canonical_url(
+ thread_safe_cache_->GetCanonicalURLForPrefix(url_stripped));
+ if (thread_safe_cache_->GetPageThumbnail(canonical_url, bytes))
+ return true;
+ }
return false;
}

Powered by Google App Engine
This is Rietveld 408576698