OLD | NEW |
(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_ARTICLE_ATTACHMENTS_DATA_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_ATTACHMENTS_DATA_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 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" |
| 14 |
| 15 namespace dom_distiller { |
| 16 |
| 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); |
| 30 |
| 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; |
| 35 |
| 36 const DistilledArticleProto& distilled_article() const { |
| 37 return distilled_article_; |
| 38 } |
| 39 void set_distilled_article(const DistilledArticleProto& article) { |
| 40 distilled_article_ = article; |
| 41 } |
| 42 |
| 43 std::string ToString() const; |
| 44 private: |
| 45 DistilledArticleProto distilled_article_; |
| 46 }; |
| 47 |
| 48 syncer::AttachmentIdList GetAttachmentIds( |
| 49 const sync_pb::ArticleAttachments& attachments); |
| 50 |
| 51 } // namespace dom_distiller |
| 52 |
| 53 #endif // COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_ATTACHMENTS_DATA_H_ |
OLD | NEW |