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

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

Issue 1763273002: base: Remove OwningMRUCache in favor of scoped_ptrs in MRUCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + fix Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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 #include "ios/chrome/browser/favicon/large_icon_cache.h" 5 #include "ios/chrome/browser/favicon/large_icon_cache.h"
6 6
7 #include "components/favicon_base/fallback_icon_style.h" 7 #include "components/favicon_base/fallback_icon_style.h"
8 #include "components/favicon_base/favicon_types.h" 8 #include "components/favicon_base/favicon_types.h"
9 #include "url/gurl.h" 9 #include "url/gurl.h"
10 10
(...skipping 10 matching lines...) Expand all
21 scoped_ptr<favicon_base::LargeIconResult> result; 21 scoped_ptr<favicon_base::LargeIconResult> result;
22 }; 22 };
23 23
24 LargeIconCache::LargeIconCache() : cache_(kMaxCacheSize) {} 24 LargeIconCache::LargeIconCache() : cache_(kMaxCacheSize) {}
25 25
26 LargeIconCache::~LargeIconCache() {} 26 LargeIconCache::~LargeIconCache() {}
27 27
28 void LargeIconCache::SetCachedResult( 28 void LargeIconCache::SetCachedResult(
29 const GURL& url, 29 const GURL& url,
30 const favicon_base::LargeIconResult& result) { 30 const favicon_base::LargeIconResult& result) {
31 LargeIconCacheEntry* entry = new LargeIconCacheEntry; 31 scoped_ptr<LargeIconCacheEntry> entry(new LargeIconCacheEntry);
32 entry->result = CloneLargeIconResult(result); 32 entry->result = CloneLargeIconResult(result);
33 cache_.Put(url, entry); 33 cache_.Put(url, std::move(entry));
34 } 34 }
35 35
36 scoped_ptr<favicon_base::LargeIconResult> LargeIconCache::GetCachedResult( 36 scoped_ptr<favicon_base::LargeIconResult> LargeIconCache::GetCachedResult(
37 const GURL& url) { 37 const GURL& url) {
38 auto iter = cache_.Get(url); 38 auto iter = cache_.Get(url);
39 if (iter != cache_.end()) { 39 if (iter != cache_.end()) {
40 DCHECK(iter->second->result); 40 DCHECK(iter->second->result);
41 return CloneLargeIconResult(*iter->second->result.get()); 41 return CloneLargeIconResult(*iter->second->result.get());
42 } 42 }
43 43
44 return scoped_ptr<favicon_base::LargeIconResult>(); 44 return scoped_ptr<favicon_base::LargeIconResult>();
45 } 45 }
46 46
47 scoped_ptr<favicon_base::LargeIconResult> LargeIconCache::CloneLargeIconResult( 47 scoped_ptr<favicon_base::LargeIconResult> LargeIconCache::CloneLargeIconResult(
48 const favicon_base::LargeIconResult& large_icon_result) { 48 const favicon_base::LargeIconResult& large_icon_result) {
49 scoped_ptr<favicon_base::LargeIconResult> clone; 49 scoped_ptr<favicon_base::LargeIconResult> clone;
50 if (large_icon_result.bitmap.is_valid()) { 50 if (large_icon_result.bitmap.is_valid()) {
51 clone.reset(new favicon_base::LargeIconResult(large_icon_result.bitmap)); 51 clone.reset(new favicon_base::LargeIconResult(large_icon_result.bitmap));
52 } else { 52 } else {
53 clone.reset( 53 clone.reset(
54 new favicon_base::LargeIconResult(new favicon_base::FallbackIconStyle( 54 new favicon_base::LargeIconResult(new favicon_base::FallbackIconStyle(
55 *large_icon_result.fallback_icon_style.get()))); 55 *large_icon_result.fallback_icon_style.get())));
56 } 56 }
57 return clone; 57 return clone;
58 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698