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

Unified Diff: components/data_reduction_proxy/core/browser/data_usage_store.cc

Issue 2810393002: Fix memory issues with the Data Reduction proxy LevelDB (Closed)
Patch Set: ryan comments Created 3 years, 8 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 | « components/data_reduction_proxy/core/browser/data_store_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/data_reduction_proxy/core/browser/data_usage_store.cc
diff --git a/components/data_reduction_proxy/core/browser/data_usage_store.cc b/components/data_reduction_proxy/core/browser/data_usage_store.cc
index fb89dd096a4fd02641f3af48d077004e888aecd8..41f5fb6533208d9f9fa62063be15e68f9da0c45a 100644
--- a/components/data_reduction_proxy/core/browser/data_usage_store.cc
+++ b/components/data_reduction_proxy/core/browser/data_usage_store.cc
@@ -152,10 +152,16 @@ void DataUsageStore::StoreCurrentDataUsageBucket(
}
void DataUsageStore::DeleteHistoricalDataUsage() {
- for (int i = 0; i < kNumDataUsageBuckets; ++i)
- db_->Delete(DbKeyForBucketIndex(i));
+ std::string current_index_string;
+ DataStore::Status index_read_status =
+ db_->Get(kCurrentBucketIndexKey, &current_index_string);
+
+ // If the index doesn't exist, then no buckets have been written and the
+ // data usage doesn't need to be deleted.
+ if (index_read_status != DataStore::Status::OK)
+ return;
- db_->Delete(kCurrentBucketIndexKey);
+ db_->RecreateDB();
}
void DataUsageStore::DeleteBrowsingHistory(const base::Time& start,
« no previous file with comments | « components/data_reduction_proxy/core/browser/data_store_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698