OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/dom_distiller/core/article_attachments_data.h" | 5 #include "components/dom_distiller/core/article_attachments_data.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace dom_distiller { | 9 namespace dom_distiller { |
10 | 10 |
11 syncer::AttachmentIdList GetAttachmentIds( | 11 syncer::AttachmentIdList GetAttachmentIds( |
12 const sync_pb::ArticleAttachments& attachments) { | 12 const sync_pb::ArticleAttachments& attachments) { |
13 syncer::AttachmentIdList ids; | 13 syncer::AttachmentIdList ids; |
14 ids.push_back( | 14 ids.push_back( |
15 syncer::AttachmentId::CreateFromProto(attachments.distilled_article())); | 15 syncer::AttachmentId::CreateFromProto(attachments.distilled_article())); |
16 return ids; | 16 return ids; |
17 } | 17 } |
18 | 18 |
19 scoped_ptr<ArticleAttachmentsData> ArticleAttachmentsData::GetFromAttachmentMap( | 19 std::unique_ptr<ArticleAttachmentsData> |
| 20 ArticleAttachmentsData::GetFromAttachmentMap( |
20 const sync_pb::ArticleAttachments& attachments_key, | 21 const sync_pb::ArticleAttachments& attachments_key, |
21 const syncer::AttachmentMap& attachment_map) { | 22 const syncer::AttachmentMap& attachment_map) { |
22 scoped_ptr<ArticleAttachmentsData> data(new ArticleAttachmentsData); | 23 std::unique_ptr<ArticleAttachmentsData> data(new ArticleAttachmentsData); |
23 syncer::AttachmentMap::const_iterator iter = | 24 syncer::AttachmentMap::const_iterator iter = |
24 attachment_map.find(syncer::AttachmentId::CreateFromProto( | 25 attachment_map.find(syncer::AttachmentId::CreateFromProto( |
25 attachments_key.distilled_article())); | 26 attachments_key.distilled_article())); |
26 CHECK(iter != attachment_map.end()); | 27 CHECK(iter != attachment_map.end()); |
27 scoped_refptr<base::RefCountedMemory> attachment_bytes = | 28 scoped_refptr<base::RefCountedMemory> attachment_bytes = |
28 iter->second.GetData(); | 29 iter->second.GetData(); |
29 data->distilled_article_.ParseFromArray(attachment_bytes->front(), | 30 data->distilled_article_.ParseFromArray(attachment_bytes->front(), |
30 attachment_bytes->size()); | 31 attachment_bytes->size()); |
31 return data; | 32 return data; |
32 } | 33 } |
(...skipping 10 matching lines...) Expand all Loading... |
43 *attachments_key->mutable_distilled_article() = | 44 *attachments_key->mutable_distilled_article() = |
44 attachment.GetId().GetProto(); | 45 attachment.GetId().GetProto(); |
45 attachment_list->push_back(attachment); | 46 attachment_list->push_back(attachment); |
46 } | 47 } |
47 | 48 |
48 std::string ArticleAttachmentsData::ToString() const { | 49 std::string ArticleAttachmentsData::ToString() const { |
49 return distilled_article_.SerializeAsString(); | 50 return distilled_article_.SerializeAsString(); |
50 } | 51 } |
51 | 52 |
52 } // namespace dom_distiller | 53 } // namespace dom_distiller |
OLD | NEW |