| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_CHROME_BROWSER_FAVICON_LARGE_ICON_CACHE_H_ |
| 6 #define IOS_CHROME_BROWSER_FAVICON_LARGE_ICON_CACHE_H_ |
| 7 |
| 8 #include "base/containers/mru_cache.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "components/keyed_service/core/keyed_service.h" |
| 12 |
| 13 class GURL; |
| 14 struct LargeIconCacheEntry; |
| 15 |
| 16 namespace favicon_base { |
| 17 struct LargeIconResult; |
| 18 } |
| 19 |
| 20 namespace ios { |
| 21 class ChromeBrowserState; |
| 22 } |
| 23 |
| 24 // Provides a cache of most recently used LargeIconResult. |
| 25 // |
| 26 // Example usage: |
| 27 // LargeIconCache* large_icon_cache = |
| 28 // IOSChromeLargeIconServiceFactory::GetForBrowserState(browser_state); |
| 29 // scoped_ptr<favicon_base::LargeIconResult> icon = |
| 30 // large_icon_cache->GetCachedResult(...); |
| 31 // |
| 32 class LargeIconCache : public KeyedService { |
| 33 public: |
| 34 LargeIconCache(); |
| 35 ~LargeIconCache() override; |
| 36 |
| 37 // |LargeIconService| does everything on callbacks, and iOS needs to load the |
| 38 // icons immediately on page load. This caches the LargeIconResult so we can |
| 39 // immediately load. |
| 40 void SetCachedResult(const GURL& url, const favicon_base::LargeIconResult&); |
| 41 |
| 42 // Returns a cached LargeIconResult. |
| 43 scoped_ptr<favicon_base::LargeIconResult> GetCachedResult(const GURL& url); |
| 44 |
| 45 private: |
| 46 // Clones a LargeIconResult. |
| 47 scoped_ptr<favicon_base::LargeIconResult> CloneLargeIconResult( |
| 48 const favicon_base::LargeIconResult& large_icon_result); |
| 49 |
| 50 base::OwningMRUCache<GURL, LargeIconCacheEntry*> cache_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(LargeIconCache); |
| 53 }; |
| 54 |
| 55 #endif // IOS_CHROME_BROWSER_FAVICON_LARGE_ICON_CACHE_H_ |
| OLD | NEW |