OLD | NEW |
(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_ENGINE_ATTACHMENTS_ATTACHMENT_UPLOADER_H_ |
| 6 #define COMPONENTS_SYNC_ENGINE_ATTACHMENTS_ATTACHMENT_UPLOADER_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "components/sync/api/attachments/attachment.h" |
| 13 #include "components/sync/base/model_type.h" |
| 14 #include "google_apis/gaia/oauth2_token_service_request.h" |
| 15 |
| 16 namespace net { |
| 17 class URLRequestContextGetter; |
| 18 } // namespace net |
| 19 |
| 20 namespace syncer { |
| 21 |
| 22 // AttachmentUploader is responsible for uploading attachments to the server. |
| 23 class AttachmentUploader { |
| 24 public: |
| 25 // The result of an UploadAttachment operation. |
| 26 enum UploadResult { |
| 27 UPLOAD_SUCCESS, // No error, attachment was uploaded |
| 28 // successfully. |
| 29 UPLOAD_TRANSIENT_ERROR, // A transient error occurred, try again later. |
| 30 UPLOAD_UNSPECIFIED_ERROR, // An unspecified error occurred. |
| 31 }; |
| 32 |
| 33 typedef base::Callback<void(const UploadResult&, const AttachmentId&)> |
| 34 UploadCallback; |
| 35 |
| 36 virtual ~AttachmentUploader(); |
| 37 |
| 38 // Upload |attachment| and invoke |callback| when done. |
| 39 // |
| 40 // |callback| will be invoked when the operation has completed (successfully |
| 41 // or otherwise). |
| 42 // |
| 43 // |callback| will receive an UploadResult code and the AttachmentId of the |
| 44 // newly uploaded attachment. |
| 45 virtual void UploadAttachment(const Attachment& attachment, |
| 46 const UploadCallback& callback) = 0; |
| 47 |
| 48 // Create an instance of AttachmentUploader. |
| 49 // |
| 50 // |sync_service_url| is the URL of the sync service. |
| 51 // |
| 52 // |url_request_context_getter| provides a URLRequestContext. |
| 53 // |
| 54 // |account_id| is the account id to use for uploads. |
| 55 // |
| 56 // |scopes| is the set of scopes to use for uploads. |
| 57 // |
| 58 // |token_service_provider| provides an OAuth2 token service. |
| 59 // |
| 60 // |store_birthday| is the raw, sync store birthday. |
| 61 // |
| 62 // |model_type| is the model type this uploader is used with. |
| 63 static std::unique_ptr<AttachmentUploader> Create( |
| 64 const GURL& sync_service_url, |
| 65 const scoped_refptr<net::URLRequestContextGetter>& |
| 66 url_request_context_getter, |
| 67 const std::string& account_id, |
| 68 const OAuth2TokenService::ScopeSet scopes, |
| 69 const scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider>& |
| 70 token_service_provider, |
| 71 const std::string& store_birthday, |
| 72 ModelType model_type); |
| 73 }; |
| 74 |
| 75 } // namespace syncer |
| 76 |
| 77 #endif // COMPONENTS_SYNC_ENGINE_ATTACHMENTS_ATTACHMENT_UPLOADER_H_ |
OLD | NEW |