OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 13 matching lines...) Expand all Loading... |
24 ~TopSitesCache(); | 24 ~TopSitesCache(); |
25 | 25 |
26 // The top sites. | 26 // The top sites. |
27 void SetTopSites(const MostVisitedURLList& top_sites); | 27 void SetTopSites(const MostVisitedURLList& top_sites); |
28 const MostVisitedURLList& top_sites() const { return top_sites_; } | 28 const MostVisitedURLList& top_sites() const { return top_sites_; } |
29 | 29 |
30 // The thumbnails. | 30 // The thumbnails. |
31 void SetThumbnails(const URLToImagesMap& images); | 31 void SetThumbnails(const URLToImagesMap& images); |
32 const URLToImagesMap& images() const { return images_; } | 32 const URLToImagesMap& images() const { return images_; } |
33 | 33 |
34 // Set a thumbnail. | |
35 void SetPageThumbnail(const GURL& url, | |
36 RefCountedBytes* thumbnail, | |
37 const ThumbnailScore& score); | |
38 | |
39 // Returns the thumbnail as an Image for the specified url. This adds an entry | 34 // Returns the thumbnail as an Image for the specified url. This adds an entry |
40 // for |url| if one has not yet been added. | 35 // for |url| if one has not yet been added. |
41 Images* GetImage(const GURL& url); | 36 Images* GetImage(const GURL& url); |
42 | 37 |
43 // Fetches the thumbnail for the specified url. Returns true if there is a | 38 // Fetches the thumbnail for the specified url. Returns true if there is a |
44 // thumbnail for the specified url. It is possible for a URL to be in TopSites | 39 // thumbnail for the specified url. It is possible for a URL to be in TopSites |
45 // but not have an thumbnail. | 40 // but not have an thumbnail. |
46 bool GetPageThumbnail(const GURL& url, | 41 bool GetPageThumbnail(const GURL& url, |
47 scoped_refptr<RefCountedBytes>* bytes); | 42 scoped_refptr<RefCountedBytes>* bytes); |
48 | 43 |
49 // Fetches the thumbnail score for the specified url. Returns true if | 44 // Fetches the thumbnail score for the specified url. Returns true if |
50 // there is a thumbnail score for the specified url. | 45 // there is a thumbnail score for the specified url. |
51 bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score); | 46 bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score); |
52 | 47 |
53 // Returns the canonical URL for |url|. | 48 // Returns the canonical URL for |url|. |
54 GURL GetCanonicalURL(const GURL& url); | 49 GURL GetCanonicalURL(const GURL& url); |
55 | 50 |
56 // Returns true if |url| is known. | 51 // Returns true if |url| is known. |
57 bool IsKnownURL(const GURL& url); | 52 bool IsKnownURL(const GURL& url); |
58 | 53 |
59 // Returns the index into |top_sites_| for |url|. | 54 // Returns the index into |top_sites_| for |url|. |
60 size_t GetURLIndex(const GURL& url); | 55 size_t GetURLIndex(const GURL& url); |
61 | 56 |
62 // Removes any thumbnails that are no longer referenced by the top sites. | |
63 void RemoveUnreferencedThumbnails(); | |
64 | |
65 private: | 57 private: |
66 // The entries in CanonicalURLs, see CanonicalURLs for details. The second | 58 // The entries in CanonicalURLs, see CanonicalURLs for details. The second |
67 // argument gives the index of the URL into MostVisitedURLs redirects. | 59 // argument gives the index of the URL into MostVisitedURLs redirects. |
68 typedef std::pair<MostVisitedURL*, size_t> CanonicalURLEntry; | 60 typedef std::pair<MostVisitedURL*, size_t> CanonicalURLEntry; |
69 | 61 |
70 // Comparator used for CanonicalURLs. | 62 // Comparator used for CanonicalURLs. |
71 class CanonicalURLComparator { | 63 class CanonicalURLComparator { |
72 public: | 64 public: |
73 bool operator()(const CanonicalURLEntry& e1, | 65 bool operator()(const CanonicalURLEntry& e1, |
74 const CanonicalURLEntry& e2) const { | 66 const CanonicalURLEntry& e2) const { |
(...skipping 29 matching lines...) Expand all Loading... |
104 // Generated from the redirects to and from the most visited pages. See | 96 // Generated from the redirects to and from the most visited pages. See |
105 // description above typedef for details. | 97 // description above typedef for details. |
106 CanonicalURLs canonical_urls_; | 98 CanonicalURLs canonical_urls_; |
107 | 99 |
108 DISALLOW_COPY_AND_ASSIGN(TopSitesCache); | 100 DISALLOW_COPY_AND_ASSIGN(TopSitesCache); |
109 }; | 101 }; |
110 | 102 |
111 } // namespace history | 103 } // namespace history |
112 | 104 |
113 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_CACHE_H_ | 105 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_CACHE_H_ |
OLD | NEW |