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

Unified 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 7 years 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/api/sync_attachment.cc
diff --git a/sync/api/sync_attachment.cc b/sync/api/sync_attachment.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3827cd68020b7ffffc48b5d6d3ffd84a0914784c
--- /dev/null
+++ b/sync/api/sync_attachment.cc
@@ -0,0 +1,45 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/api/sync_attachment.h"
+
+#include "base/logging.h"
+#include "base/memory/ref_counted_memory.h"
+#include "base/rand_util.h"
+
+namespace syncer {
+
+SyncAttachment::~SyncAttachment() {}
+
+// Static.
+scoped_ptr<SyncAttachment> SyncAttachment::Create(
+ const scoped_refptr<base::RefCountedMemory>& bytes) {
+ sync_pb::SyncAttachmentId id;
+ // Only requirement here is that this id must be globally unique.
+ id.set_unique_id(base::RandBytesAsString(16));
+ return CreateWithId(id, bytes);
+}
+
+// Static.
+scoped_ptr<SyncAttachment> SyncAttachment::CreateWithId(
+ const sync_pb::SyncAttachmentId& id,
+ const scoped_refptr<base::RefCountedMemory>& bytes) {
+ return scoped_ptr<SyncAttachment>(new SyncAttachment(id, bytes)).Pass();
+}
+
+const sync_pb::SyncAttachmentId& SyncAttachment::GetId() const { return id_; }
+
+const scoped_refptr<base::RefCountedMemory>& SyncAttachment::GetBytes() const {
+ return bytes_;
+}
+
+SyncAttachment::SyncAttachment(
+ const sync_pb::SyncAttachmentId& id,
+ const scoped_refptr<base::RefCountedMemory>& bytes)
+ : id_(id), bytes_(bytes) {
+ DCHECK(!id.unique_id().empty());
+ DCHECK(bytes);
+}
+
+} // namespace syncer
« 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