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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 // The result of a StoreAttachments operation. | 47 // The result of a StoreAttachments operation. |
48 enum StoreResult { | 48 enum StoreResult { |
49 STORE_SUCCESS, // No error, all attachments stored (at least | 49 STORE_SUCCESS, // No error, all attachments stored (at least |
50 // locally). | 50 // locally). |
51 STORE_UNSPECIFIED_ERROR, // An unspecified error occurred. Some or all | 51 STORE_UNSPECIFIED_ERROR, // An unspecified error occurred. Some or all |
52 // attachments may not have been stored. | 52 // attachments may not have been stored. |
53 }; | 53 }; |
54 | 54 |
55 typedef base::Callback<void(const StoreResult&)> StoreCallback; | 55 typedef base::Callback<void(const StoreResult&)> StoreCallback; |
56 | 56 |
57 // An interface that embedder code implements to be notified about different | |
58 // events that originate from AttachmentService. | |
59 class Delegate { | |
maniscalco
2014/05/09 18:12:11
I'm thinking about in which thread the delegate wi
pavely
2014/05/13 23:06:44
Done.
| |
60 public: | |
61 virtual ~Delegate() {} | |
62 | |
63 // Attachment is uploaded to server and attachment_id is updated with server | |
64 // url. | |
65 virtual void OnAttachmentUploaded(const AttachmentId& attachment_id) = 0; | |
66 }; | |
67 | |
57 AttachmentService(); | 68 AttachmentService(); |
58 virtual ~AttachmentService(); | 69 virtual ~AttachmentService(); |
59 | 70 |
71 // Set delegate pointer. AttachmentService doesn't own delegate. | |
maniscalco
2014/05/09 18:12:11
Can we avoid adding a no-op implementation here?
pavely
2014/05/13 23:06:44
The reason was to not add implementation of it to
| |
72 virtual void SetDelegate(Delegate* delegate) {} | |
maniscalco
2014/05/09 18:12:11
In the future we may move the delegate functionali
pavely
2014/05/13 23:06:44
Right now interface simple, explicit and will blow
| |
73 | |
60 // See SyncData::GetOrDownloadAttachments. | 74 // See SyncData::GetOrDownloadAttachments. |
61 virtual void GetOrDownloadAttachments( | 75 virtual void GetOrDownloadAttachments( |
62 const AttachmentIdList& attachment_ids, | 76 const AttachmentIdList& attachment_ids, |
63 const GetOrDownloadCallback& callback) = 0; | 77 const GetOrDownloadCallback& callback) = 0; |
64 | 78 |
65 // See SyncData::DropAttachments. | 79 // See SyncData::DropAttachments. |
66 virtual void DropAttachments(const AttachmentIdList& attachment_ids, | 80 virtual void DropAttachments(const AttachmentIdList& attachment_ids, |
67 const DropCallback& callback) = 0; | 81 const DropCallback& callback) = 0; |
68 | 82 |
69 // Store |attachments| on device and (eventually) upload them to the server. | 83 // Store |attachments| on device and (eventually) upload them to the server. |
(...skipping 11 matching lines...) Expand all Loading... | |
81 // This method should be called when a SyncData is about to be updated so we | 95 // This method should be called when a SyncData is about to be updated so we |
82 // can remove unreferenced attachments from local storage and ensure new | 96 // can remove unreferenced attachments from local storage and ensure new |
83 // attachments are persisted and uploaded to the sync server. | 97 // attachments are persisted and uploaded to the sync server. |
84 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, | 98 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, |
85 const SyncData& updated_sync_data) = 0; | 99 const SyncData& updated_sync_data) = 0; |
86 }; | 100 }; |
87 | 101 |
88 } // namespace syncer | 102 } // namespace syncer |
89 | 103 |
90 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | 104 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
OLD | NEW |