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

Side by Side Diff: chrome/browser/android/thumbnail/scoped_ptr_expiring_cache.h

Issue 2244783005: Android: Don't evict thumbnails for last visible tab on stop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CHROME_BROWSER_ANDROID_THUMBNAIL_SCOPED_PTR_EXPIRING_CACHE_H_ 5 #ifndef CHROME_BROWSER_ANDROID_THUMBNAIL_SCOPED_PTR_EXPIRING_CACHE_H_
6 #define CHROME_BROWSER_ANDROID_THUMBNAIL_SCOPED_PTR_EXPIRING_CACHE_H_ 6 #define CHROME_BROWSER_ANDROID_THUMBNAIL_SCOPED_PTR_EXPIRING_CACHE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 20 matching lines...) Expand all
31 EvictIfFull(); 31 EvictIfFull();
32 } 32 }
33 33
34 Value* Get(const Key& key) { 34 Value* Get(const Key& key) {
35 iterator iter = map_.find(key); 35 iterator iter = map_.find(key);
36 if (iter != map_.end()) 36 if (iter != map_.end())
37 return iter->second; 37 return iter->second;
38 return NULL; 38 return NULL;
39 } 39 }
40 40
41 void Remove(const Key& key) { 41 std::unique_ptr<Value> Remove(const Key& key) {
42 iterator iter = map_.find(key); 42 iterator iter = map_.find(key);
43 std::unique_ptr<Value> value;
43 if (iter != map_.end()) { 44 if (iter != map_.end()) {
44 delete iter->second; 45 value.reset(iter->second);
45 map_.erase(key); 46 map_.erase(key);
46 } 47 }
48 return std::move(value);
47 } 49 }
48 50
49 void Clear() { 51 void Clear() {
50 for (iterator iter = map_.begin(); iter != map_.end(); iter++) { 52 for (iterator iter = map_.begin(); iter != map_.end(); iter++) {
51 delete iter->second; 53 delete iter->second;
52 } 54 }
53 map_.clear(); 55 map_.clear();
54 } 56 }
55 57
56 iterator begin() { return map_.begin(); } 58 iterator begin() { return map_.begin(); }
(...skipping 10 matching lines...) Expand all
67 } 69 }
68 } 70 }
69 71
70 size_t max_cache_size_; 72 size_t max_cache_size_;
71 LinkedHashMap map_; 73 LinkedHashMap map_;
72 74
73 DISALLOW_COPY_AND_ASSIGN(ScopedPtrExpiringCache); 75 DISALLOW_COPY_AND_ASSIGN(ScopedPtrExpiringCache);
74 }; 76 };
75 77
76 #endif // CHROME_BROWSER_ANDROID_THUMBNAIL_SCOPED_PTR_EXPIRING_CACHE_H_ 78 #endif // CHROME_BROWSER_ANDROID_THUMBNAIL_SCOPED_PTR_EXPIRING_CACHE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/thumbnail/thumbnail_cache.h » ('j') | chrome/browser/android/thumbnail/thumbnail_cache.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698