| OLD | NEW |
| 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 #import "ios/chrome/browser/snapshots/lru_cache.h" | 5 #import "ios/chrome/browser/snapshots/lru_cache.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> |
| 10 |
| 9 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 10 #include "base/containers/mru_cache.h" | 12 #include "base/containers/mru_cache.h" |
| 11 #include "base/mac/scoped_nsobject.h" | 13 #include "base/mac/scoped_nsobject.h" |
| 12 #include "base/macros.h" | 14 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 struct NSObjectEqualTo { | 18 struct NSObjectEqualTo { |
| 18 bool operator()(const base::scoped_nsprotocol<id<NSObject>>& obj1, | 19 bool operator()(const base::scoped_nsprotocol<id<NSObject>>& obj1, |
| 19 const base::scoped_nsprotocol<id<NSObject>>& obj2) const { | 20 const base::scoped_nsprotocol<id<NSObject>>& obj2) const { |
| 20 return [obj1 isEqual:obj2]; | 21 return [obj1 isEqual:obj2]; |
| 21 } | 22 } |
| 22 }; | 23 }; |
| 23 | 24 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 49 explicit NSObjectMRUCache(typename ParentType::size_type max_size) | 50 explicit NSObjectMRUCache(typename ParentType::size_type max_size) |
| 50 : ParentType(max_size) {} | 51 : ParentType(max_size) {} |
| 51 | 52 |
| 52 private: | 53 private: |
| 53 DISALLOW_COPY_AND_ASSIGN(NSObjectMRUCache); | 54 DISALLOW_COPY_AND_ASSIGN(NSObjectMRUCache); |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 } // namespace | 57 } // namespace |
| 57 | 58 |
| 58 @implementation LRUCache { | 59 @implementation LRUCache { |
| 59 scoped_ptr<NSObjectMRUCache> _cache; | 60 std::unique_ptr<NSObjectMRUCache> _cache; |
| 60 } | 61 } |
| 61 | 62 |
| 62 @synthesize maxCacheSize = _maxCacheSize; | 63 @synthesize maxCacheSize = _maxCacheSize; |
| 63 | 64 |
| 64 - (instancetype)init { | 65 - (instancetype)init { |
| 65 NOTREACHED(); // Use initWithCacheSize: instead. | 66 NOTREACHED(); // Use initWithCacheSize: instead. |
| 66 return nil; | 67 return nil; |
| 67 } | 68 } |
| 68 | 69 |
| 69 - (instancetype)initWithCacheSize:(NSUInteger)maxCacheSize { | 70 - (instancetype)initWithCacheSize:(NSUInteger)maxCacheSize { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 103 |
| 103 - (NSUInteger)count { | 104 - (NSUInteger)count { |
| 104 return _cache->size(); | 105 return _cache->size(); |
| 105 } | 106 } |
| 106 | 107 |
| 107 - (BOOL)isEmpty { | 108 - (BOOL)isEmpty { |
| 108 return _cache->empty(); | 109 return _cache->empty(); |
| 109 } | 110 } |
| 110 | 111 |
| 111 @end | 112 @end |
| OLD | NEW |