| 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_ID_H_ | 5 #ifndef COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_ID_H_ |
| 6 #define COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_ID_H_ | 6 #define COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_ID_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "components/sync/base/immutable.h" | 15 #include "components/sync/base/immutable.h" |
| 16 #include "components/sync/base/sync_export.h" | |
| 17 | 16 |
| 18 namespace sync_pb { | 17 namespace sync_pb { |
| 19 class AttachmentIdProto; | 18 class AttachmentIdProto; |
| 20 } // namespace sync_pb | 19 } // namespace sync_pb |
| 21 | 20 |
| 22 namespace syncer { | 21 namespace syncer { |
| 23 | 22 |
| 24 // Uniquely identifies an attachment. | 23 // Uniquely identifies an attachment. |
| 25 // | 24 // |
| 26 // Two attachments with equal (operator==) AttachmentIds are considered | 25 // Two attachments with equal (operator==) AttachmentIds are considered |
| 27 // equivalent. | 26 // equivalent. |
| 28 class SYNC_EXPORT AttachmentId { | 27 class AttachmentId { |
| 29 public: | 28 public: |
| 30 AttachmentId(const AttachmentId& other); | 29 AttachmentId(const AttachmentId& other); |
| 31 ~AttachmentId(); | 30 ~AttachmentId(); |
| 32 | 31 |
| 33 // Default copy and assignment are welcome. | 32 // Default copy and assignment are welcome. |
| 34 | 33 |
| 35 bool operator==(const AttachmentId& other) const; | 34 bool operator==(const AttachmentId& other) const; |
| 36 | 35 |
| 37 bool operator!=(const AttachmentId& other) const; | 36 bool operator!=(const AttachmentId& other) const; |
| 38 | 37 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 53 | 52 |
| 54 // Returns the size (in bytes) the attachment. | 53 // Returns the size (in bytes) the attachment. |
| 55 size_t GetSize() const; | 54 size_t GetSize() const; |
| 56 | 55 |
| 57 // Returns the crc32c the attachment. | 56 // Returns the crc32c the attachment. |
| 58 uint32_t GetCrc32c() const; | 57 uint32_t GetCrc32c() const; |
| 59 | 58 |
| 60 private: | 59 private: |
| 61 // Necessary since we forward-declare sync_pb::AttachmentIdProto; see comments | 60 // Necessary since we forward-declare sync_pb::AttachmentIdProto; see comments |
| 62 // in immutable.h. | 61 // in immutable.h. |
| 63 struct SYNC_EXPORT ImmutableAttachmentIdProtoTraits { | 62 struct ImmutableAttachmentIdProtoTraits { |
| 64 typedef sync_pb::AttachmentIdProto* Wrapper; | 63 typedef sync_pb::AttachmentIdProto* Wrapper; |
| 65 static void InitializeWrapper(Wrapper* wrapper); | 64 static void InitializeWrapper(Wrapper* wrapper); |
| 66 static void DestroyWrapper(Wrapper* wrapper); | 65 static void DestroyWrapper(Wrapper* wrapper); |
| 67 static const sync_pb::AttachmentIdProto& Unwrap(const Wrapper& wrapper); | 66 static const sync_pb::AttachmentIdProto& Unwrap(const Wrapper& wrapper); |
| 68 static sync_pb::AttachmentIdProto* UnwrapMutable(Wrapper* wrapper); | 67 static sync_pb::AttachmentIdProto* UnwrapMutable(Wrapper* wrapper); |
| 69 static void Swap(sync_pb::AttachmentIdProto* t1, | 68 static void Swap(sync_pb::AttachmentIdProto* t1, |
| 70 sync_pb::AttachmentIdProto* t2); | 69 sync_pb::AttachmentIdProto* t2); |
| 71 }; | 70 }; |
| 72 | 71 |
| 73 typedef Immutable<sync_pb::AttachmentIdProto, | 72 typedef Immutable<sync_pb::AttachmentIdProto, |
| 74 ImmutableAttachmentIdProtoTraits> | 73 ImmutableAttachmentIdProtoTraits> |
| 75 ImmutableAttachmentIdProto; | 74 ImmutableAttachmentIdProto; |
| 76 | 75 |
| 77 ImmutableAttachmentIdProto proto_; | 76 ImmutableAttachmentIdProto proto_; |
| 78 | 77 |
| 79 explicit AttachmentId(sync_pb::AttachmentIdProto* proto); | 78 explicit AttachmentId(sync_pb::AttachmentIdProto* proto); |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 // All public interfaces use AttachmentIdList. AttachmentIdSet is used in | 81 // All public interfaces use AttachmentIdList. AttachmentIdSet is used in |
| 83 // implementations of algorithms where set properties are needed. | 82 // implementations of algorithms where set properties are needed. |
| 84 typedef std::vector<AttachmentId> AttachmentIdList; | 83 typedef std::vector<AttachmentId> AttachmentIdList; |
| 85 typedef std::set<AttachmentId> AttachmentIdSet; | 84 typedef std::set<AttachmentId> AttachmentIdSet; |
| 86 | 85 |
| 87 } // namespace syncer | 86 } // namespace syncer |
| 88 | 87 |
| 89 #endif // COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_ID_H_ | 88 #endif // COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_ID_H_ |
| OLD | NEW |