Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: components/dom_distiller/core/distilled_content_store.h

Issue 189833002: Add a DistilledContentStore (and an in-memory impl) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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,
shashi 2014/03/18 21:14:57 nit: Can this method be const? i.e. LoadContent ju
cjhopman 2014/04/11 22:37:21 Done.
27 LoadCallback callback) = 0;
28
29 virtual ~DistilledContentStore() {}
shashi 2014/03/18 21:14:57 DISALLOW_COPY_AND_ASSIGN(DistilledContentStore);
cjhopman 2014/04/11 22:37:21 Done.
30 };
31
32 class InMemoryContentStore : public DistilledContentStore {
33 public:
34 InMemoryContentStore();
35 virtual ~InMemoryContentStore();
36
37 // DistilledContentStore implementation
38 virtual void SaveContent(const ArticleEntry& entry,
39 const DistilledArticleProto& proto,
40 SaveCallback callback) OVERRIDE;
41 virtual void LoadContent(const ArticleEntry& entry,
42 LoadCallback callback) OVERRIDE;
43
44 // Synchronously saves the content.
45 void InjectContent(const ArticleEntry& entry,
46 const DistilledArticleProto& proto);
47
48 private:
49 typedef base::hash_map<std::string, DistilledArticleProto> ContentMap;
50 ContentMap cache_;
51 };
nyquist 2014/04/10 19:00:13 DISALLOW_COPY_AND_ASSIGN?
cjhopman 2014/04/11 22:37:21 Now disallowed in the base class.
52 } // dom_distiller
53
54 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698