Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / components / dom_distiller / core / article_attachments_data.h
blobc25df29bf9a66d725388172dc5d36a50f4e3fd66
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.
5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_ATTACHMENTS_DATA_H_
6 #define COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_ATTACHMENTS_DATA_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "components/dom_distiller/core/proto/distilled_article.pb.h"
12 #include "sync/api/attachments/attachment.h"
13 #include "sync/protocol/article_specifics.pb.h"
15 namespace dom_distiller {
17 // When stored, article attachments are split into two pieces, the actual data
18 // is stored by a set of ids in some attachment storage. The mapping of what
19 // each id corresponds to is stored in the ArticleEntry's
20 // sync_pb::ArticleAttachments. This class handles splitting into those two
21 // pieces (::CreateSyncAttachments) and reconstructing the data from the two
22 // pieces (::GetFromAttachmentMap and ::GetAttachmentIds). Outside of this
23 // class, the structure of sync_pb::ArticleAttachments (the id mapping) should
24 // be rather opaque.
25 class ArticleAttachmentsData {
26 public:
27 static scoped_ptr<ArticleAttachmentsData> GetFromAttachmentMap(
28 const sync_pb::ArticleAttachments& attachments_key,
29 const syncer::AttachmentMap& attachment_map);
31 // Creates sync attachments and the sync_pb::ArticleAttachments id map.
32 void CreateSyncAttachments(
33 syncer::AttachmentList* attachment_list,
34 sync_pb::ArticleAttachments* attachments_key) const;
36 const DistilledArticleProto& distilled_article() const {
37 return distilled_article_;
39 void set_distilled_article(const DistilledArticleProto& article) {
40 distilled_article_ = article;
43 std::string ToString() const;
44 private:
45 DistilledArticleProto distilled_article_;
48 syncer::AttachmentIdList GetAttachmentIds(
49 const sync_pb::ArticleAttachments& attachments);
51 } // namespace dom_distiller
53 #endif // COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_ATTACHMENTS_DATA_H_