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

Side by Side Diff: components/sync/core/attachments/attachment_service.h

Issue 2399953002: [Sync] Move attachments code out of core/. (Closed)
Patch Set: Address comments. Created 4 years, 2 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 COMPONENTS_SYNC_CORE_ATTACHMENTS_ATTACHMENT_SERVICE_H_
6 #define COMPONENTS_SYNC_CORE_ATTACHMENTS_ATTACHMENT_SERVICE_H_
7
8 #include <memory>
9
10 #include "base/callback.h"
11 #include "base/memory/weak_ptr.h"
12 #include "components/sync/api/attachments/attachment.h"
13
14 namespace syncer {
15
16 class AttachmentStore;
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 //
24 // Destroying this object does not necessarily cancel outstanding async
25 // operations. If you need cancel like semantics, use WeakPtr in the callbacks.
26 class AttachmentService {
27 public:
28 // The result of a GetOrDownloadAttachments operation.
29 enum GetOrDownloadResult {
30 GET_SUCCESS, // No error, all attachments returned.
31 GET_UNSPECIFIED_ERROR, // An unspecified error occurred.
32 };
33
34 typedef base::Callback<void(const GetOrDownloadResult&,
35 std::unique_ptr<AttachmentMap> attachments)>
36 GetOrDownloadCallback;
37
38 // An interface that embedder code implements to be notified about different
39 // events that originate from AttachmentService.
40 // This interface will be called from the same thread AttachmentService was
41 // created and called.
42 class Delegate {
43 public:
44 virtual ~Delegate() {}
45
46 // Attachment is uploaded to server and attachment_id is updated with server
47 // url.
48 virtual void OnAttachmentUploaded(const AttachmentId& attachment_id) = 0;
49 };
50
51 AttachmentService();
52 virtual ~AttachmentService();
53
54 // See SyncData::GetOrDownloadAttachments.
55 virtual void GetOrDownloadAttachments(
56 const AttachmentIdList& attachment_ids,
57 const GetOrDownloadCallback& callback) = 0;
58
59 // Schedules the attachments identified by |attachment_ids| to be uploaded to
60 // the server.
61 //
62 // Assumes the attachments are already in the attachment store.
63 //
64 // A request to upload attachments is persistent in that uploads will be
65 // automatically retried if transient errors occur.
66 //
67 // A request to upload attachments does not persist across restarts of Chrome.
68 //
69 // Invokes OnAttachmentUploaded on the Delegate (if provided).
70 virtual void UploadAttachments(const AttachmentIdList& attachment_ids) = 0;
71 };
72
73 } // namespace syncer
74
75 #endif // COMPONENTS_SYNC_CORE_ATTACHMENTS_ATTACHMENT_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698