Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / sync / internal_api / public / base / attachment_id_proto.cc
blob6692ab70dc77d5bc0411a2222028b85e215ebcf2
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.
5 #include "sync/internal_api/public/base/attachment_id_proto.h"
7 #include "base/guid.h"
8 #include "base/logging.h"
9 #include "base/strings/string_util.h"
11 namespace syncer {
13 sync_pb::AttachmentIdProto CreateAttachmentIdProto(size_t size,
14 uint32_t crc32c) {
15 sync_pb::AttachmentIdProto proto;
16 std::string guid = base::StringToLowerASCII(base::GenerateGUID());
17 DCHECK(!guid.empty());
18 // Requirements are that this id must be a unique RFC4122 UUID, formatted in
19 // lower case.
20 proto.set_unique_id(guid);
21 proto.set_size_bytes(size);
22 proto.set_crc32c(crc32c);
23 return proto;
26 sync_pb::AttachmentMetadata CreateAttachmentMetadata(
27 const google::protobuf::RepeatedPtrField<sync_pb::AttachmentIdProto>& ids) {
28 sync_pb::AttachmentMetadata result;
29 for (int i = 0; i < ids.size(); ++i) {
30 sync_pb::AttachmentMetadataRecord* record = result.add_record();
31 *record->mutable_id() = ids.Get(i);
32 record->set_is_on_server(true);
34 return result;
37 } // namespace syncer