OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_NTP_TILES_ICON_CACHER_H_ | 5 #ifndef COMPONENTS_NTP_TILES_ICON_CACHER_H_ |
6 #define COMPONENTS_NTP_TILES_ICON_CACHER_H_ | 6 #define COMPONENTS_NTP_TILES_ICON_CACHER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "components/ntp_tiles/popular_sites.h" | 9 #include "components/ntp_tiles/popular_sites.h" |
10 | 10 |
11 namespace ntp_tiles { | 11 namespace ntp_tiles { |
12 | 12 |
13 // Ensures that a Popular Sites icon is cached, downloading and saving it if | 13 // Ensures that Popular Sites icons and MostLikely icons are cached, downloading |
14 // not. | 14 // and saving them if not. |
15 // | 15 // |
16 // Does not provide any way to get a fetched favicon; use the FaviconService for | 16 // Does not provide any way to get a fetched favicon; use the FaviconService / |
17 // that. All this interface guarantees is that FaviconService will be able to | 17 // LargeIconService for that. All this interface guarantees is that |
18 // get you an icon (if it exists). | 18 // FaviconService will be able to get you an icon (if it exists). |
19 class IconCacher { | 19 class IconCacher { |
20 public: | 20 public: |
21 virtual ~IconCacher() = default; | 21 virtual ~IconCacher() = default; |
22 | 22 |
23 // Fetches the icon if necessary. If a new icon was fetched, the optional | 23 // Fetches the icon if necessary. If a new icon was fetched, the optional |
24 // |icon_available| callback will be invoked. | 24 // |icon_available| callback will be invoked. |
25 // If there are preliminary icons (e.g. provided by static resources), the | 25 // If there are preliminary icons (e.g. provided by static resources), the |
26 // optional |preliminary_icon_available| callback will be invoked in addition. | 26 // optional |preliminary_icon_available| callback will be invoked in addition. |
27 // TODO(fhorschig): In case we keep these, make them OnceClosures. | 27 // TODO(fhorschig): In case we keep these, make them OnceClosures. |
28 virtual void StartFetch(PopularSites::Site site, | 28 virtual void StartFetchPopularSites( |
29 const base::Closure& icon_available, | 29 PopularSites::Site site, |
30 const base::Closure& preliminary_icon_available) = 0; | 30 const base::Closure& icon_available, |
| 31 const base::Closure& preliminary_icon_available) = 0; |
| 32 |
| 33 // Fetches the icon if necessary, then invokes |done| with true if it was |
| 34 // newly fetched (false if it was already cached or could not be fetched). |
| 35 virtual void StartFetchMostLikely(const GURL& page_url, |
| 36 const base::Closure& icon_available) = 0; |
31 }; | 37 }; |
32 | 38 |
33 } // namespace ntp_tiles | 39 } // namespace ntp_tiles |
34 | 40 |
35 #endif // COMPONENTS_NTP_TILES_ICON_CACHER_H_ | 41 #endif // COMPONENTS_NTP_TILES_ICON_CACHER_H_ |
OLD | NEW |