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 // This interface will be called from the same thread AttachmentService was |
| 60 // created and called. |
| 61 class Delegate { |
| 62 public: |
| 63 virtual ~Delegate() {} |
| 64 |
| 65 // Attachment is uploaded to server and attachment_id is updated with server |
| 66 // url. |
| 67 virtual void OnAttachmentUploaded(const AttachmentId& attachment_id) = 0; |
| 68 }; |
| 69 |
57 AttachmentService(); | 70 AttachmentService(); |
58 virtual ~AttachmentService(); | 71 virtual ~AttachmentService(); |
59 | 72 |
60 // See SyncData::GetOrDownloadAttachments. | 73 // See SyncData::GetOrDownloadAttachments. |
61 virtual void GetOrDownloadAttachments( | 74 virtual void GetOrDownloadAttachments( |
62 const AttachmentIdList& attachment_ids, | 75 const AttachmentIdList& attachment_ids, |
63 const GetOrDownloadCallback& callback) = 0; | 76 const GetOrDownloadCallback& callback) = 0; |
64 | 77 |
65 // See SyncData::DropAttachments. | 78 // See SyncData::DropAttachments. |
66 virtual void DropAttachments(const AttachmentIdList& attachment_ids, | 79 virtual void DropAttachments(const AttachmentIdList& attachment_ids, |
(...skipping 14 matching lines...) Expand all Loading... |
81 // This method should be called when a SyncData is about to be updated so we | 94 // 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 | 95 // can remove unreferenced attachments from local storage and ensure new |
83 // attachments are persisted and uploaded to the sync server. | 96 // attachments are persisted and uploaded to the sync server. |
84 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, | 97 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, |
85 const SyncData& updated_sync_data) = 0; | 98 const SyncData& updated_sync_data) = 0; |
86 }; | 99 }; |
87 | 100 |
88 } // namespace syncer | 101 } // namespace syncer |
89 | 102 |
90 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | 103 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
OLD | NEW |