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

Unified Diff: components/dom_distiller/core/distilled_content_store.cc

Issue 1763273002: base: Remove OwningMRUCache in favor of scoped_ptrs in MRUCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + fix Created 4 years, 9 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
Index: components/dom_distiller/core/distilled_content_store.cc
diff --git a/components/dom_distiller/core/distilled_content_store.cc b/components/dom_distiller/core/distilled_content_store.cc
index 1cb1d9e79e379a502522ac6048f58feaf06fe27a..e6885cbd10e142fc62674d24dacbcd67fda734a7 100644
--- a/components/dom_distiller/core/distilled_content_store.cc
+++ b/components/dom_distiller/core/distilled_content_store.cc
@@ -9,8 +9,7 @@
namespace dom_distiller {
InMemoryContentStore::InMemoryContentStore(const int max_num_entries)
- : cache_(max_num_entries, CacheDeletor(this)) {
-}
+ : cache_(max_num_entries) {}
InMemoryContentStore::~InMemoryContentStore() {
// Clear the cache before destruction to ensure the CacheDeletor is not called
@@ -52,7 +51,7 @@ void InMemoryContentStore::LoadContent(
}
scoped_ptr<DistilledArticleProto> distilled_article;
if (success) {
- distilled_article.reset(new DistilledArticleProto(it->second));
+ distilled_article.reset(new DistilledArticleProto(*it->second));
} else {
distilled_article.reset(new DistilledArticleProto());
}
@@ -63,7 +62,9 @@ void InMemoryContentStore::LoadContent(
void InMemoryContentStore::InjectContent(const ArticleEntry& entry,
const DistilledArticleProto& proto) {
- cache_.Put(entry.entry_id(), proto);
+ cache_.Put(entry.entry_id(),
+ scoped_ptr<DistilledArticleProto, CacheDeletor>(
+ new DistilledArticleProto(proto), CacheDeletor(this)));
AddUrlToIdMapping(entry, proto);
}
@@ -96,11 +97,12 @@ InMemoryContentStore::CacheDeletor::~CacheDeletor() {
}
void InMemoryContentStore::CacheDeletor::operator()(
- const DistilledArticleProto& proto) {
+ DistilledArticleProto* proto) {
// When InMemoryContentStore is deleted, the |store_| pointer becomes invalid,
// but since the ContentMap is cleared in the InMemoryContentStore destructor,
// this should never be called after the destructor.
- store_->EraseUrlToIdMapping(proto);
+ store_->EraseUrlToIdMapping(*proto);
+ delete proto;
}
} // namespace dom_distiller

Powered by Google App Engine
This is Rietveld 408576698