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

Side by Side Diff: sync/internal_api/attachments/on_disk_attachment_store.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/attachments/on_disk_attachment_store.h" 5 #include "sync/internal_api/public/attachments/on_disk_attachment_store.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return attachment.Pass(); 314 return attachment.Pass();
315 } 315 }
316 scoped_refptr<base::RefCountedMemory> data = 316 scoped_refptr<base::RefCountedMemory> data =
317 base::RefCountedString::TakeString(&data_str); 317 base::RefCountedString::TakeString(&data_str);
318 uint32_t crc32c = ComputeCrc32c(data); 318 uint32_t crc32c = ComputeCrc32c(data);
319 if (record_metadata.has_crc32c() && record_metadata.crc32c() != crc32c) { 319 if (record_metadata.has_crc32c() && record_metadata.crc32c() != crc32c) {
320 DVLOG(1) << "Attachment crc does not match"; 320 DVLOG(1) << "Attachment crc does not match";
321 return attachment.Pass(); 321 return attachment.Pass();
322 } 322 }
323 attachment.reset( 323 attachment.reset(
324 new Attachment(Attachment::CreateFromParts(attachment_id, data, crc32c))); 324 new Attachment(Attachment::CreateFromParts(attachment_id, data)));
pavely 2015/03/07 00:07:25 Maybe check that attachment_id's crc matches the o
maniscalco 2015/03/09 17:09:00 Good idea. Done with test case to verify.
325 return attachment.Pass(); 325 return attachment.Pass();
326 } 326 }
327 327
328 bool OnDiskAttachmentStore::WriteSingleAttachment( 328 bool OnDiskAttachmentStore::WriteSingleAttachment(
329 const Attachment& attachment) { 329 const Attachment& attachment) {
330 const std::string metadata_key = 330 const std::string metadata_key =
331 MakeMetadataKeyFromAttachmentId(attachment.GetId()); 331 MakeMetadataKeyFromAttachmentId(attachment.GetId());
332 const std::string data_key = MakeDataKeyFromAttachmentId(attachment.GetId()); 332 const std::string data_key = MakeDataKeyFromAttachmentId(attachment.GetId());
333 333
334 std::string metadata_str; 334 std::string metadata_str;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 return key; 397 return key;
398 } 398 }
399 399
400 AttachmentMetadata OnDiskAttachmentStore::MakeAttachmentMetadata( 400 AttachmentMetadata OnDiskAttachmentStore::MakeAttachmentMetadata(
401 const AttachmentId& attachment_id, 401 const AttachmentId& attachment_id,
402 const attachment_store_pb::RecordMetadata& record_metadata) { 402 const attachment_store_pb::RecordMetadata& record_metadata) {
403 return AttachmentMetadata(attachment_id, record_metadata.attachment_size()); 403 return AttachmentMetadata(attachment_id, record_metadata.attachment_size());
404 } 404 }
405 405
406 } // namespace syncer 406 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698