OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 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/api/sync_attachment.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/memory/ref_counted_memory.h" | |
9 #include "base/rand_util.h" | |
10 | |
11 namespace syncer { | |
12 | |
13 SyncAttachment::~SyncAttachment() {} | |
14 | |
15 // Static. | |
16 scoped_ptr<SyncAttachment> SyncAttachment::Create( | |
17 const scoped_refptr<base::RefCountedMemory>& bytes) { | |
18 sync_pb::SyncAttachmentId id; | |
19 // Only requirement here is that this id must be globally unique. | |
20 id.set_unique_id(base::RandBytesAsString(16)); | |
21 return CreateWithId(id, bytes); | |
22 } | |
23 | |
24 // Static. | |
25 scoped_ptr<SyncAttachment> SyncAttachment::CreateWithId( | |
26 const sync_pb::SyncAttachmentId& id, | |
27 const scoped_refptr<base::RefCountedMemory>& bytes) { | |
28 return scoped_ptr<SyncAttachment>(new SyncAttachment(id, bytes)).Pass(); | |
29 } | |
30 | |
31 const sync_pb::SyncAttachmentId& SyncAttachment::GetId() const { return id_; } | |
32 | |
33 const scoped_refptr<base::RefCountedMemory>& SyncAttachment::GetBytes() const { | |
34 return bytes_; | |
35 } | |
36 | |
37 SyncAttachment::SyncAttachment( | |
38 const sync_pb::SyncAttachmentId& id, | |
39 const scoped_refptr<base::RefCountedMemory>& bytes) | |
40 : id_(id), bytes_(bytes) { | |
41 DCHECK(id.has_unique_id()); | |
Nicolas Zea
2013/12/30 19:10:31
I think this dcheck is redundant given the one bel
maniscalco
2013/12/30 22:17:19
You're right. Done.
| |
42 DCHECK(!id.unique_id().empty()); | |
43 DCHECK(bytes); | |
44 } | |
45 | |
46 } // namespace syncer | |
OLD | NEW |