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 27 matching lines...) Expand all Loading... |
38 private: | 38 private: |
39 DISALLOW_COPY_AND_ASSIGN(DistilledContentStore); | 39 DISALLOW_COPY_AND_ASSIGN(DistilledContentStore); |
40 }; | 40 }; |
41 | 41 |
42 // This content store keeps up to |max_num_entries| of the last accessed items | 42 // This content store keeps up to |max_num_entries| of the last accessed items |
43 // in its cache. Both loading and saving content is counted as access. | 43 // in its cache. Both loading and saving content is counted as access. |
44 // Lookup can be done based on entry ID or URL. | 44 // Lookup can be done based on entry ID or URL. |
45 class InMemoryContentStore : public DistilledContentStore { | 45 class InMemoryContentStore : public DistilledContentStore { |
46 public: | 46 public: |
47 explicit InMemoryContentStore(const int max_num_entries); | 47 explicit InMemoryContentStore(const int max_num_entries); |
48 virtual ~InMemoryContentStore(); | 48 ~InMemoryContentStore() override; |
49 | 49 |
50 // DistilledContentStore implementation | 50 // DistilledContentStore implementation |
51 virtual void SaveContent(const ArticleEntry& entry, | 51 void SaveContent(const ArticleEntry& entry, |
52 const DistilledArticleProto& proto, | 52 const DistilledArticleProto& proto, |
53 SaveCallback callback) override; | 53 SaveCallback callback) override; |
54 virtual void LoadContent(const ArticleEntry& entry, | 54 void LoadContent(const ArticleEntry& entry, LoadCallback callback) override; |
55 LoadCallback callback) override; | |
56 | 55 |
57 // Synchronously saves the content. | 56 // Synchronously saves the content. |
58 void InjectContent(const ArticleEntry& entry, | 57 void InjectContent(const ArticleEntry& entry, |
59 const DistilledArticleProto& proto); | 58 const DistilledArticleProto& proto); |
60 | 59 |
61 private: | 60 private: |
62 // The CacheDeletor gets called when anything is removed from the ContentMap. | 61 // The CacheDeletor gets called when anything is removed from the ContentMap. |
63 class CacheDeletor { | 62 class CacheDeletor { |
64 public: | 63 public: |
65 explicit CacheDeletor(InMemoryContentStore* store); | 64 explicit CacheDeletor(InMemoryContentStore* store); |
(...skipping 14 matching lines...) Expand all Loading... |
80 InMemoryContentStore::CacheDeletor> ContentMap; | 79 InMemoryContentStore::CacheDeletor> ContentMap; |
81 typedef base::hash_map<std::string, std::string> UrlMap; | 80 typedef base::hash_map<std::string, std::string> UrlMap; |
82 | 81 |
83 ContentMap cache_; | 82 ContentMap cache_; |
84 UrlMap url_to_id_; | 83 UrlMap url_to_id_; |
85 }; | 84 }; |
86 | 85 |
87 } // dom_distiller | 86 } // dom_distiller |
88 | 87 |
89 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_ | 88 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_ |
OLD | NEW |