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/api/attachments/attachment.cc

Issue 710073003: Store attachment crc in AttachmentStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Add comment in attachment_util.h. Created 6 years, 1 month 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
« no previous file with comments | « sync/api/attachments/attachment.h ('k') | sync/api/attachments/attachment_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/api/attachments/attachment.h" 5 #include "sync/api/attachments/attachment.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "sync/internal_api/public/attachments/attachment_util.h"
8 9
9 namespace syncer { 10 namespace syncer {
10 11
11 Attachment::~Attachment() {} 12 Attachment::~Attachment() {}
12 13
13 // Static. 14 // Static.
14 Attachment Attachment::Create( 15 Attachment Attachment::Create(
15 const scoped_refptr<base::RefCountedMemory>& data) { 16 const scoped_refptr<base::RefCountedMemory>& data) {
16 return CreateWithId(AttachmentId::Create(), data); 17 uint32_t crc32c = ComputeCrc32c(data);
18 return CreateFromParts(AttachmentId::Create(), data, crc32c);
17 } 19 }
18 20
19 // Static. 21 // Static.
20 Attachment Attachment::CreateWithId( 22 Attachment Attachment::CreateFromParts(
21 const AttachmentId& id, 23 const AttachmentId& id,
22 const scoped_refptr<base::RefCountedMemory>& data) { 24 const scoped_refptr<base::RefCountedMemory>& data,
23 return Attachment(id, data); 25 uint32_t crc32c) {
26 return Attachment(id, data, crc32c);
24 } 27 }
25 28
26 const AttachmentId& Attachment::GetId() const { return id_; } 29 const AttachmentId& Attachment::GetId() const { return id_; }
27 30
28 const scoped_refptr<base::RefCountedMemory>& Attachment::GetData() const { 31 const scoped_refptr<base::RefCountedMemory>& Attachment::GetData() const {
29 return data_; 32 return data_;
30 } 33 }
31 34
35 uint32_t Attachment::GetCrc32c() const { return crc32c_; }
36
32 Attachment::Attachment(const AttachmentId& id, 37 Attachment::Attachment(const AttachmentId& id,
33 const scoped_refptr<base::RefCountedMemory>& data) 38 const scoped_refptr<base::RefCountedMemory>& data,
34 : id_(id), data_(data) { 39 uint32_t crc32c)
40 : id_(id), data_(data), crc32c_(crc32c) {
35 DCHECK(data.get()); 41 DCHECK(data.get());
36 } 42 }
37 43
38 } // namespace syncer 44 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/api/attachments/attachment.h ('k') | sync/api/attachments/attachment_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698