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

Unified 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: Fix nits for unit test Created 5 years, 2 months 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 side-by-side diff with in-line comments
Download patch
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..67abec9d7c796ed04964bd35f99505129bb34cb0
--- /dev/null
+++ b/ios/chrome/browser/favicon/large_icon_cache.h
@@ -0,0 +1,55 @@
+// 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"
+
+class GURL;
+struct LargeIconCacheEntry;
+
+namespace favicon_base {
+struct LargeIconResult;
+}
+
+namespace ios {
+class ChromeBrowserState;
+}
+
+// Provides a cache of most recently used LargeIconResult.
+//
+// Example usage:
+// LargeIconCache* large_icon_cache =
+// IOSChromeLargeIconServiceFactory::GetForBrowserState(browser_state);
+// scoped_ptr<favicon_base::LargeIconResult> icon =
+// large_icon_cache->GetCachedResult(...);
+//
+class LargeIconCache : public KeyedService {
noyau (Ping after 24h) 2015/10/30 23:22:31 I would expect some tests for this class.
justincohen 2015/10/31 03:54:21 I will add this in a followup CL.
+ public:
+ LargeIconCache();
+ ~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&);
+
+ // Returns a cached LargeIconResult.
+ scoped_ptr<favicon_base::LargeIconResult> GetCachedResult(const GURL& url);
+
+ private:
+ // Clones a LargeIconResult.
+ scoped_ptr<favicon_base::LargeIconResult> CloneLargeIconResult(
+ const favicon_base::LargeIconResult& large_icon_result);
+
+ base::OwningMRUCache<GURL, LargeIconCacheEntry*> cache_;
noyau (Ping after 24h) 2015/10/30 23:22:31 You cache all those images in memory? From our exp
justincohen 2015/10/31 03:54:21 The NTP slide-in animation needs the images loaded
+
+ DISALLOW_COPY_AND_ASSIGN(LargeIconCache);
+};
+
+#endif // IOS_CHROME_BROWSER_FAVICON_LARGE_ICON_CACHE_H_

Powered by Google App Engine
This is Rietveld 408576698