Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(722)

Side by Side Diff: ios/chrome/browser/favicon/large_icon_cache.h

Issue 1413903008: Add LargeIconCache and LargeIconServiceFactory for iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Sylvain comments. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
sdefresne 2015/10/30 14:19:37 nit: no blank line and sort, i.e. struct LargeIco
justincohen 2015/10/30 15:25:15 Done.
15 struct LargeIconCacheEntry;
16
17 namespace favicon_base {
18 struct LargeIconResult;
19 };
20
21 namespace ios {
22 class ChromeBrowserState;
23 }
24
25 // Provides a cache of most recently used LargeIconResult.
26 //
27 // Example usage:
28 // LargeIconCache* large_icon_cache =
29 // IOSChromeLargeIconServiceFactory::GetForBrowserState(browser_state);
30 // scoped_ptr<favicon_base::LargeIconResult> icon =
31 // large_icon_cache->GetCachedResult(...);
32 //
33 class LargeIconCache : public KeyedService {
34 public:
35 LargeIconCache();
36 ~LargeIconCache() override;
37
38 // |LargeIconService| does everything on callbacks, and iOS needs to load the
39 // icons immediately on page load. This caches the LargeIconResult so we can
40 // immediately load.
41 void SetCachedResult(const GURL& url, const favicon_base::LargeIconResult&);
42
43 // Returns a cached LargeIconResult.
44 scoped_ptr<favicon_base::LargeIconResult> GetCachedResult(const GURL& url);
45
46 private:
47 // Clones a LargeIconResult.
48 scoped_ptr<favicon_base::LargeIconResult> CloneLargeIconResult(
49 const favicon_base::LargeIconResult& large_icon_result);
50
51 base::OwningMRUCache<GURL, LargeIconCacheEntry*> cache_;
52
53 DISALLOW_COPY_AND_ASSIGN(LargeIconCache);
54 };
55
56 #endif // IOS_CHROME_BROWSER_FAVICON_LARGE_ICON_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698