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

Side by Side Diff: sync/internal_api/public/attachments/attachment_service.h

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

Powered by Google App Engine
This is Rietveld 408576698