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

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

Issue 2401223002: [Sync] Renaming sync/api* to sync/model*. (Closed)
Patch Set: Missed a comment in a DEPS file, and rebasing. 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_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_
6 #define COMPONENTS_SYNC_API_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 AttachmentDownloader;
17 class AttachmentStore;
18 class AttachmentStoreForSync;
19 class AttachmentUploader;
20 class SyncData;
21
22 // AttachmentService is responsible for managing a model type's attachments.
23 //
24 // Outside of sync code, AttachmentService shouldn't be used directly. Instead
25 // use the functionality provided by SyncData and SyncChangeProcessor.
26 //
27 // Destroying this object does not necessarily cancel outstanding async
28 // operations. If you need cancel like semantics, use WeakPtr in the callbacks.
29 class AttachmentService {
30 public:
31 // The result of a GetOrDownloadAttachments operation.
32 enum GetOrDownloadResult {
33 GET_SUCCESS, // No error, all attachments returned.
34 GET_UNSPECIFIED_ERROR, // An unspecified error occurred.
35 };
36
37 typedef base::Callback<void(const GetOrDownloadResult&,
38 std::unique_ptr<AttachmentMap> attachments)>
39 GetOrDownloadCallback;
40
41 // An interface that embedder code implements to be notified about different
42 // events that originate from AttachmentService.
43 // This interface will be called from the same thread AttachmentService was
44 // created and called.
45 class Delegate {
46 public:
47 virtual ~Delegate() {}
48
49 // Attachment is uploaded to server and attachment_id is updated with server
50 // url.
51 virtual void OnAttachmentUploaded(const AttachmentId& attachment_id) = 0;
52 };
53
54 // Create a concrete AttachmentService.
55 static std::unique_ptr<AttachmentService> Create(
56 std::unique_ptr<AttachmentStoreForSync> attachment_store,
57 std::unique_ptr<AttachmentUploader> attachment_uploader,
58 std::unique_ptr<AttachmentDownloader> attachment_downloader,
59 Delegate* delegate,
60 const base::TimeDelta& initial_backoff_delay,
61 const base::TimeDelta& max_backoff_delay);
62
63 // Create an AttachmentService suitable for use in tests.
64 static std::unique_ptr<AttachmentService> CreateForTest();
65
66 virtual ~AttachmentService();
67
68 // See SyncData::GetOrDownloadAttachments.
69 virtual void GetOrDownloadAttachments(
70 const AttachmentIdList& attachment_ids,
71 const GetOrDownloadCallback& callback) = 0;
72
73 // Schedules the attachments identified by |attachment_ids| to be uploaded to
74 // the server.
75 //
76 // Assumes the attachments are already in the attachment store.
77 //
78 // A request to upload attachments is persistent in that uploads will be
79 // automatically retried if transient errors occur.
80 //
81 // A request to upload attachments does not persist across restarts of Chrome.
82 //
83 // Invokes OnAttachmentUploaded on the Delegate (if provided).
84 virtual void UploadAttachments(const AttachmentIdList& attachment_ids) = 0;
85 };
86
87 } // namespace syncer
88
89 #endif // COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_
OLDNEW
« no previous file with comments | « components/sync/api/attachments/attachment_metadata_unittest.cc ('k') | components/sync/api/attachments/attachment_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698