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

Side by Side Diff: chrome/browser/history/top_sites_cache.h

Issue 24632002: Implementing chrome://thumbnails page to view URLs in TopSites and cached thumbnails. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Trying to fix Linux compile by reordering initializing order of weak_ptr_factory_. Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/top_sites.h ('k') | chrome/browser/history/top_sites_cache.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 CHROME_BROWSER_HISTORY_TOP_SITES_CACHE_H_ 5 #ifndef CHROME_BROWSER_HISTORY_TOP_SITES_CACHE_H_
6 #define CHROME_BROWSER_HISTORY_TOP_SITES_CACHE_H_ 6 #define CHROME_BROWSER_HISTORY_TOP_SITES_CACHE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "chrome/browser/history/history_types.h" 12 #include "chrome/browser/history/history_types.h"
13 #include "chrome/browser/history/url_utils.h" 13 #include "chrome/browser/history/url_utils.h"
14 14
15 class GURL;
16
15 namespace history { 17 namespace history {
16 18
17 // TopSiteCache caches thumbnails for visited pages. Retrieving thumbnails from 19 // TopSiteCache caches thumbnails for visited pages. Retrieving thumbnails from
18 // a given input URL is a two-stage process: 20 // a given input URL is a two-stage process:
19 // 21 //
20 // input URL --(map 1)--> canonical URL --(map 2)--> image. 22 // input URL --(map 1)--> canonical URL --(map 2)--> image.
21 // 23 //
22 // (map 1) searches input URL in |canonical_urls_|. canonical URL is 24 // (map 1) searches input URL in |canonical_urls_|. canonical URL is
23 // assigned to the resulting value if found; else input URL. 25 // assigned to the resulting value if found; else input URL.
24 // 26 //
(...skipping 21 matching lines...) Expand all
46 const URLToImagesMap& images() const { return images_; } 48 const URLToImagesMap& images() const { return images_; }
47 49
48 // Returns the thumbnail as an Image for the specified url. This adds an entry 50 // Returns the thumbnail as an Image for the specified url. This adds an entry
49 // for |url| if one has not yet been added. 51 // for |url| if one has not yet been added.
50 Images* GetImage(const GURL& url); 52 Images* GetImage(const GURL& url);
51 53
52 // Fetches the thumbnail for the specified url. Returns true if there is a 54 // Fetches the thumbnail for the specified url. Returns true if there is a
53 // thumbnail for the specified url. It is possible for a URL to be in TopSites 55 // thumbnail for the specified url. It is possible for a URL to be in TopSites
54 // but not have an thumbnail. 56 // but not have an thumbnail.
55 bool GetPageThumbnail(const GURL& url, 57 bool GetPageThumbnail(const GURL& url,
56 scoped_refptr<base::RefCountedMemory>* bytes); 58 scoped_refptr<base::RefCountedMemory>* bytes) const;
57 59
58 // Fetches the thumbnail score for the specified url. Returns true if 60 // Fetches the thumbnail score for the specified url. Returns true if
59 // there is a thumbnail score for the specified url. 61 // there is a thumbnail score for the specified url.
60 bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score); 62 bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score) const;
61 63
62 // Returns the canonical URL for |url|. 64 // Returns the canonical URL for |url|.
63 const GURL& GetCanonicalURL(const GURL& url); 65 const GURL& GetCanonicalURL(const GURL& url) const;
64 66
65 // Returns the canonical URL for |url_prefix| that matches by prefix. 67 // Returns the canonical URL for |url_prefix| that matches by prefix.
66 // Multiple matches exst, returns the canonical URL for the first 68 // If multiple matches exist, returns the canonical URL for the first
67 // matching entry under lexicographical order. 69 // matching entry under lexicographical order.
68 const GURL& GetCanonicalURLForPrefix(const GURL& url_prefix); 70 const GURL& GetCanonicalURLForPrefix(const GURL& url_prefix) const;
69 71
70 // Returns true if |url| is known. 72 // Returns true if |url| is known.
71 bool IsKnownURL(const GURL& url); 73 bool IsKnownURL(const GURL& url) const;
72 74
73 // Returns the index into |top_sites_| for |url|. 75 // Returns the index into |top_sites_| for |url|.
74 size_t GetURLIndex(const GURL& url); 76 size_t GetURLIndex(const GURL& url) const;
75 77
76 private: 78 private:
77 // The entries in CanonicalURLs, see CanonicalURLs for details. The second 79 // The entries in CanonicalURLs, see CanonicalURLs for details. The second
78 // argument gives the index of the URL into MostVisitedURLs redirects. 80 // argument gives the index of the URL into MostVisitedURLs redirects.
79 typedef std::pair<MostVisitedURL*, size_t> CanonicalURLEntry; 81 typedef std::pair<MostVisitedURL*, size_t> CanonicalURLEntry;
80 82
81 // Comparator used for CanonicalURLs. 83 // Comparator used for CanonicalURLs.
82 class CanonicalURLComparator { 84 class CanonicalURLComparator {
83 public: 85 public:
84 bool operator()(const CanonicalURLEntry& e1, 86 bool operator()(const CanonicalURLEntry& e1,
(...skipping 13 matching lines...) Expand all
98 typedef std::map<CanonicalURLEntry, size_t, 100 typedef std::map<CanonicalURLEntry, size_t,
99 CanonicalURLComparator> CanonicalURLs; 101 CanonicalURLComparator> CanonicalURLs;
100 102
101 // Generates the set of canonical urls from |top_sites_|. 103 // Generates the set of canonical urls from |top_sites_|.
102 void GenerateCanonicalURLs(); 104 void GenerateCanonicalURLs();
103 105
104 // Stores a set of redirects. This is used by GenerateCanonicalURLs. 106 // Stores a set of redirects. This is used by GenerateCanonicalURLs.
105 void StoreRedirectChain(const RedirectList& redirects, size_t destination); 107 void StoreRedirectChain(const RedirectList& redirects, size_t destination);
106 108
107 // Returns the iterator into |canonical_urls_| for the |url|. 109 // Returns the iterator into |canonical_urls_| for the |url|.
108 CanonicalURLs::iterator GetCanonicalURLsIterator(const GURL& url); 110 CanonicalURLs::const_iterator GetCanonicalURLsIterator(const GURL& url) const;
109 111
110 // Returns the first iterator into |canonical_urls_| for which |prefix_url| 112 // Returns the first iterator into |canonical_urls_| for which |prefix_url|
111 // is a URL prefix. Returns |canonical_urls_.end()| if no match is found. 113 // is a URL prefix. Returns |canonical_urls_.end()| if no match is found.
112 CanonicalURLs::iterator GetCanonicalURLsIteratorForPrefix( 114 CanonicalURLs::const_iterator GetCanonicalURLsIteratorForPrefix(
113 const GURL& prefix_url); 115 const GURL& prefix_url) const;
114 116
115 // The top sites. 117 // The top sites.
116 MostVisitedURLList top_sites_; 118 MostVisitedURLList top_sites_;
117 119
118 // The images. These map from canonical url to image. 120 // The images. These map from canonical url to image.
119 URLToImagesMap images_; 121 URLToImagesMap images_;
120 122
121 // Generated from the redirects to and from the most visited pages. See 123 // Generated from the redirects to and from the most visited pages. See
122 // description above typedef for details. 124 // description above typedef for details.
123 CanonicalURLs canonical_urls_; 125 CanonicalURLs canonical_urls_;
124 126
125 DISALLOW_COPY_AND_ASSIGN(TopSitesCache); 127 DISALLOW_COPY_AND_ASSIGN(TopSitesCache);
126 }; 128 };
127 129
128 } // namespace history 130 } // namespace history
129 131
130 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_CACHE_H_ 132 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_CACHE_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/top_sites.h ('k') | chrome/browser/history/top_sites_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698