diff options
author | huangs@chromium.org <huangs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-02 07:07:02 +0000 |
---|---|---|
committer | huangs@chromium.org <huangs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-02 07:07:02 +0000 |
commit | a3216d6629ee0f00f0e46e2a5b26020006a2f4a0 (patch) | |
tree | 764f066855c591b039dc165a2cb8a73f1a2393a1 /chrome/browser/history | |
parent | 3548c98c06c043cbe5e0791415e9c5224c8454c9 (diff) | |
download | chromium_src-a3216d6629ee0f00f0e46e2a5b26020006a2f4a0.zip chromium_src-a3216d6629ee0f00f0e46e2a5b26020006a2f4a0.tar.gz chromium_src-a3216d6629ee0f00f0e46e2a5b26020006a2f4a0.tar.bz2 |
Implementing chrome://thumbnails page to view URLs in TopSites and cached thumbnails.
BUG=298240
Review URL: https://codereview.chromium.org/24632002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226411 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history')
-rw-r--r-- | chrome/browser/history/top_sites.h | 4 | ||||
-rw-r--r-- | chrome/browser/history/top_sites_cache.cc | 32 | ||||
-rw-r--r-- | chrome/browser/history/top_sites_cache.h | 22 | ||||
-rw-r--r-- | chrome/browser/history/top_sites_impl.cc | 2 | ||||
-rw-r--r-- | chrome/browser/history/top_sites_impl.h | 1 |
5 files changed, 32 insertions, 29 deletions
diff --git a/chrome/browser/history/top_sites.h b/chrome/browser/history/top_sites.h index e1ae857..92e8eee 100644 --- a/chrome/browser/history/top_sites.h +++ b/chrome/browser/history/top_sites.h @@ -15,8 +15,8 @@ #include "chrome/common/thumbnail_score.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/image/image.h" -#include "url/gurl.h" +class GURL; class Profile; namespace base { @@ -71,7 +71,7 @@ class TopSites virtual void GetMostVisitedURLs( const GetMostVisitedURLsCallback& callback) = 0; - // Get a thumbnail for a given page. Returns true iff we have the thumbnail. + // Gets a thumbnail for a given page. Returns true iff we have the thumbnail. // This may be invoked on any thread. // If an exact thumbnail URL match fails, |prefix_match| specifies whether or // not to try harder by matching the query thumbnail URL as URL prefix (as diff --git a/chrome/browser/history/top_sites_cache.cc b/chrome/browser/history/top_sites_cache.cc index 6552f73..284377f 100644 --- a/chrome/browser/history/top_sites_cache.cc +++ b/chrome/browser/history/top_sites_cache.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "base/memory/ref_counted_memory.h" +#include "url/gurl.h" namespace history { @@ -30,7 +31,7 @@ Images* TopSitesCache::GetImage(const GURL& url) { bool TopSitesCache::GetPageThumbnail( const GURL& url, - scoped_refptr<base::RefCountedMemory>* bytes) { + scoped_refptr<base::RefCountedMemory>* bytes) const { std::map<GURL, Images>::const_iterator found = images_.find(GetCanonicalURL(url)); if (found != images_.end()) { @@ -44,7 +45,7 @@ bool TopSitesCache::GetPageThumbnail( } bool TopSitesCache::GetPageThumbnailScore(const GURL& url, - ThumbnailScore* score) { + ThumbnailScore* score) const { std::map<GURL, Images>::const_iterator found = images_.find(GetCanonicalURL(url)); if (found != images_.end()) { @@ -54,21 +55,21 @@ bool TopSitesCache::GetPageThumbnailScore(const GURL& url, return false; } -const GURL& TopSitesCache::GetCanonicalURL(const GURL& url) { - CanonicalURLs::iterator i = GetCanonicalURLsIterator(url); - return i == canonical_urls_.end() ? url : i->first.first->url; +const GURL& TopSitesCache::GetCanonicalURL(const GURL& url) const { + CanonicalURLs::const_iterator it = GetCanonicalURLsIterator(url); + return it == canonical_urls_.end() ? url : it->first.first->url; } -const GURL& TopSitesCache::GetCanonicalURLForPrefix(const GURL& url) { - CanonicalURLs::iterator i = GetCanonicalURLsIteratorForPrefix(url); - return i == canonical_urls_.end() ? url : i->first.first->url; +const GURL& TopSitesCache::GetCanonicalURLForPrefix(const GURL& url) const { + CanonicalURLs::const_iterator it = GetCanonicalURLsIteratorForPrefix(url); + return it == canonical_urls_.end() ? url : it->first.first->url; } -bool TopSitesCache::IsKnownURL(const GURL& url) { +bool TopSitesCache::IsKnownURL(const GURL& url) const { return GetCanonicalURLsIterator(url) != canonical_urls_.end(); } -size_t TopSitesCache::GetURLIndex(const GURL& url) { +size_t TopSitesCache::GetURLIndex(const GURL& url) const { DCHECK(IsKnownURL(url)); return GetCanonicalURLsIterator(url)->second; } @@ -96,8 +97,8 @@ void TopSitesCache::StoreRedirectChain(const RedirectList& redirects, } } -TopSitesCache::CanonicalURLs::iterator TopSitesCache::GetCanonicalURLsIterator( - const GURL& url) { +TopSitesCache::CanonicalURLs::const_iterator + TopSitesCache::GetCanonicalURLsIterator(const GURL& url) const { MostVisitedURL most_visited_url; most_visited_url.redirects.push_back(url); CanonicalURLEntry entry; @@ -106,8 +107,9 @@ TopSitesCache::CanonicalURLs::iterator TopSitesCache::GetCanonicalURLsIterator( return canonical_urls_.find(entry); } -TopSitesCache::CanonicalURLs::iterator - TopSitesCache::GetCanonicalURLsIteratorForPrefix(const GURL& prefix_url) { +TopSitesCache::CanonicalURLs::const_iterator + TopSitesCache::GetCanonicalURLsIteratorForPrefix(const GURL& prefix_url) + const { MostVisitedURL most_visited_url; most_visited_url.redirects.push_back(prefix_url); CanonicalURLEntry entry; @@ -115,7 +117,7 @@ TopSitesCache::CanonicalURLs::iterator entry.second = 0u; // Perform effective binary search for URL prefix search. - TopSitesCache::CanonicalURLs::iterator it = + TopSitesCache::CanonicalURLs::const_iterator it = canonical_urls_.lower_bound(entry); // Perform prefix match. if (it != canonical_urls_.end()) { diff --git a/chrome/browser/history/top_sites_cache.h b/chrome/browser/history/top_sites_cache.h index 939f88d..ad1c912 100644 --- a/chrome/browser/history/top_sites_cache.h +++ b/chrome/browser/history/top_sites_cache.h @@ -12,6 +12,8 @@ #include "chrome/browser/history/history_types.h" #include "chrome/browser/history/url_utils.h" +class GURL; + namespace history { // TopSiteCache caches thumbnails for visited pages. Retrieving thumbnails from @@ -53,25 +55,25 @@ class TopSitesCache { // thumbnail for the specified url. It is possible for a URL to be in TopSites // but not have an thumbnail. bool GetPageThumbnail(const GURL& url, - scoped_refptr<base::RefCountedMemory>* bytes); + scoped_refptr<base::RefCountedMemory>* bytes) const; // Fetches the thumbnail score for the specified url. Returns true if // there is a thumbnail score for the specified url. - bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score); + bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score) const; // Returns the canonical URL for |url|. - const GURL& GetCanonicalURL(const GURL& url); + const GURL& GetCanonicalURL(const GURL& url) const; // Returns the canonical URL for |url_prefix| that matches by prefix. - // Multiple matches exst, returns the canonical URL for the first + // If multiple matches exist, returns the canonical URL for the first // matching entry under lexicographical order. - const GURL& GetCanonicalURLForPrefix(const GURL& url_prefix); + const GURL& GetCanonicalURLForPrefix(const GURL& url_prefix) const; // Returns true if |url| is known. - bool IsKnownURL(const GURL& url); + bool IsKnownURL(const GURL& url) const; // Returns the index into |top_sites_| for |url|. - size_t GetURLIndex(const GURL& url); + size_t GetURLIndex(const GURL& url) const; private: // The entries in CanonicalURLs, see CanonicalURLs for details. The second @@ -105,12 +107,12 @@ class TopSitesCache { void StoreRedirectChain(const RedirectList& redirects, size_t destination); // Returns the iterator into |canonical_urls_| for the |url|. - CanonicalURLs::iterator GetCanonicalURLsIterator(const GURL& url); + CanonicalURLs::const_iterator GetCanonicalURLsIterator(const GURL& url) const; // Returns the first iterator into |canonical_urls_| for which |prefix_url| // is a URL prefix. Returns |canonical_urls_.end()| if no match is found. - CanonicalURLs::iterator GetCanonicalURLsIteratorForPrefix( - const GURL& prefix_url); + CanonicalURLs::const_iterator GetCanonicalURLsIteratorForPrefix( + const GURL& prefix_url) const; // The top sites. MostVisitedURLList top_sites_; diff --git a/chrome/browser/history/top_sites_impl.cc b/chrome/browser/history/top_sites_impl.cc index 8920e1b..3a9149d 100644 --- a/chrome/browser/history/top_sites_impl.cc +++ b/chrome/browser/history/top_sites_impl.cc @@ -9,11 +9,11 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/metrics/histogram.h" #include "base/logging.h" #include "base/md5.h" #include "base/memory/ref_counted_memory.h" #include "base/message_loop/message_loop_proxy.h" +#include "base/metrics/histogram.h" #include "base/prefs/pref_service.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" diff --git a/chrome/browser/history/top_sites_impl.h b/chrome/browser/history/top_sites_impl.h index 5417b4a..8355f52 100644 --- a/chrome/browser/history/top_sites_impl.h +++ b/chrome/browser/history/top_sites_impl.h @@ -43,7 +43,6 @@ namespace history { class TopSitesCache; class TopSitesImplTest; - // This class allows requests for most visited urls and thumbnails on any // thread. All other methods must be invoked on the UI thread. All mutations // to internal state happen on the UI thread and are scheduled to update the |