Chromium Code Reviews| Index: ios/chrome/browser/favicon/large_icon_cache.h |
| diff --git a/ios/chrome/browser/favicon/large_icon_cache.h b/ios/chrome/browser/favicon/large_icon_cache.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..112b3678abbbb8a73337cf69e61ef540f64b531d |
| --- /dev/null |
| +++ b/ios/chrome/browser/favicon/large_icon_cache.h |
| @@ -0,0 +1,61 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef IOS_CHROME_BROWSER_FAVICON_LARGE_ICON_CACHE_H_ |
| +#define IOS_CHROME_BROWSER_FAVICON_LARGE_ICON_CACHE_H_ |
| + |
| +#include "base/containers/mru_cache.h" |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "components/keyed_service/core/keyed_service.h" |
| + |
| +namespace ios { |
|
sdefresne
2015/10/30 09:27:19
nit: ditto, sort namespaces.
justincohen
2015/10/30 11:59:20
Done.
|
| +class ChromeBrowserState; |
| +} |
| + |
| +namespace favicon_base { |
| +struct LargeIconResult; |
| +}; |
| + |
| +class GURL; |
|
sdefresne
2015/10/30 09:27:19
nit: ditto, please put before namespaces.
justincohen
2015/10/30 11:59:21
Done.
|
| + |
| +// Provides a cache of most recently used LargeIconResult. |
| +// |
| +// Example usage: |
| +// LargeIconCache* large_icon_cache = |
| +// IOSChromeLargeIconServiceFactory::GetForBrowserState(browser_state); |
| +// large_icon_cache->GetCachedResult(...); |
|
sdefresne
2015/10/30 09:27:18
nit:
scoped_ptr<favicon_base::LargeIconResult> ic
justincohen
2015/10/30 11:59:20
Done.
|
| +// |
| +class LargeIconCache : public KeyedService { |
| + public: |
| + explicit LargeIconCache(); |
|
sdefresne
2015/10/30 09:27:19
style: do not use "explicit" for constructor witho
justincohen
2015/10/30 11:59:20
Done.
|
| + ~LargeIconCache() override; |
| + |
| + // |LargeIconService| does everything on callbacks, and iOS needs to load the |
| + // icons immediately on page load. This caches the LargeIconResult so we can |
| + // immediately load. |
| + void SetCachedResult(const GURL url, const favicon_base::LargeIconResult&); |
|
sdefresne
2015/10/30 09:27:19
const GURL -> const GURL&
justincohen
2015/10/30 11:59:20
Done.
|
| + |
| + // Get a cached LargeIconResult. |
|
sdefresne
2015/10/30 09:27:19
s/Get/Returns/
justincohen
2015/10/30 11:59:20
Done.
|
| + scoped_ptr<favicon_base::LargeIconResult> GetCachedResult(const GURL& url); |
| + |
| + private: |
| + // Clone a LargeIconResult. |
|
sdefresne
2015/10/30 09:27:19
s/Clone/Clones/
justincohen
2015/10/30 11:59:21
Done.
|
| + scoped_ptr<favicon_base::LargeIconResult> CloneLargeIconResult( |
| + const favicon_base::LargeIconResult& large_icon_result); |
| + |
| + // Cache of LargeIconResult. |
| + struct CacheEntry { |
|
sdefresne
2015/10/30 09:27:19
Please forward-declare:
class LargeIconCacheEntry
justincohen
2015/10/30 11:59:20
Done.
|
| + CacheEntry(); |
| + ~CacheEntry(); |
| + |
| + scoped_ptr<favicon_base::LargeIconResult> result; |
| + }; |
| + |
| + base::OwningMRUCache<GURL, CacheEntry*> cache_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(LargeIconCache); |
| +}; |
| + |
| +#endif // IOS_CHROME_BROWSER_FAVICON_LARGE_ICON_CACHE_H_ |