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

Side by Side Diff: sync/internal_api/public/base/attachment_id_proto.cc

Issue 982883002: [Sync] Add size and crc32c to AttachmentId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix argument evaluation order bug. Created 5 years, 9 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sync/internal_api/public/base/attachment_id_proto.h" 5 #include "sync/internal_api/public/base/attachment_id_proto.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 10
11 namespace syncer { 11 namespace syncer {
12 12
13 sync_pb::AttachmentIdProto CreateAttachmentIdProto() { 13 sync_pb::AttachmentIdProto CreateAttachmentIdProto(size_t size,
14 uint32_t crc32c) {
14 sync_pb::AttachmentIdProto proto; 15 sync_pb::AttachmentIdProto proto;
15 std::string guid = base::StringToLowerASCII(base::GenerateGUID()); 16 std::string guid = base::StringToLowerASCII(base::GenerateGUID());
16 DCHECK(!guid.empty()); 17 DCHECK(!guid.empty());
17 // Requirements are that this id must be a unique RFC4122 UUID, formatted in 18 // Requirements are that this id must be a unique RFC4122 UUID, formatted in
18 // lower case. 19 // lower case.
19 proto.set_unique_id(guid); 20 proto.set_unique_id(guid);
21 proto.set_size_bytes(size);
22 proto.set_crc32c(crc32c);
20 return proto; 23 return proto;
21 } 24 }
22 25
23 sync_pb::AttachmentMetadata CreateAttachmentMetadata( 26 sync_pb::AttachmentMetadata CreateAttachmentMetadata(
24 const google::protobuf::RepeatedPtrField<sync_pb::AttachmentIdProto>& ids) { 27 const google::protobuf::RepeatedPtrField<sync_pb::AttachmentIdProto>& ids) {
25 sync_pb::AttachmentMetadata result; 28 sync_pb::AttachmentMetadata result;
26 for (int i = 0; i < ids.size(); ++i) { 29 for (int i = 0; i < ids.size(); ++i) {
27 sync_pb::AttachmentMetadataRecord* record = result.add_record(); 30 sync_pb::AttachmentMetadataRecord* record = result.add_record();
28 *record->mutable_id() = ids.Get(i); 31 *record->mutable_id() = ids.Get(i);
29 record->set_is_on_server(true); 32 record->set_is_on_server(true);
30 } 33 }
31 return result; 34 return result;
32 } 35 }
33 36
34 } // namespace syncer 37 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698