OLD | NEW |
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 #ifndef SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | 5 #ifndef SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | 6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 GET_UNSPECIFIED_ERROR, // An unspecified error occurred. | 31 GET_UNSPECIFIED_ERROR, // An unspecified error occurred. |
32 }; | 32 }; |
33 | 33 |
34 typedef base::Callback< | 34 typedef base::Callback< |
35 void(const GetOrDownloadResult&, scoped_ptr<AttachmentMap> attachments)> | 35 void(const GetOrDownloadResult&, scoped_ptr<AttachmentMap> attachments)> |
36 GetOrDownloadCallback; | 36 GetOrDownloadCallback; |
37 | 37 |
38 // The result of a DropAttachments operation. | 38 // The result of a DropAttachments operation. |
39 enum DropResult { | 39 enum DropResult { |
40 DROP_SUCCESS, // No error, all attachments dropped. | 40 DROP_SUCCESS, // No error, all attachments dropped. |
41 DROP_UNSPECIFIED_ERROR, // An unspecified error occurred. | 41 DROP_UNSPECIFIED_ERROR, // An unspecified error occurred. Some or all |
| 42 // attachments may not have been dropped. |
42 }; | 43 }; |
43 | 44 |
44 typedef base::Callback<void(const DropResult&)> DropCallback; | 45 typedef base::Callback<void(const DropResult&)> DropCallback; |
45 | 46 |
| 47 // The result of a StoreAttachments operation. |
| 48 enum StoreResult { |
| 49 STORE_SUCCESS, // No error, all attachments stored (at least |
| 50 // locally). |
| 51 STORE_UNSPECIFIED_ERROR, // An unspecified error occurred. Some or all |
| 52 // attachments may not have been stored. |
| 53 }; |
| 54 |
| 55 typedef base::Callback<void(const StoreResult&)> StoreCallback; |
| 56 |
46 AttachmentService(); | 57 AttachmentService(); |
47 virtual ~AttachmentService(); | 58 virtual ~AttachmentService(); |
48 | 59 |
49 // See SyncData::GetOrDownloadAttachments. | 60 // See SyncData::GetOrDownloadAttachments. |
50 virtual void GetOrDownloadAttachments( | 61 virtual void GetOrDownloadAttachments( |
51 const AttachmentIdList& attachment_ids, | 62 const AttachmentIdList& attachment_ids, |
52 const GetOrDownloadCallback& callback) = 0; | 63 const GetOrDownloadCallback& callback) = 0; |
53 | 64 |
54 // See SyncData::DropAttachments. | 65 // See SyncData::DropAttachments. |
55 virtual void DropAttachments(const AttachmentIdList& attachment_ids, | 66 virtual void DropAttachments(const AttachmentIdList& attachment_ids, |
56 const DropCallback& callback) = 0; | 67 const DropCallback& callback) = 0; |
57 | 68 |
58 // This method should be called when a SyncData is about to be added to the | 69 // Store |attachments| on device and (eventually) upload them to the server. |
59 // sync database so we have a chance to persist the Attachment locally and | 70 // |
60 // schedule it for upload to the sync server. | 71 // Invokes |callback| once the attachments have been written to device |
61 virtual void OnSyncDataAdd(const SyncData& sync_data) = 0; | 72 // storage. |
| 73 virtual void StoreAttachments(const AttachmentList& attachments, |
| 74 const StoreCallback& callback) = 0; |
62 | 75 |
63 // This method should be called when a SyncData is about to be deleted from | 76 // This method should be called when a SyncData is about to be deleted from |
64 // the sync database so we can remove any unreferenced attachments from local | 77 // the sync database so we can remove any unreferenced attachments from local |
65 // storage. | 78 // storage. |
66 virtual void OnSyncDataDelete(const SyncData& sync_data) = 0; | 79 virtual void OnSyncDataDelete(const SyncData& sync_data) = 0; |
67 | 80 |
68 // This method should be called when a SyncData is about to be updated so we | 81 // This method should be called when a SyncData is about to be updated so we |
69 // can remove unreferenced attachments from local storage and ensure new | 82 // can remove unreferenced attachments from local storage and ensure new |
70 // attachments are persisted and uploaded to the sync server. | 83 // attachments are persisted and uploaded to the sync server. |
71 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, | 84 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, |
72 const SyncData& updated_sync_data) = 0; | 85 const SyncData& updated_sync_data) = 0; |
73 }; | 86 }; |
74 | 87 |
75 } // namespace syncer | 88 } // namespace syncer |
76 | 89 |
77 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | 90 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
OLD | NEW |