Index: net/sdch/sdch_owner.cc |
diff --git a/net/sdch/sdch_owner.cc b/net/sdch/sdch_owner.cc |
index 9d985816a9e0350e3930b7c17e7f4f0fdbb85630..306f2a94311fff891c9f3879b97eee487f0070ef 100644 |
--- a/net/sdch/sdch_owner.cc |
+++ b/net/sdch/sdch_owner.cc |
@@ -10,6 +10,7 @@ |
#include "base/metrics/histogram_macros.h" |
#include "base/prefs/persistent_pref_store.h" |
#include "base/prefs/value_map_pref_store.h" |
+#include "base/process/process_info.h" |
#include "base/strings/string_util.h" |
#include "base/time/default_clock.h" |
#include "base/values.h" |
@@ -310,6 +311,7 @@ SdchOwner::~SdchOwner() { |
DICTIONARY_FATE_UNLOAD_FOR_DESTRUCTION : |
DICTIONARY_FATE_EVICT_FOR_DESTRUCTION; |
RecordDictionaryEvictionOrUnload(new_uses, fate); |
+ RecordDictionaryLifetime(it.server_hash(), it.size()); |
} |
manager_->RemoveObserver(this); |
@@ -351,6 +353,7 @@ void SdchOwner::OnDictionaryFetched(base::Time last_used, |
std::string server_hash; |
int use_count; |
size_t dictionary_size; |
+ base::Time load_time; |
Randy Smith (Not in Mondays)
2015/04/03 16:08:18
??
Elly Fong-Jones
2015/04/03 20:24:23
Done.
|
DictionaryItem() : use_count(0), dictionary_size(0) {} |
DictionaryItem(const base::Time& last_used, |
@@ -452,6 +455,7 @@ void SdchOwner::OnDictionaryFetched(base::Time last_used, |
use_counts_at_load_[stale_it->server_hash]; |
RecordDictionaryEvictionOrUnload(new_uses, |
DICTIONARY_FATE_EVICT_FOR_DICT); |
+ RecordDictionaryLifetime(stale_it->server_hash, stale_it->dictionary_size); |
++stale_it; |
} |
@@ -487,6 +491,7 @@ void SdchOwner::OnDictionaryFetched(base::Time last_used, |
dictionary_description->SetInteger(kDictionarySizeKey, |
dictionary_text.size()); |
pref_dictionary_map->Set(server_hash, dictionary_description.Pass()); |
+ load_times_[server_hash] = clock_->Now(); |
} |
void SdchOwner::OnDictionaryUsed(SdchManager* manager, |
@@ -780,4 +785,16 @@ bool SdchOwner::IsPersistingDictionaries() const { |
return in_memory_pref_store_.get() != nullptr; |
} |
+void SdchOwner::RecordDictionaryLifetime(const std::string& server_hash, |
+ size_t size) { |
+ DCHECK(load_times_.count(server_hash) == 1); |
+ base::Time now = clock_->Now(); |
+ base::TimeDelta dict_lifetime = now - load_times_[server_hash]; |
+ base::TimeDelta process_lifetime = now - |
+ base::CurrentProcessInfo::CreationTime(); |
Randy Smith (Not in Mondays)
2015/04/03 16:08:18
I'm not sure this is the right value. Specificall
Elly Fong-Jones
2015/04/03 20:24:23
Done.
|
+ int64 frac = (size * dict_lifetime.InMilliseconds()) / |
+ process_lifetime.InMilliseconds(); |
+ UMA_HISTOGRAM_COUNTS("Sdch3.TimeWeightedMemoryUse", frac); |
+} |
+ |
} // namespace net |