OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | |
6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/callback.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "sync/api/attachments/attachment.h" | |
12 #include "sync/base/sync_export.h" | |
13 #include "sync/protocol/sync.pb.h" | |
14 | |
15 namespace syncer { | |
16 | |
17 class SyncData; | |
18 | |
19 // AttachmentService is responsible for managing a model type's attachments. | |
20 // | |
21 // Outside of sync code, AttachmentService shouldn't be used directly. Instead | |
22 // use the functionality provided by SyncData and SyncChangeProcessor. | |
23 class SYNC_EXPORT AttachmentService { | |
24 public: | |
25 // The result of a GetAttachments operation. | |
26 enum GetResult { | |
27 GET_SUCCESS, // No error. | |
28 GET_NOT_FOUND, // Attachment was not found or does not exist. | |
29 GET_UNSPECIFIED_ERROR, // An unspecified error occurred. | |
30 }; | |
31 | |
32 typedef base::Callback< | |
33 void(const GetResult&, const AttachmentMap& attachments)> GetCallback; | |
34 | |
35 // The result of a DropAttachments operation. | |
36 enum DropResult { | |
37 DROP_SUCCESS, // No error. | |
38 DROP_UNSPECIFIED_ERROR, // An unspecified error occurred. | |
39 }; | |
40 | |
41 typedef base::Callback<void(const DropResult&)> DropCallback; | |
42 | |
43 AttachmentService(); | |
44 virtual ~AttachmentService(); | |
45 | |
46 // See SyncData::GetAttachments. | |
47 virtual void GetAttachments(const AttachmentIdList& attachment_ids, | |
48 const GetCallback& callback) = 0; | |
49 | |
50 // See SyncData::DropAttachments. | |
51 virtual void DropAttachments(const AttachmentIdList& attachment_ids, | |
52 const DropCallback& callback) = 0; | |
53 | |
54 // This method should be called when a SyncData is about to be added to the | |
55 // sync database so we have a chance to persist the Attachment locally and | |
56 // schedule it for upload to the sync server. | |
57 virtual void OnSyncDataAdd(const SyncData& sync_data) = 0; | |
58 | |
59 // This method should be called when a SyncData is about to be deleted from | |
60 // the sync database so we can remove any unreferenced attachments from local | |
61 // storage. | |
62 virtual void OnSyncDataDelete(const SyncData& sync_data) = 0; | |
63 | |
64 // This method should be called when a SyncData is about to be updated so we | |
65 // can remove unreferenced attachments from local storage and ensure new | |
66 // attachments are persisted and uploaded to the sync server. | |
67 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, | |
68 const SyncData& updated_sync_data) = 0; | |
69 }; | |
70 | |
71 } // namespace syncer | |
72 | |
73 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVaICE_H_ | |
tim (not reviewing)
2014/03/10 22:55:58
did this pass presubmit? SERVaICE_H
maniscalco
2014/03/18 20:49:18
Heh, unfortunately, it does pass. Fixed.
| |
OLD | NEW |