OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_STORE_H_ | |
6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_STORE_H_ | |
7 | |
8 #include "base/bind.h" | |
9 #include "base/containers/hash_tables.h" | |
10 #include "components/dom_distiller/core/article_entry.h" | |
11 #include "components/dom_distiller/core/proto/distilled_article.pb.h" | |
12 | |
13 namespace dom_distiller { | |
14 | |
15 // This is a simple interface for saving and loading of distilled content for an | |
16 // ArticleEntry. | |
17 class DistilledContentStore { | |
18 public: | |
19 typedef base::Callback< | |
20 void(bool /* success */, scoped_ptr<DistilledArticleProto>)> LoadCallback; | |
21 typedef base::Callback<void(bool /* success */)> SaveCallback; | |
22 | |
23 virtual void SaveContent(const ArticleEntry& entry, | |
24 const DistilledArticleProto& proto, | |
25 SaveCallback callback) = 0; | |
26 virtual void LoadContent(const ArticleEntry& entry, | |
27 LoadCallback callback) const = 0; | |
28 | |
29 DistilledContentStore() {}; | |
30 virtual ~DistilledContentStore() {}; | |
31 private: | |
32 DISALLOW_COPY_AND_ASSIGN(DistilledContentStore); | |
33 }; | |
34 | |
35 class InMemoryContentStore : public DistilledContentStore { | |
nyquist
2014/04/14 22:42:22
This is very simple and nice for now. But this sto
| |
36 public: | |
37 InMemoryContentStore(); | |
38 virtual ~InMemoryContentStore(); | |
39 | |
40 // DistilledContentStore implementation | |
41 virtual void SaveContent(const ArticleEntry& entry, | |
42 const DistilledArticleProto& proto, | |
43 SaveCallback callback) OVERRIDE; | |
44 virtual void LoadContent(const ArticleEntry& entry, | |
45 LoadCallback callback) const OVERRIDE; | |
46 | |
47 // Synchronously saves the content. | |
48 void InjectContent(const ArticleEntry& entry, | |
49 const DistilledArticleProto& proto); | |
50 | |
51 private: | |
52 typedef base::hash_map<std::string, DistilledArticleProto> ContentMap; | |
53 ContentMap cache_; | |
54 }; | |
55 } // dom_distiller | |
56 | |
57 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_ | |
OLD | NEW |