| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 virtual ~InMemoryContentStore(); |
| 49 | 49 |
| 50 // DistilledContentStore implementation | 50 // DistilledContentStore implementation |
| 51 virtual void SaveContent(const ArticleEntry& entry, | 51 virtual 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 virtual void LoadContent(const ArticleEntry& entry, |
| 55 LoadCallback callback) OVERRIDE; | 55 LoadCallback callback) override; |
| 56 | 56 |
| 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); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 80 InMemoryContentStore::CacheDeletor> ContentMap; | 80 InMemoryContentStore::CacheDeletor> ContentMap; |
| 81 typedef base::hash_map<std::string, std::string> UrlMap; | 81 typedef base::hash_map<std::string, std::string> UrlMap; |
| 82 | 82 |
| 83 ContentMap cache_; | 83 ContentMap cache_; |
| 84 UrlMap url_to_id_; | 84 UrlMap url_to_id_; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 } // dom_distiller | 87 } // dom_distiller |
| 88 | 88 |
| 89 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_ | 89 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_ |
| OLD | NEW |