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

Side by Side Diff: sync/internal_api/public/base/attachment_id_proto.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
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/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
OLDNEW
« no previous file with comments | « sync/internal_api/public/base/attachment_id_proto.h ('k') | sync/internal_api/public/base/attachment_id_proto_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698