Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: components/sync/api/attachments/attachment_id.cc

Issue 2401223002: [Sync] Renaming sync/api* to sync/model*. (Closed)
Patch Set: Missed a comment in a DEPS file, and rebasing. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include "components/sync/api/attachments/attachment_id.h"
6
7 #include "base/logging.h"
8 #include "components/sync/base/attachment_id_proto.h"
9 #include "components/sync/protocol/sync.pb.h"
10
11 namespace syncer {
12
13 void AttachmentId::ImmutableAttachmentIdProtoTraits::InitializeWrapper(
14 Wrapper* wrapper) {
15 *wrapper = new sync_pb::AttachmentIdProto();
16 }
17
18 void AttachmentId::ImmutableAttachmentIdProtoTraits::DestroyWrapper(
19 Wrapper* wrapper) {
20 delete *wrapper;
21 }
22
23 const sync_pb::AttachmentIdProto&
24 AttachmentId::ImmutableAttachmentIdProtoTraits::Unwrap(const Wrapper& wrapper) {
25 return *wrapper;
26 }
27
28 sync_pb::AttachmentIdProto*
29 AttachmentId::ImmutableAttachmentIdProtoTraits::UnwrapMutable(
30 Wrapper* wrapper) {
31 return *wrapper;
32 }
33
34 void AttachmentId::ImmutableAttachmentIdProtoTraits::Swap(
35 sync_pb::AttachmentIdProto* t1,
36 sync_pb::AttachmentIdProto* t2) {
37 t1->Swap(t2);
38 }
39
40 AttachmentId::~AttachmentId() {}
41
42 bool AttachmentId::operator==(const AttachmentId& other) const {
43 return proto_.Get().unique_id() == other.proto_.Get().unique_id();
44 }
45
46 bool AttachmentId::operator!=(const AttachmentId& other) const {
47 return !operator==(other);
48 }
49
50 bool AttachmentId::operator<(const AttachmentId& other) const {
51 return proto_.Get().unique_id() < other.proto_.Get().unique_id();
52 }
53
54 // Static.
55 AttachmentId AttachmentId::Create(size_t size, uint32_t crc32c) {
56 sync_pb::AttachmentIdProto proto = CreateAttachmentIdProto(size, crc32c);
57 return AttachmentId(&proto);
58 }
59
60 // Static.
61 AttachmentId AttachmentId::CreateFromProto(
62 const sync_pb::AttachmentIdProto& proto) {
63 sync_pb::AttachmentIdProto copy_of_proto(proto);
64 return AttachmentId(&copy_of_proto);
65 }
66
67 const sync_pb::AttachmentIdProto& AttachmentId::GetProto() const {
68 return proto_.Get();
69 }
70
71 AttachmentId::AttachmentId(sync_pb::AttachmentIdProto* proto) : proto_(proto) {}
72
73 AttachmentId::AttachmentId(const AttachmentId& other) = default;
74
75 size_t AttachmentId::GetSize() const {
76 return proto_.Get().size_bytes();
77 }
78
79 uint32_t AttachmentId::GetCrc32c() const {
80 return proto_.Get().crc32c();
81 }
82
83 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/api/attachments/attachment_id.h ('k') | components/sync/api/attachments/attachment_id_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698