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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/dom_distiller/core/distilled_content_store.h
diff --git a/components/dom_distiller/core/distilled_content_store.h b/components/dom_distiller/core/distilled_content_store.h
new file mode 100644
index 0000000000000000000000000000000000000000..b6b26956218e642e97e10c4b3d10e835f8d6e9ea
--- /dev/null
+++ b/components/dom_distiller/core/distilled_content_store.h
@@ -0,0 +1,53 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
shashi 2014/03/13 00:32:45 2014
cjhopman 2014/03/18 16:06:10 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#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.
+#define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_
+
+#include "base/bind.h"
+#include "components/dom_distiller/core/article_entry.h"
+#include "components/dom_distiller/core/proto/distilled_article.pb.h"
+
+namespace dom_distiller {
+
+// This is a simple interface for saving and loading of distilled content for an
+// ArticleEntry.
+class DistilledContentStore {
+ public:
+ typedef base::Callback<
+ void(bool /* success */, scoped_ptr<DistilledArticleProto>)> LoadCallback;
+ typedef base::Callback<void(bool /* success */)> SaveCallback;
+
+ virtual void SaveContent(const ArticleEntry& entry,
+ const DistilledArticleProto& proto,
+ SaveCallback callback) = 0;
+ virtual void LoadContent(const ArticleEntry& entry,
+ LoadCallback callback) = 0;
+
+ virtual ~DistilledContentStore() {}
+};
+
+class InMemoryContentStore : public DistilledContentStore {
+ public:
+ InMemoryContentStore();
+ virtual ~InMemoryContentStore();
+
+ // DistilledContentStore implementation
+ virtual void SaveContent(const ArticleEntry& entry,
+ const DistilledArticleProto& proto,
+ SaveCallback callback) OVERRIDE;
+ virtual void LoadContent(const ArticleEntry& entry,
+ LoadCallback callback) OVERRIDE;
+
+ // Synchronously saves the content.
+ void InjectContent(const ArticleEntry& entry,
+ const DistilledArticleProto& proto);
+
+ private:
+ 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.
+ ContentMap cache_;
+};
+} // dom_distiller
+
+#endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_CONTENT_CACHE_H_

Powered by Google App Engine
This is Rietveld 408576698