OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SYNC_API_ATTACHMENTS_ATTACHMENT_UPLOADER_H_ | 5 #ifndef SYNC_API_ATTACHMENTS_ATTACHMENT_UPLOADER_H_ |
6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_UPLOADER_H_ | 6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_UPLOADER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | |
12 #include "sync/api/attachments/attachment.h" | 11 #include "sync/api/attachments/attachment.h" |
13 #include "sync/base/sync_export.h" | 12 #include "sync/base/sync_export.h" |
14 | 13 |
15 namespace syncer { | 14 namespace syncer { |
16 | 15 |
17 // AttachmentUploader is responsible for uploading attachments to the server. | 16 // AttachmentUploader is responsible for uploading attachments to the server. |
18 class SYNC_EXPORT AttachmentUploader { | 17 class SYNC_EXPORT AttachmentUploader { |
19 public: | 18 public: |
20 // The result of an UploadAttachment operation. | 19 // The result of an UploadAttachment operation. |
21 enum UploadResult { | 20 enum UploadResult { |
22 UPLOAD_SUCCESS, // No error, attachment was uploaded | 21 UPLOAD_SUCCESS, // No error, attachment was uploaded |
23 // successfully. | 22 // successfully. |
24 UPLOAD_UNSPECIFIED_ERROR, // An unspecified error occurred. | 23 UPLOAD_UNSPECIFIED_ERROR, // An unspecified error occurred. |
25 }; | 24 }; |
26 | 25 |
27 typedef base::Callback<void(const UploadResult&, const AttachmentId&)> | 26 typedef base::Callback<void(const UploadResult&, const AttachmentId&)> |
28 UploadCallback; | 27 UploadCallback; |
29 | 28 |
30 AttachmentUploader(); | 29 AttachmentUploader(); |
31 virtual ~AttachmentUploader(); | 30 virtual ~AttachmentUploader(); |
32 | 31 |
33 // Upload |attachment| and invoke |callback| when done. | 32 // Upload |attachment| and invoke |callback| when done. |
34 // | 33 // |
35 // |callback| will be invoked when the operation has completed (successfully | 34 // |callback| will be invoked when the operation has completed (successfully |
36 // or otherwise). | 35 // or otherwise). |
37 // | 36 // |
38 // |callback| will receive an UploadResult code and an updated AttachmentId | 37 // |callback| will receive an UploadResult code and an updated AttachmentId |
39 // |containing the server address of the newly uploaded attachment. | 38 // containing the server address of the newly uploaded attachment. |
40 virtual void UploadAttachment(const Attachment& attachment, | 39 virtual void UploadAttachment(const Attachment& attachment, |
41 const UploadCallback& callback) = 0; | 40 const UploadCallback& callback) = 0; |
42 }; | 41 }; |
43 | 42 |
44 } // namespace syncer | 43 } // namespace syncer |
45 | 44 |
46 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_UPLOADER_H_ | 45 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_UPLOADER_H_ |
OLD | NEW |