OLD | NEW |
| (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/internal_api/public/base/attachment_id_proto.h" | |
6 | |
7 #include <stddef.h> | |
8 #include <stdint.h> | |
9 | |
10 #include <string> | |
11 | |
12 #include "base/guid.h" | |
13 #include "base/logging.h" | |
14 #include "base/strings/string_util.h" | |
15 | |
16 namespace syncer { | |
17 | |
18 sync_pb::AttachmentIdProto CreateAttachmentIdProto(size_t size, | |
19 uint32_t crc32c) { | |
20 sync_pb::AttachmentIdProto proto; | |
21 std::string guid = base::ToLowerASCII(base::GenerateGUID()); | |
22 DCHECK(!guid.empty()); | |
23 // Requirements are that this id must be a unique RFC4122 UUID, formatted in | |
24 // lower case. | |
25 proto.set_unique_id(guid); | |
26 proto.set_size_bytes(size); | |
27 proto.set_crc32c(crc32c); | |
28 return proto; | |
29 } | |
30 | |
31 sync_pb::AttachmentMetadata CreateAttachmentMetadata( | |
32 const google::protobuf::RepeatedPtrField<sync_pb::AttachmentIdProto>& ids) { | |
33 sync_pb::AttachmentMetadata result; | |
34 for (int i = 0; i < ids.size(); ++i) { | |
35 sync_pb::AttachmentMetadataRecord* record = result.add_record(); | |
36 *record->mutable_id() = ids.Get(i); | |
37 record->set_is_on_server(true); | |
38 } | |
39 return result; | |
40 } | |
41 | |
42 } // namespace syncer | |
OLD | NEW |