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/sync_attachment.cc

Issue 102193004: Checkpointing some Sync Attachment work. Added SyncAttachment and SyncAttachmentId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing SYNC_EXPORT_PRIVATE modifier (was cause of link error on trybots). Created 6 years, 11 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
« no previous file with comments | « sync/api/sync_attachment.h ('k') | sync/api/sync_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
(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.unique_id().empty());
42 DCHECK(bytes);
43 }
44
45 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/api/sync_attachment.h ('k') | sync/api/sync_attachment_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698