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 SYNC_API_ATTACHMENTS_ATTACHMENT_H_ | 5 #ifndef SYNC_API_ATTACHMENTS_ATTACHMENT_H_ |
6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_H_ | 6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 public: | 27 public: |
28 ~Attachment(); | 28 ~Attachment(); |
29 | 29 |
30 // Default copy and assignment are welcome. | 30 // Default copy and assignment are welcome. |
31 | 31 |
32 // Creates an attachment with a unique id and the supplied data. | 32 // Creates an attachment with a unique id and the supplied data. |
33 // | 33 // |
34 // Used when creating a brand new attachment. | 34 // Used when creating a brand new attachment. |
35 static Attachment Create(const scoped_refptr<base::RefCountedMemory>& data); | 35 static Attachment Create(const scoped_refptr<base::RefCountedMemory>& data); |
36 | 36 |
37 // Creates an attachment with the supplied id, data and crc32c. | 37 // Creates an attachment with the supplied id and data. |
38 // | 38 // |
39 // Used when you want to recreate a specific attachment. E.g. creating a local | 39 // Used when you want to recreate a specific attachment. E.g. creating a local |
40 // copy of an attachment that already exists on the sync server. | 40 // copy of an attachment that already exists on the sync server. |
41 static Attachment CreateFromParts( | 41 static Attachment CreateFromParts( |
42 const AttachmentId& id, | 42 const AttachmentId& id, |
43 const scoped_refptr<base::RefCountedMemory>& data, | 43 const scoped_refptr<base::RefCountedMemory>& data); |
44 uint32_t crc32c); | |
45 | 44 |
46 // Returns this attachment's id. | 45 // Returns this attachment's id. |
47 const AttachmentId& GetId() const; | 46 const AttachmentId& GetId() const; |
48 | 47 |
49 // Returns this attachment's data. | 48 // Returns this attachment's data. |
50 const scoped_refptr<base::RefCountedMemory>& GetData() const; | 49 const scoped_refptr<base::RefCountedMemory>& GetData() const; |
51 | 50 |
52 // Returns precomputed crc32c hash of data. In ideal case this hash is | 51 // Returns precomputed crc32c hash of data. In ideal case this hash is |
53 // computed when attachment is first created. It is then passed around through | 52 // computed when attachment is first created. It is then passed around through |
54 // local attachment store and attachment server. Crc is verified when | 53 // local attachment store and attachment server. Crc is verified when |
55 // attachment is downloaded from server or loaded from local storage. | 54 // attachment is downloaded from server or loaded from local storage. |
56 uint32_t GetCrc32c() const; | 55 uint32_t GetCrc32c() const; |
57 | 56 |
58 private: | 57 private: |
59 AttachmentId id_; | 58 AttachmentId id_; |
60 scoped_refptr<base::RefCountedMemory> data_; | 59 scoped_refptr<base::RefCountedMemory> data_; |
61 uint32_t crc32c_; | |
62 | 60 |
63 Attachment(const AttachmentId& id, | 61 Attachment(const AttachmentId& id, |
64 const scoped_refptr<base::RefCountedMemory>& data, | 62 const scoped_refptr<base::RefCountedMemory>& data); |
65 uint32_t crc32c); | |
66 }; | 63 }; |
67 | 64 |
68 typedef std::vector<syncer::Attachment> AttachmentList; | 65 typedef std::vector<syncer::Attachment> AttachmentList; |
69 typedef std::map<AttachmentId, Attachment> AttachmentMap; | 66 typedef std::map<AttachmentId, Attachment> AttachmentMap; |
70 | 67 |
71 } // namespace syncer | 68 } // namespace syncer |
72 | 69 |
73 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_H_ | 70 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_H_ |
OLD | NEW |