| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "net/sdch/sdch_owner.h" | 5 #include "net/sdch/sdch_owner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/alias.h" | 8 #include "base/debug/alias.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" |
| 10 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/prefs/persistent_pref_store.h" | 12 #include "base/prefs/persistent_pref_store.h" |
| 12 #include "base/prefs/value_map_pref_store.h" | 13 #include "base/prefs/value_map_pref_store.h" |
| 13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 14 #include "base/time/default_clock.h" | 15 #include "base/time/default_clock.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "net/base/sdch_manager.h" | 17 #include "net/base/sdch_manager.h" |
| 17 #include "net/base/sdch_net_log_params.h" | 18 #include "net/base/sdch_net_log_params.h" |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 RecordDictionaryEvictionOrUnload(it.server_hash(), it.size(), new_uses, | 274 RecordDictionaryEvictionOrUnload(it.server_hash(), it.size(), new_uses, |
| 274 fate); | 275 fate); |
| 275 } | 276 } |
| 276 manager_->RemoveObserver(this); | 277 manager_->RemoveObserver(this); |
| 277 | 278 |
| 278 // This object only observes the external store during loading, | 279 // This object only observes the external store during loading, |
| 279 // i.e. before it's made the default preferences store. | 280 // i.e. before it's made the default preferences store. |
| 280 if (external_pref_store_) | 281 if (external_pref_store_) |
| 281 external_pref_store_->RemoveObserver(this); | 282 external_pref_store_->RemoveObserver(this); |
| 282 | 283 |
| 283 int64 object_lifetime = | 284 int64_t object_lifetime = (clock_->Now() - creation_time_).InMilliseconds(); |
| 284 (clock_->Now() - creation_time_).InMilliseconds(); | |
| 285 for (const auto& val : consumed_byte_seconds_) { | 285 for (const auto& val : consumed_byte_seconds_) { |
| 286 if (object_lifetime > 0) { | 286 if (object_lifetime > 0) { |
| 287 // Objects that are created and immediately destroyed don't add any memory | 287 // Objects that are created and immediately destroyed don't add any memory |
| 288 // pressure over time (and also cause a crash here). | 288 // pressure over time (and also cause a crash here). |
| 289 UMA_HISTOGRAM_MEMORY_KB("Sdch3.TimeWeightedMemoryUse", | 289 UMA_HISTOGRAM_MEMORY_KB("Sdch3.TimeWeightedMemoryUse", |
| 290 val / object_lifetime); | 290 val / object_lifetime); |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 | 293 |
| 294 } | 294 } |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 } | 711 } |
| 712 | 712 |
| 713 return true; | 713 return true; |
| 714 } | 714 } |
| 715 | 715 |
| 716 bool SdchOwner::IsPersistingDictionaries() const { | 716 bool SdchOwner::IsPersistingDictionaries() const { |
| 717 return in_memory_pref_store_.get() != nullptr; | 717 return in_memory_pref_store_.get() != nullptr; |
| 718 } | 718 } |
| 719 | 719 |
| 720 } // namespace net | 720 } // namespace net |
| OLD | NEW |