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 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_STORE_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_STORE_H_ |
6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_STORE_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_STORE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // Synchronously saves the content. | 57 // Synchronously saves the content. |
58 void InjectContent(const ArticleEntry& entry, | 58 void InjectContent(const ArticleEntry& entry, |
59 const DistilledArticleProto& proto); | 59 const DistilledArticleProto& proto); |
60 | 60 |
61 private: | 61 private: |
62 // The CacheDeletor gets called when anything is removed from the ContentMap. | 62 // The CacheDeletor gets called when anything is removed from the ContentMap. |
63 class CacheDeletor { | 63 class CacheDeletor { |
64 public: | 64 public: |
65 explicit CacheDeletor(InMemoryContentStore* store); | 65 explicit CacheDeletor(InMemoryContentStore* store); |
66 ~CacheDeletor(); | 66 ~CacheDeletor(); |
67 void operator()(const DistilledArticleProto& proto); | 67 void operator()(DistilledArticleProto* proto); |
68 | 68 |
69 private: | 69 private: |
70 InMemoryContentStore* store_; | 70 InMemoryContentStore* store_; |
71 }; | 71 }; |
72 | 72 |
73 void AddUrlToIdMapping(const ArticleEntry& entry, | 73 void AddUrlToIdMapping(const ArticleEntry& entry, |
74 const DistilledArticleProto& proto); | 74 const DistilledArticleProto& proto); |
75 | 75 |
76 void EraseUrlToIdMapping(const DistilledArticleProto& proto); | 76 void EraseUrlToIdMapping(const DistilledArticleProto& proto); |
77 | 77 |
78 typedef base::MRUCacheBase<std::string, | 78 typedef base::MRUCache<std::string, |
79 DistilledArticleProto, | 79 scoped_ptr<DistilledArticleProto, CacheDeletor>> |
80 std::less<std::string>, | 80 |
81 InMemoryContentStore::CacheDeletor> | |
82 ContentMap; | 81 ContentMap; |
83 typedef base::hash_map<std::string, std::string> UrlMap; | 82 typedef base::hash_map<std::string, std::string> UrlMap; |
84 | 83 |
85 ContentMap cache_; | 84 ContentMap cache_; |
86 UrlMap url_to_id_; | 85 UrlMap url_to_id_; |
87 }; | 86 }; |
88 | 87 |
89 } // dom_distiller | 88 } // dom_distiller |
90 | 89 |
91 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_ | 90 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_ |
OLD | NEW |