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

Unified Diff: net/base/expiring_cache.h

Issue 11065052: [net] Add AsyncDNS.TTL histogram. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/host_cache.h » ('j') | net/base/host_cache.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/expiring_cache.h
diff --git a/net/base/expiring_cache.h b/net/base/expiring_cache.h
index fe2fc65a0d68d2f6b58da4ba5f06c2f37dd3a666..3cdf42deddae7e6c22d34f2b2e48d8e70deeaad9 100644
--- a/net/base/expiring_cache.h
+++ b/net/base/expiring_cache.h
@@ -120,11 +120,12 @@ class ExpiringCache {
return &it->second.first;
}
- // Updates or replaces the value associated with |key|.
- void Put(const KeyType& key,
- const ValueType& value,
- const ExpirationType& now,
- const ExpirationType& expiration) {
+ // Updates or replaces the value associated with |key|. Returns a pointer to
+ // the stored value.
+ ValueType* Put(const KeyType& key,
+ const ValueType& value,
+ const ExpirationType& now,
+ const ExpirationType& expiration) {
typename EntryMap::iterator it = entries_.find(key);
if (it == entries_.end()) {
// Compact the cache if it grew beyond the limit.
@@ -132,12 +133,13 @@ class ExpiringCache {
Compact(now);
// No existing entry. Creating a new one.
- entries_.insert(std::make_pair(key, Entry(value, expiration)));
+ it = entries_.insert(std::make_pair(key, Entry(value, expiration))).first;
} else {
// Update an existing cache entry.
it->second.first = value;
it->second.second = expiration;
}
+ return &it->second.first;
}
// Empties the cache.
« no previous file with comments | « no previous file | net/base/host_cache.h » ('j') | net/base/host_cache.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698