Index: net/sdch/sdch_owner.cc |
diff --git a/net/sdch/sdch_owner.cc b/net/sdch/sdch_owner.cc |
index b0e440569646d0aa8ebd30d2a9ea05297a766b9c..de1643b2a90f1a6605fb39870ec50098249033f0 100644 |
--- a/net/sdch/sdch_owner.cc |
+++ b/net/sdch/sdch_owner.cc |
@@ -6,6 +6,7 @@ |
#include "base/bind.h" |
#include "base/metrics/histogram_macros.h" |
+#include "base/strings/string_util.h" |
#include "base/time/default_clock.h" |
#include "net/base/sdch_manager.h" |
#include "net/base/sdch_net_log_params.h" |
@@ -86,22 +87,34 @@ SdchOwner::SdchOwner(net::SdchManager* sdch_manager, |
clock_(new base::DefaultClock), |
max_total_dictionary_size_(kMaxTotalDictionarySize), |
min_space_for_dictionary_fetch_(kMinSpaceForDictionaryFetch), |
+#if defined(OS_CHROMEOS) |
+ // For debugging http://crbug.com/454198; remove when resolved. |
+ destroyed_(0), |
+#endif |
memory_pressure_listener_( |
base::Bind(&SdchOwner::OnMemoryPressure, |
// Because |memory_pressure_listener_| is owned by |
// SdchOwner, the SdchOwner object will be available |
// for the lifetime of |memory_pressure_listener_|. |
base::Unretained(this))) { |
+ // For debugging http://crbug.com/454198; remove when resolved. |
+ AssertNotDestroyedAndClockNotNull(__LINE__, GURL()); |
manager_->AddObserver(this); |
} |
SdchOwner::~SdchOwner() { |
+ // For debugging http://crbug.com/454198; remove when resolved. |
+ AssertNotDestroyedAndClockNotNull(__LINE__, GURL()); |
+ |
for (auto it = local_dictionary_info_.begin(); |
it != local_dictionary_info_.end(); ++it) { |
RecordDictionaryEviction(it->second.use_count, |
DICTIONARY_FATE_EVICT_FOR_DESTRUCTION); |
} |
manager_->RemoveObserver(this); |
+#if defined(OS_CHROMEOS) |
+ destroyed_ = 0xdeadbeef; |
+#endif |
} |
void SdchOwner::SetMaxTotalDictionarySize(size_t max_total_dictionary_size) { |
@@ -138,6 +151,9 @@ void SdchOwner::OnDictionaryFetched(const std::string& dictionary_text, |
} |
}; |
+ // For debugging http://crbug.com/454198; remove when resolved. |
+ AssertNotDestroyedAndClockNotNull(__LINE__, dictionary_url); |
mmenke
2015/02/20 17:30:09
Sorry, I really wasn't thinking when I signed off.
|
+ |
std::vector<DictionaryItem> stale_dictionary_list; |
size_t recoverable_bytes = 0; |
base::Time stale_boundary(clock_->Now() - base::TimeDelta::FromDays(1)); |
@@ -151,6 +167,9 @@ void SdchOwner::OnDictionaryFetched(const std::string& dictionary_text, |
} |
} |
+ // For debugging http://crbug.com/454198; remove when resolved. |
+ AssertNotDestroyedAndClockNotNull(__LINE__, dictionary_url); |
+ |
if (total_dictionary_bytes_ + dictionary_text.size() - recoverable_bytes > |
max_total_dictionary_size_) { |
RecordDictionaryFate(DICTIONARY_FATE_FETCH_IGNORED_NO_SPACE); |
@@ -198,6 +217,9 @@ void SdchOwner::OnDictionaryFetched(const std::string& dictionary_text, |
// to avoid taking too much time/space with useless dictionaries/one-off |
// visits to web sites. |
clock_->Now() - base::TimeDelta::FromHours(23), dictionary_text.size()); |
+ |
+ // For debugging http://crbug.com/454198; remove when resolved. |
+ AssertNotDestroyedAndClockNotNull(__LINE__, dictionary_url); |
} |
void SdchOwner::OnDictionaryUsed(SdchManager* manager, |
@@ -212,6 +234,9 @@ void SdchOwner::OnDictionaryUsed(SdchManager* manager, |
void SdchOwner::OnGetDictionary(net::SdchManager* manager, |
const GURL& request_url, |
const GURL& dictionary_url) { |
+ // For debugging http://crbug.com/454198; remove when resolved. |
+ AssertNotDestroyedAndClockNotNull(__LINE__, dictionary_url); |
+ |
base::Time stale_boundary(clock_->Now() - base::TimeDelta::FromDays(1)); |
size_t avail_bytes = 0; |
for (auto it = local_dictionary_info_.begin(); |
@@ -245,6 +270,9 @@ void SdchOwner::OnClearDictionaries(net::SdchManager* manager) { |
void SdchOwner::SetClockForTesting(scoped_ptr<base::Clock> clock) { |
clock_ = clock.Pass(); |
+ |
+ // For debugging http://crbug.com/454198; remove when resolved. |
+ AssertNotDestroyedAndClockNotNull(__LINE__, GURL()); |
} |
void SdchOwner::OnMemoryPressure( |
@@ -262,4 +290,19 @@ void SdchOwner::OnMemoryPressure( |
manager_->ClearData(); |
} |
+// For debugging http://crbug.com/454198; remove when resolved. |
+#if defined(OS_CHROMEOS) |
+void SdchOwner::AssertNotDestroyedAndClockNotNull(int line, const GURL& url) { |
+ if (destroyed_ != 0u || clock_.get() == nullptr) { |
+ char url_buf[128]; |
+ base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); |
+ CHECK(false) << "454198 test tripped on line " << line << ", destroyed " |
+ << destroyed_ << ", clock " << clock_.get(); |
+ } |
+} |
+#else |
+void SdchOwner::AssertNotDestroyedAndClockNotNull(int line, const GURL& url) { |
+} |
+#endif |
+ |
} // namespace net |