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

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

Issue 302163005: Change InMemoryContentStore to use MRUCache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated tests for expiry and fixed lint errors. Created 6 years, 7 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 fa7b00247ba0a0bd873ff94c44163ef4176aa004..9a92920c75a8d57b60b33b9243b7e3122bf3db6e 100644
--- a/components/dom_distiller/core/distilled_content_store.cc
+++ b/components/dom_distiller/core/distilled_content_store.cc
@@ -8,8 +8,12 @@
namespace dom_distiller {
-InMemoryContentStore::InMemoryContentStore() {}
-InMemoryContentStore::~InMemoryContentStore() {}
+InMemoryContentStore::InMemoryContentStore(const int max_num_entries)
+ : cache_(max_num_entries) {
+}
+
+InMemoryContentStore::~InMemoryContentStore() {
+}
void InMemoryContentStore::SaveContent(
const ArticleEntry& entry,
@@ -24,11 +28,11 @@ void InMemoryContentStore::SaveContent(
void InMemoryContentStore::LoadContent(
const ArticleEntry& entry,
- InMemoryContentStore::LoadCallback callback) const {
+ InMemoryContentStore::LoadCallback callback) {
if (callback.is_null())
return;
- ContentMap::const_iterator it = cache_.find(entry.entry_id());
+ ContentMap::const_iterator it = cache_.Get(entry.entry_id());
bool success = it != cache_.end();
scoped_ptr<DistilledArticleProto> distilled_article;
if (success) {
@@ -43,7 +47,7 @@ void InMemoryContentStore::LoadContent(
void InMemoryContentStore::InjectContent(const ArticleEntry& entry,
const DistilledArticleProto& proto) {
- cache_[entry.entry_id()] = proto;
+ cache_.Put(entry.entry_id(), proto);
}
} // namespace dom_distiller

Powered by Google App Engine
This is Rietveld 408576698