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