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

Side by Side Diff: sync/api/attachments/attachment_id.cc

Issue 264793007: Keep track of which attachments are referenced by which sync entries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory leak. Created 6 years, 7 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 | Annotate | Revision Log
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_id.h" 5 #include "sync/api/attachments/attachment_id.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/rand_util.h" 8 #include "sync/internal_api/public/base/attachment_id_proto.h"
9 #include "sync/protocol/sync.pb.h" 9 #include "sync/protocol/sync.pb.h"
10 10
11 namespace syncer { 11 namespace syncer {
12 12
13 void AttachmentId::ImmutableAttachmentIdProtoTraits::InitializeWrapper( 13 void AttachmentId::ImmutableAttachmentIdProtoTraits::InitializeWrapper(
14 Wrapper* wrapper) { 14 Wrapper* wrapper) {
15 *wrapper = new sync_pb::AttachmentIdProto(); 15 *wrapper = new sync_pb::AttachmentIdProto();
16 } 16 }
17 17
18 void AttachmentId::ImmutableAttachmentIdProtoTraits::DestroyWrapper( 18 void AttachmentId::ImmutableAttachmentIdProtoTraits::DestroyWrapper(
(...skipping 27 matching lines...) Expand all
46 bool AttachmentId::operator!=(const AttachmentId& other) const { 46 bool AttachmentId::operator!=(const AttachmentId& other) const {
47 return !operator==(other); 47 return !operator==(other);
48 } 48 }
49 49
50 bool AttachmentId::operator<(const AttachmentId& other) const { 50 bool AttachmentId::operator<(const AttachmentId& other) const {
51 return proto_.Get().unique_id() < other.proto_.Get().unique_id(); 51 return proto_.Get().unique_id() < other.proto_.Get().unique_id();
52 } 52 }
53 53
54 // Static. 54 // Static.
55 AttachmentId AttachmentId::Create() { 55 AttachmentId AttachmentId::Create() {
56 // Only requirement here is that this id must be globally unique. 56 sync_pb::AttachmentIdProto proto = CreateAttachmentIdProto();
57 // TODO(maniscalco): Consider making this base64 encoded.
58 sync_pb::AttachmentIdProto proto;
59 proto.set_unique_id(base::RandBytesAsString(16));
60 return AttachmentId(&proto); 57 return AttachmentId(&proto);
61 } 58 }
62 59
63 // Static. 60 // Static.
64 AttachmentId AttachmentId::CreateFromProto( 61 AttachmentId AttachmentId::CreateFromProto(
65 const sync_pb::AttachmentIdProto& proto) { 62 const sync_pb::AttachmentIdProto& proto) {
66 sync_pb::AttachmentIdProto copy_of_proto(proto); 63 sync_pb::AttachmentIdProto copy_of_proto(proto);
67 return AttachmentId(&copy_of_proto); 64 return AttachmentId(&copy_of_proto);
68 } 65 }
69 66
70 const sync_pb::AttachmentIdProto& AttachmentId::GetProto() const { 67 const sync_pb::AttachmentIdProto& AttachmentId::GetProto() const {
71 return proto_.Get(); 68 return proto_.Get();
72 } 69 }
73 70
74 AttachmentId::AttachmentId(sync_pb::AttachmentIdProto* proto) 71 AttachmentId::AttachmentId(sync_pb::AttachmentIdProto* proto)
75 : proto_(proto) {} 72 : proto_(proto) {}
76 73
77 } // namespace syncer 74 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync_driver/generic_change_processor_unittest.cc ('k') | sync/api/attachments/attachment_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698