| 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 #ifndef COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_H_ | 5 #ifndef COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_H_ |
| 6 #define COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_H_ | 6 #define COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/ref_counted_memory.h" | 15 #include "base/memory/ref_counted_memory.h" |
| 16 #include "components/sync/api/attachments/attachment_id.h" | 16 #include "components/sync/api/attachments/attachment_id.h" |
| 17 #include "components/sync/base/sync_export.h" | |
| 18 | 17 |
| 19 namespace syncer { | 18 namespace syncer { |
| 20 | 19 |
| 21 // A blob of in-memory data attached to a sync item. | 20 // A blob of in-memory data attached to a sync item. |
| 22 // | 21 // |
| 23 // While Attachment objects themselves aren't immutable (they are assignable) | 22 // While Attachment objects themselves aren't immutable (they are assignable) |
| 24 // the data they wrap is immutable. | 23 // the data they wrap is immutable. |
| 25 // | 24 // |
| 26 // It is cheap to copy Attachments. Feel free to store and return by value. | 25 // It is cheap to copy Attachments. Feel free to store and return by value. |
| 27 class SYNC_EXPORT Attachment { | 26 class Attachment { |
| 28 public: | 27 public: |
| 29 Attachment(const Attachment& other); | 28 Attachment(const Attachment& other); |
| 30 ~Attachment(); | 29 ~Attachment(); |
| 31 | 30 |
| 32 // Default copy and assignment are welcome. | 31 // Default copy and assignment are welcome. |
| 33 | 32 |
| 34 // Creates an attachment with a unique id and the supplied data. | 33 // Creates an attachment with a unique id and the supplied data. |
| 35 // | 34 // |
| 36 // Used when creating a brand new attachment. | 35 // Used when creating a brand new attachment. |
| 37 static Attachment Create(const scoped_refptr<base::RefCountedMemory>& data); | 36 static Attachment Create(const scoped_refptr<base::RefCountedMemory>& data); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 63 Attachment(const AttachmentId& id, | 62 Attachment(const AttachmentId& id, |
| 64 const scoped_refptr<base::RefCountedMemory>& data); | 63 const scoped_refptr<base::RefCountedMemory>& data); |
| 65 }; | 64 }; |
| 66 | 65 |
| 67 typedef std::vector<syncer::Attachment> AttachmentList; | 66 typedef std::vector<syncer::Attachment> AttachmentList; |
| 68 typedef std::map<AttachmentId, Attachment> AttachmentMap; | 67 typedef std::map<AttachmentId, Attachment> AttachmentMap; |
| 69 | 68 |
| 70 } // namespace syncer | 69 } // namespace syncer |
| 71 | 70 |
| 72 #endif // COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_H_ | 71 #endif // COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_H_ |
| OLD | NEW |