Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: sync/api/attachments/attachment_service.h

Issue 187303006: Update sync API to support attachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@attachmentapi
Patch Set: Remove AttachmentServiceBase for reals. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "base/memory/weak_ptr.h"
12 #include "sync/api/attachments/attachment.h"
13 #include "sync/base/sync_export.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 GetOrDownloadAttachments operation.
26 enum GetOrDownloadResult {
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 GetOrDownloadResult&, const AttachmentMap& attachments)>
34 GetOrDownloadCallback;
35
36 // The result of a DropAttachments operation.
37 enum DropResult {
38 DROP_SUCCESS, // No error.
39 DROP_UNSPECIFIED_ERROR, // An unspecified error occurred.
40 };
41
42 typedef base::Callback<void(const DropResult&)> DropCallback;
43
44 AttachmentService();
45 virtual ~AttachmentService();
46
47 // See SyncData::GetOrDownloadAttachments.
48 virtual void GetOrDownloadAttachments(
49 const AttachmentIdList& attachment_ids,
50 const GetOrDownloadCallback& callback) = 0;
51
52 // See SyncData::DropAttachments.
53 virtual void DropAttachments(const AttachmentIdList& attachment_ids,
54 const DropCallback& callback) = 0;
55
56 // This method should be called when a SyncData is about to be added to the
57 // sync database so we have a chance to persist the Attachment locally and
58 // schedule it for upload to the sync server.
59 virtual void OnSyncDataAdd(const SyncData& sync_data) = 0;
60
61 // This method should be called when a SyncData is about to be deleted from
62 // the sync database so we can remove any unreferenced attachments from local
63 // storage.
64 virtual void OnSyncDataDelete(const SyncData& sync_data) = 0;
65
66 // This method should be called when a SyncData is about to be updated so we
67 // can remove unreferenced attachments from local storage and ensure new
68 // attachments are persisted and uploaded to the sync server.
69 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids,
70 const SyncData& updated_sync_data) = 0;
71 };
72
73 } // namespace syncer
74
75 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698