Index: chrome/common/instant_restricted_id_cache.h |
diff --git a/chrome/common/instant_restricted_id_cache.h b/chrome/common/instant_restricted_id_cache.h |
index 66ae060a754be541c57df73a9230ad069c903ab8..1ca09ebffb77c116d9505273cf0ba2900440e330 100644 |
--- a/chrome/common/instant_restricted_id_cache.h |
+++ b/chrome/common/instant_restricted_id_cache.h |
@@ -68,6 +68,7 @@ class InstantRestrictedIDCache { |
FRIEND_TEST_ALL_PREFIXES(InstantRestrictedIDCacheTest, CrazyIDGeneration); |
FRIEND_TEST_ALL_PREFIXES(InstantRestrictedIDCacheTest, ManualIDGeneration); |
FRIEND_TEST_ALL_PREFIXES(InstantRestrictedIDCacheTest, MixIDGeneration); |
+ FRIEND_TEST_ALL_PREFIXES(InstantRestrictedIDCacheTest, AddEmptySet); |
typedef base::MRUCache<InstantRestrictedID, T> CacheImpl; |
@@ -92,9 +93,14 @@ InstantRestrictedIDCache<T>::~InstantRestrictedIDCache() { |
template <typename T> |
void InstantRestrictedIDCache<T>::AddItems(const ItemVector& items) { |
- if (items.size() == 0 || items.size() > cache_.max_size()) |
+ if (items.size() > cache_.max_size()) |
return; |
brettw
2013/03/25 22:26:52
I'm wondering about this. If you add too many item
sreeram
2013/03/25 22:29:33
Adding too many items would be an error situation,
brettw
2013/03/25 22:34:04
Yeah, I like the dcheck.
sreeram
2013/03/25 22:39:26
Done.
|
+ if (items.empty()) { |
+ last_add_start_ = cache_.rend(); |
+ return; |
+ } |
+ |
for (size_t i = 0; i < items.size(); ++i) { |
InstantRestrictedID id = ++last_restricted_id_; |
cache_.Put(id, items[i]); |
@@ -106,9 +112,14 @@ void InstantRestrictedIDCache<T>::AddItems(const ItemVector& items) { |
template <typename T> |
void InstantRestrictedIDCache<T>::AddItemsWithRestrictedID( |
const ItemIDVector& items) { |
- if (items.size() == 0 || items.size() > cache_.max_size()) |
+ if (items.size() > cache_.max_size()) |
return; |
+ if (items.empty()) { |
+ last_add_start_ = cache_.rend(); |
+ return; |
+ } |
+ |
std::set<InstantRestrictedID> ids_added; |
for (size_t i = 0; i < items.size(); ++i) { |
const ItemIDPair& item_id = items[i]; |