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

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

Issue 436373002: Move non-API code out of sync/api/attachments/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Apply CR feedback. Created 6 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 | Annotate | Revision Log
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 //
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 SYNC_EXPORT 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<
35 void(const GetOrDownloadResult&, scoped_ptr<AttachmentMap> attachments)>
36 GetOrDownloadCallback;
37
38 // The result of a DropAttachments operation.
39 enum DropResult {
40 DROP_SUCCESS, // No error, all attachments dropped.
41 DROP_UNSPECIFIED_ERROR, // An unspecified error occurred. Some or all
42 // attachments may not have been dropped.
43 };
44
45 typedef base::Callback<void(const DropResult&)> DropCallback;
46
47 // The result of a StoreAttachments operation.
48 enum StoreResult {
49 STORE_SUCCESS, // No error, all attachments stored (at least
50 // locally).
51 STORE_UNSPECIFIED_ERROR, // An unspecified error occurred. Some or all
52 // attachments may not have been stored.
53 };
54
55 typedef base::Callback<void(const StoreResult&)> StoreCallback;
56
57 // An interface that embedder code implements to be notified about different
58 // events that originate from AttachmentService.
59 // This interface will be called from the same thread AttachmentService was
60 // created and called.
61 class Delegate {
62 public:
63 virtual ~Delegate() {}
64
65 // Attachment is uploaded to server and attachment_id is updated with server
66 // url.
67 virtual void OnAttachmentUploaded(const AttachmentId& attachment_id) = 0;
68 };
69
70 AttachmentService();
71 virtual ~AttachmentService();
72
73 // See SyncData::GetOrDownloadAttachments.
74 virtual void GetOrDownloadAttachments(
75 const AttachmentIdList& attachment_ids,
76 const GetOrDownloadCallback& callback) = 0;
77
78 // See SyncData::DropAttachments.
79 virtual void DropAttachments(const AttachmentIdList& attachment_ids,
80 const DropCallback& callback) = 0;
81
82 // Store |attachments| on device and (eventually) upload them to the server.
83 //
84 // Invokes |callback| once the attachments have been written to device
85 // storage.
86 virtual void StoreAttachments(const AttachmentList& attachments,
87 const StoreCallback& callback) = 0;
88 };
89
90 } // namespace syncer
91
92 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_
OLDNEW
« no previous file with comments | « sync/api/attachments/attachment_downloader.cc ('k') | sync/api/attachments/attachment_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698