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

Unified Diff: components/dom_distiller/core/article_attachments_data.h

Issue 717793007: Add attachments support to DomDistillerStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « components/dom_distiller/core/BUILD.gn ('k') | components/dom_distiller/core/article_attachments_data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/dom_distiller/core/article_attachments_data.h
diff --git a/components/dom_distiller/core/article_attachments_data.h b/components/dom_distiller/core/article_attachments_data.h
new file mode 100644
index 0000000000000000000000000000000000000000..c25df29bf9a66d725388172dc5d36a50f4e3fd66
--- /dev/null
+++ b/components/dom_distiller/core/article_attachments_data.h
@@ -0,0 +1,53 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// 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_ARTICLE_ATTACHMENTS_DATA_H_
+#define COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_ATTACHMENTS_DATA_H_
+
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
+#include "components/dom_distiller/core/proto/distilled_article.pb.h"
+#include "sync/api/attachments/attachment.h"
+#include "sync/protocol/article_specifics.pb.h"
+
+namespace dom_distiller {
+
+// When stored, article attachments are split into two pieces, the actual data
+// is stored by a set of ids in some attachment storage. The mapping of what
+// each id corresponds to is stored in the ArticleEntry's
+// sync_pb::ArticleAttachments. This class handles splitting into those two
+// pieces (::CreateSyncAttachments) and reconstructing the data from the two
+// pieces (::GetFromAttachmentMap and ::GetAttachmentIds). Outside of this
+// class, the structure of sync_pb::ArticleAttachments (the id mapping) should
+// be rather opaque.
+class ArticleAttachmentsData {
+ public:
+ static scoped_ptr<ArticleAttachmentsData> GetFromAttachmentMap(
+ const sync_pb::ArticleAttachments& attachments_key,
+ const syncer::AttachmentMap& attachment_map);
+
+ // Creates sync attachments and the sync_pb::ArticleAttachments id map.
+ void CreateSyncAttachments(
+ syncer::AttachmentList* attachment_list,
+ sync_pb::ArticleAttachments* attachments_key) const;
+
+ const DistilledArticleProto& distilled_article() const {
+ return distilled_article_;
+ }
+ void set_distilled_article(const DistilledArticleProto& article) {
+ distilled_article_ = article;
+ }
+
+ std::string ToString() const;
+ private:
+ DistilledArticleProto distilled_article_;
+};
+
+syncer::AttachmentIdList GetAttachmentIds(
+ const sync_pb::ArticleAttachments& attachments);
+
+} // namespace dom_distiller
+
+#endif // COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_ATTACHMENTS_DATA_H_
« no previous file with comments | « components/dom_distiller/core/BUILD.gn ('k') | components/dom_distiller/core/article_attachments_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698