Chromium Code Reviews| Index: base/memory/mru_cache.h |
| diff --git a/base/memory/mru_cache.h b/base/memory/mru_cache.h |
| index 434e5925e46bf92c3920cbb288eae55a92870ef8..6105c78a0e3c11651a86948f6b66d1340638697a 100644 |
| --- a/base/memory/mru_cache.h |
| +++ b/base/memory/mru_cache.h |
| @@ -150,6 +150,15 @@ class MRUCacheBase { |
| return reverse_iterator(Erase((++pos).base())); |
| } |
| + // Updates the |max_size_| of the cache to |new_max_size| and evicts entries, |
| + // if necessary, to satisfy the new maximum. |
| + void SetMaxSize(size_t new_max_size) { |
|
mmenke
2011/12/06 15:50:38
You're going to need a signoff from an owner of ba
James Simonsen
2011/12/06 19:57:49
Yeah, Will's an owner and he's already given LGTM
|
| + if (new_max_size < max_size_) { |
| + ShrinkToSize(new_max_size); |
| + } |
| + max_size_ = new_max_size; |
| + } |
| + |
| // Shrinks the cache so it only holds |new_size| items. If |new_size| is |
| // bigger or equal to the current number of items, this will do nothing. |
| void ShrinkToSize(size_type new_size) { |
| @@ -181,12 +190,12 @@ class MRUCacheBase { |
| // can keep them as you insert or delete things (as long as you don't delete |
| // the one you are pointing to) and they will still be valid. |
| iterator begin() { return ordering_.begin(); } |
| - const_iterator begin() const { ordering_.begin(); } |
| + const_iterator begin() const { return ordering_.begin(); } |
| iterator end() { return ordering_.end(); } |
| const_iterator end() const { return ordering_.end(); } |
| reverse_iterator rbegin() { return ordering_.rbegin(); } |
| - const_reverse_iterator rbegin() const { ordering_.rbegin(); } |
| + const_reverse_iterator rbegin() const { return ordering_.rbegin(); } |
| reverse_iterator rend() { return ordering_.rend(); } |
| const_reverse_iterator rend() const { return ordering_.rend(); } |