| OLD | NEW |
| 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 COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_CACHE_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_CACHE_H_ |
| 6 #define COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_CACHE_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_CACHE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "components/history/core/browser/history_types.h" | 15 #include "components/history/core/browser/history_types.h" |
| 16 #include "components/history/core/browser/url_utils.h" | 16 #include "components/history/core/browser/url_utils.h" |
| 17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 18 | 18 |
| 19 class GURL; | |
| 20 | |
| 21 namespace history { | 19 namespace history { |
| 22 | 20 |
| 23 // TopSiteCache caches thumbnails for visited pages. Retrieving thumbnails from | 21 // TopSitesCache caches the top sites and thumbnails for TopSites. |
| 24 // a given input URL is a two-stage process: | 22 // |
| 23 // Retrieving thumbnails from a given input URL is a two-stage process: |
| 25 // | 24 // |
| 26 // input URL --(map 1)--> canonical URL --(map 2)--> image. | 25 // input URL --(map 1)--> canonical URL --(map 2)--> image. |
| 27 // | 26 // |
| 28 // (map 1) searches for an URL in |canonical_urls_| that "matches" (see below) | 27 // (map 1) searches for an URL in |canonical_urls_| that "matches" (see below) |
| 29 // input URL. If found, canonical URL assigned to the result. Otherwise the | 28 // input URL. If found, canonical URL assigned to the result. Otherwise the |
| 30 // input URL is considered to already be a canonical URL. | 29 // input URL is considered to already be a canonical URL. |
| 31 // | 30 // |
| 32 // (map 2) simply looks up canonical URL in |images_|. | 31 // (map 2) simply looks up canonical URL in |images_|. |
| 33 // | 32 // |
| 34 // The rule to "match" URL in |canonical_urls_| always favors exact match. | 33 // The rule to "match" URL in |canonical_urls_| always favors exact match. |
| 35 // - In GetCanonicalURL(), exact match is the only case examined. | 34 // - In GetCanonicalURL(), exact match is the only case examined. |
| 36 // - In GetGeneralizedCanonicalURL(), we also perform "generalized" URL matches, | 35 // - In GetGeneralizedCanonicalURL(), we also perform "generalized" URL matches, |
| 37 // i.e., stored URLs in |canonical_urls_| that are prefixes of input URL, | 36 // i.e., stored URLs in |canonical_urls_| that are prefixes of input URL, |
| 38 // ignoring "?query#ref". | 37 // ignoring "?query#ref". |
| 39 // For the latter two "URL prefix matches", we prefer the match that is closest | 38 // For the latter two "URL prefix matches", we prefer the match that is closest |
| 40 // to input URL, w.r.t. path hierarchy. | 39 // to input URL, w.r.t. path hierarchy. |
| 41 | |
| 42 // TopSitesCache caches the top sites and thumbnails for TopSites. | |
| 43 class TopSitesCache { | 40 class TopSitesCache { |
| 44 public: | 41 public: |
| 45 TopSitesCache(); | 42 TopSitesCache(); |
| 46 ~TopSitesCache(); | 43 ~TopSitesCache(); |
| 47 | 44 |
| 48 // Set the top sites. In |top_sites| all forced URLs must appear before | 45 // Set the top sites. In |top_sites| all forced URLs must appear before |
| 49 // non-forced URLs. This is only checked in debug. | 46 // non-forced URLs. This is only checked in debug. |
| 50 void SetTopSites(const MostVisitedURLList& top_sites); | 47 void SetTopSites(const MostVisitedURLList& top_sites); |
| 51 const MostVisitedURLList& top_sites() const { return top_sites_; } | 48 const MostVisitedURLList& top_sites() const { return top_sites_; } |
| 52 | 49 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // Helper to clear "/path?query#ref" from any GURL. This is set in the | 161 // Helper to clear "/path?query#ref" from any GURL. This is set in the |
| 165 // constructor and never modified after. | 162 // constructor and never modified after. |
| 166 GURL::Replacements clear_path_query_ref_; | 163 GURL::Replacements clear_path_query_ref_; |
| 167 | 164 |
| 168 DISALLOW_COPY_AND_ASSIGN(TopSitesCache); | 165 DISALLOW_COPY_AND_ASSIGN(TopSitesCache); |
| 169 }; | 166 }; |
| 170 | 167 |
| 171 } // namespace history | 168 } // namespace history |
| 172 | 169 |
| 173 #endif // COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_CACHE_H_ | 170 #endif // COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_CACHE_H_ |
| OLD | NEW |