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

Unified Diff: sync/api/attachments/attachment_id.cc

Issue 187303006: Update sync API to support attachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@attachmentapi
Patch Set: Rename GetAttachments to GetLocalAttachmentsForUpload. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/api/attachments/attachment_id.h ('k') | sync/api/attachments/attachment_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/api/attachments/attachment_id.cc
diff --git a/sync/api/attachments/attachment_id.cc b/sync/api/attachments/attachment_id.cc
index 181f3806bedf9bdf1557f7c238305cd58d11cdc6..6f3e0a24abf2b99dcf634775286ea81168b94a2c 100644
--- a/sync/api/attachments/attachment_id.cc
+++ b/sync/api/attachments/attachment_id.cc
@@ -6,13 +6,41 @@
#include "base/logging.h"
#include "base/rand_util.h"
+#include "sync/protocol/sync.pb.h"
namespace syncer {
+void AttachmentId::ImmutableAttachmentIdProtoTraits::InitializeWrapper(
+ Wrapper* wrapper) {
+ *wrapper = new sync_pb::AttachmentIdProto();
+}
+
+void AttachmentId::ImmutableAttachmentIdProtoTraits::DestroyWrapper(
+ Wrapper* wrapper) {
+ delete *wrapper;
+}
+
+const sync_pb::AttachmentIdProto&
+AttachmentId::ImmutableAttachmentIdProtoTraits::Unwrap(const Wrapper& wrapper) {
+ return *wrapper;
+}
+
+sync_pb::AttachmentIdProto*
+AttachmentId::ImmutableAttachmentIdProtoTraits::UnwrapMutable(
+ Wrapper* wrapper) {
+ return *wrapper;
+}
+
+void AttachmentId::ImmutableAttachmentIdProtoTraits::Swap(
+ sync_pb::AttachmentIdProto* t1,
+ sync_pb::AttachmentIdProto* t2) {
+ t1->Swap(t2);
+}
+
AttachmentId::~AttachmentId() {}
bool AttachmentId::operator==(const AttachmentId& other) const {
- return unique_id_ == other.unique_id_;
+ return proto_.Get().unique_id() == other.proto_.Get().unique_id();
}
bool AttachmentId::operator!=(const AttachmentId& other) const {
@@ -20,19 +48,30 @@ bool AttachmentId::operator!=(const AttachmentId& other) const {
}
bool AttachmentId::operator<(const AttachmentId& other) const {
- return unique_id_ < other.unique_id_;
+ return proto_.Get().unique_id() < other.proto_.Get().unique_id();
}
// Static.
AttachmentId AttachmentId::Create() {
// Only requirement here is that this id must be globally unique.
// TODO(maniscalco): Consider making this base64 encoded.
- return AttachmentId(base::RandBytesAsString(16));
+ sync_pb::AttachmentIdProto proto;
+ proto.set_unique_id(base::RandBytesAsString(16));
+ return AttachmentId(&proto);
}
-AttachmentId::AttachmentId(const std::string& unique_id)
- : unique_id_(unique_id) {
- DCHECK(!unique_id_.empty());
+// Static.
+AttachmentId AttachmentId::CreateFromProto(
+ const sync_pb::AttachmentIdProto& proto) {
+ sync_pb::AttachmentIdProto copy_of_proto(proto);
+ return AttachmentId(&copy_of_proto);
}
+const sync_pb::AttachmentIdProto& AttachmentId::GetProto() const {
+ return proto_.Get();
+}
+
+AttachmentId::AttachmentId(sync_pb::AttachmentIdProto* proto)
+ : proto_(proto) {}
+
} // namespace syncer
« no previous file with comments | « sync/api/attachments/attachment_id.h ('k') | sync/api/attachments/attachment_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698