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 #ifndef SYNC_API_SYNC_ATTACHMENT_H_ |
| 6 #define SYNC_API_SYNC_ATTACHMENT_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "sync/base/sync_export.h" |
| 12 #include "sync/protocol/sync.pb.h" |
| 13 |
| 14 namespace base { |
| 15 class RefCountedMemory; |
| 16 } // namespace base |
| 17 |
| 18 namespace syncer { |
| 19 |
| 20 // An immutable blob of in-memory data attached to a sync item. |
| 21 class SYNC_EXPORT SyncAttachment { |
| 22 public: |
| 23 ~SyncAttachment(); |
| 24 |
| 25 // Creates an attachment with a unique id and the supplied bytes. |
| 26 // |
| 27 // Used when creating a brand new attachment. |
| 28 static scoped_ptr<SyncAttachment> Create( |
| 29 const scoped_refptr<base::RefCountedMemory>& bytes); |
| 30 |
| 31 // Creates an attachment with the supplied id and bytes. |
| 32 // |
| 33 // Used when you want to recreate a specific attachment. E.g. creating a local |
| 34 // copy of an attachment that already exists on the sync server. |
| 35 static scoped_ptr<SyncAttachment> CreateWithId( |
| 36 const sync_pb::SyncAttachmentId& id, |
| 37 const scoped_refptr<base::RefCountedMemory>& bytes); |
| 38 |
| 39 // Returns this attachment's id. |
| 40 const sync_pb::SyncAttachmentId& GetId() const; |
| 41 |
| 42 // Returns this attachment's bytes. |
| 43 const scoped_refptr<base::RefCountedMemory>& GetBytes() const; |
| 44 |
| 45 private: |
| 46 const sync_pb::SyncAttachmentId id_; |
| 47 const scoped_refptr<base::RefCountedMemory> bytes_; |
| 48 |
| 49 SyncAttachment(const sync_pb::SyncAttachmentId& id, |
| 50 const scoped_refptr<base::RefCountedMemory>& bytes); |
| 51 |
| 52 // Default copy ctor welcome. |
| 53 DISALLOW_ASSIGN(SyncAttachment); |
| 54 }; |
| 55 |
| 56 } // namespace syncer |
| 57 |
| 58 #endif // SYNC_API_SYNC_ATTACHMENT_H_ |
OLD | NEW |