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

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

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
« no previous file with comments | « sync/api/attachments/attachment_id.h ('k') | sync/api/attachments/attachment_id_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "sync/api/attachments/attachment_id.h"
6
7 #include <stddef.h>
8 #include <stdint.h>
9
10 #include "base/logging.h"
11 #include "sync/internal_api/public/base/attachment_id_proto.h"
12 #include "sync/protocol/sync.pb.h"
13
14 namespace syncer {
15
16 void AttachmentId::ImmutableAttachmentIdProtoTraits::InitializeWrapper(
17 Wrapper* wrapper) {
18 *wrapper = new sync_pb::AttachmentIdProto();
19 }
20
21 void AttachmentId::ImmutableAttachmentIdProtoTraits::DestroyWrapper(
22 Wrapper* wrapper) {
23 delete *wrapper;
24 }
25
26 const sync_pb::AttachmentIdProto&
27 AttachmentId::ImmutableAttachmentIdProtoTraits::Unwrap(const Wrapper& wrapper) {
28 return *wrapper;
29 }
30
31 sync_pb::AttachmentIdProto*
32 AttachmentId::ImmutableAttachmentIdProtoTraits::UnwrapMutable(
33 Wrapper* wrapper) {
34 return *wrapper;
35 }
36
37 void AttachmentId::ImmutableAttachmentIdProtoTraits::Swap(
38 sync_pb::AttachmentIdProto* t1,
39 sync_pb::AttachmentIdProto* t2) {
40 t1->Swap(t2);
41 }
42
43 AttachmentId::~AttachmentId() {}
44
45 bool AttachmentId::operator==(const AttachmentId& other) const {
46 return proto_.Get().unique_id() == other.proto_.Get().unique_id();
47 }
48
49 bool AttachmentId::operator!=(const AttachmentId& other) const {
50 return !operator==(other);
51 }
52
53 bool AttachmentId::operator<(const AttachmentId& other) const {
54 return proto_.Get().unique_id() < other.proto_.Get().unique_id();
55 }
56
57 // Static.
58 AttachmentId AttachmentId::Create(size_t size, uint32_t crc32c) {
59 sync_pb::AttachmentIdProto proto = CreateAttachmentIdProto(size, crc32c);
60 return AttachmentId(&proto);
61 }
62
63 // Static.
64 AttachmentId AttachmentId::CreateFromProto(
65 const sync_pb::AttachmentIdProto& proto) {
66 sync_pb::AttachmentIdProto copy_of_proto(proto);
67 return AttachmentId(&copy_of_proto);
68 }
69
70 const sync_pb::AttachmentIdProto& AttachmentId::GetProto() const {
71 return proto_.Get();
72 }
73
74 AttachmentId::AttachmentId(sync_pb::AttachmentIdProto* proto)
75 : proto_(proto) {}
76
77 AttachmentId::AttachmentId(const AttachmentId& other) = default;
78
79 size_t AttachmentId::GetSize() const {
80 return proto_.Get().size_bytes();
81 }
82
83 uint32_t AttachmentId::GetCrc32c() const {
84 return proto_.Get().crc32c();
85 }
86
87 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/api/attachments/attachment_id.h ('k') | sync/api/attachments/attachment_id_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698