OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
shashi
2014/03/13 00:32:45
2014
cjhopman
2014/03/18 16:06:10
Done.
| |
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_CACHE_H_ | |
shashi
2014/03/13 00:32:45
s/CACHE/STORE/
cjhopman
2014/03/18 16:06:10
Done.
| |
6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_ | |
7 | |
8 #include "base/bind.h" | |
9 #include "components/dom_distiller/core/article_entry.h" | |
10 #include "components/dom_distiller/core/proto/distilled_article.pb.h" | |
11 | |
12 namespace dom_distiller { | |
13 | |
14 // This is a simple interface for saving and loading of distilled content for an | |
15 // ArticleEntry. | |
16 class DistilledContentStore { | |
17 public: | |
18 typedef base::Callback< | |
19 void(bool /* success */, scoped_ptr<DistilledArticleProto>)> LoadCallback; | |
20 typedef base::Callback<void(bool /* success */)> SaveCallback; | |
21 | |
22 virtual void SaveContent(const ArticleEntry& entry, | |
23 const DistilledArticleProto& proto, | |
24 SaveCallback callback) = 0; | |
25 virtual void LoadContent(const ArticleEntry& entry, | |
26 LoadCallback callback) = 0; | |
27 | |
28 virtual ~DistilledContentStore() {} | |
29 }; | |
30 | |
31 class InMemoryContentStore : public DistilledContentStore { | |
32 public: | |
33 InMemoryContentStore(); | |
34 virtual ~InMemoryContentStore(); | |
35 | |
36 // DistilledContentStore implementation | |
37 virtual void SaveContent(const ArticleEntry& entry, | |
38 const DistilledArticleProto& proto, | |
39 SaveCallback callback) OVERRIDE; | |
40 virtual void LoadContent(const ArticleEntry& entry, | |
41 LoadCallback callback) OVERRIDE; | |
42 | |
43 // Synchronously saves the content. | |
44 void InjectContent(const ArticleEntry& entry, | |
45 const DistilledArticleProto& proto); | |
46 | |
47 private: | |
48 typedef std::map<std::string, DistilledArticleProto> ContentMap; | |
shashi
2014/03/13 00:32:45
why not base::hash_map?
cjhopman
2014/03/18 16:06:10
Done.
| |
49 ContentMap cache_; | |
50 }; | |
51 } // dom_distiller | |
52 | |
53 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_ | |
OLD | NEW |