Chromium Code Reviews| 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 namespace ios { | |
| 14 class ChromeBrowserState; | |
| 15 } | |
| 16 | |
| 17 namespace favicon_base { | |
| 18 struct LargeIconResult; | |
| 19 }; | |
| 20 | |
| 21 class GURL; | |
| 22 | |
| 23 // Provides a cache of most recently used LargeIconResult. | |
|
sdefresne
2015/10/29 16:45:25
Looking at the implementation this does not look l
justincohen
2015/10/29 20:32:16
Get now calls -CloneLargeIconResult, so it's more
| |
| 24 // | |
| 25 // Example usage: | |
| 26 // LargeIconCache* large_icon_cache = | |
| 27 // LargeIconCacheFactory::GetForBrowserState(browser_state); | |
|
sdefresne
2015/10/29 16:45:24
nit: s/LargeIconCacheFactory/IOSChromeLargeIconSer
justincohen
2015/10/29 20:32:17
Done.
| |
| 28 // large_icon_cache->GetCachedResult(...); | |
| 29 // | |
| 30 class LargeIconCache : public KeyedService { | |
|
sdefresne
2015/10/29 16:45:25
Since the object only temporary hold the result (a
justincohen
2015/10/29 20:32:17
Ignored, since it's not temp now.
| |
| 31 public: | |
| 32 explicit LargeIconCache(ios::ChromeBrowserState* browser_state); | |
|
sdefresne
2015/10/29 16:45:25
Change to the following as browser_state is never
justincohen
2015/10/29 20:32:17
Done.
| |
| 33 ~LargeIconCache() override; | |
| 34 | |
| 35 // |LargeIconService| does everything on callbacks, and iOS needs to load the | |
| 36 // icons immediately on page load. This caches the LargeIconResult so we can | |
| 37 // immediately load. | |
| 38 void SetCachedResult(GURL url, const favicon_base::LargeIconResult&); | |
|
sdefresne
2015/10/29 16:45:25
s/GURL/const GURL&/
justincohen
2015/10/29 20:32:17
Done.
| |
| 39 | |
| 40 // Get a cached LargeIconResult. | |
| 41 scoped_ptr<favicon_base::LargeIconResult> GetCachedResult(GURL url); | |
|
sdefresne
2015/10/29 16:45:25
s/GURL/const GURL&/
justincohen
2015/10/29 20:32:17
Done.
| |
| 42 | |
| 43 private: | |
| 44 // Cache of LargeIconResult. | |
| 45 struct CacheEntry { | |
|
sdefresne
2015/10/29 16:45:24
I would forward-declare this and only provide the
justincohen
2015/10/29 20:32:17
I'd prefer to not do this. Is it OK to skip?
| |
| 46 CacheEntry(); | |
| 47 ~CacheEntry(); | |
| 48 | |
| 49 scoped_ptr<favicon_base::LargeIconResult> result; | |
| 50 }; | |
| 51 | |
| 52 ios::ChromeBrowserState* browser_state_; | |
|
sdefresne
2015/10/29 16:45:24
This is not used, remove.
justincohen
2015/10/29 20:32:17
Done.
| |
| 53 base::OwningMRUCache<GURL, CacheEntry*> cache_; | |
| 54 | |
| 55 DISALLOW_COPY_AND_ASSIGN(LargeIconCache); | |
| 56 }; | |
| 57 | |
| 58 #endif // IOS_CHROME_BROWSER_FAVICON_LARGE_ICON_CACHE_H_ | |
| OLD | NEW |