| 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 COMPONENTS_SYNC_CORE_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | 5 #ifndef COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
| 6 #define COMPONENTS_SYNC_CORE_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | 6 #define COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "components/sync/api/attachments/attachment.h" | 12 #include "components/sync/api/attachments/attachment.h" |
| 13 | 13 |
| 14 namespace syncer { | 14 namespace syncer { |
| 15 | 15 |
| 16 class AttachmentDownloader; |
| 16 class AttachmentStore; | 17 class AttachmentStore; |
| 18 class AttachmentStoreForSync; |
| 19 class AttachmentUploader; |
| 17 class SyncData; | 20 class SyncData; |
| 18 | 21 |
| 19 // AttachmentService is responsible for managing a model type's attachments. | 22 // AttachmentService is responsible for managing a model type's attachments. |
| 20 // | 23 // |
| 21 // Outside of sync code, AttachmentService shouldn't be used directly. Instead | 24 // Outside of sync code, AttachmentService shouldn't be used directly. Instead |
| 22 // use the functionality provided by SyncData and SyncChangeProcessor. | 25 // use the functionality provided by SyncData and SyncChangeProcessor. |
| 23 // | 26 // |
| 24 // Destroying this object does not necessarily cancel outstanding async | 27 // Destroying this object does not necessarily cancel outstanding async |
| 25 // operations. If you need cancel like semantics, use WeakPtr in the callbacks. | 28 // operations. If you need cancel like semantics, use WeakPtr in the callbacks. |
| 26 class AttachmentService { | 29 class AttachmentService { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 41 // created and called. | 44 // created and called. |
| 42 class Delegate { | 45 class Delegate { |
| 43 public: | 46 public: |
| 44 virtual ~Delegate() {} | 47 virtual ~Delegate() {} |
| 45 | 48 |
| 46 // Attachment is uploaded to server and attachment_id is updated with server | 49 // Attachment is uploaded to server and attachment_id is updated with server |
| 47 // url. | 50 // url. |
| 48 virtual void OnAttachmentUploaded(const AttachmentId& attachment_id) = 0; | 51 virtual void OnAttachmentUploaded(const AttachmentId& attachment_id) = 0; |
| 49 }; | 52 }; |
| 50 | 53 |
| 51 AttachmentService(); | 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 |
| 52 virtual ~AttachmentService(); | 66 virtual ~AttachmentService(); |
| 53 | 67 |
| 54 // See SyncData::GetOrDownloadAttachments. | 68 // See SyncData::GetOrDownloadAttachments. |
| 55 virtual void GetOrDownloadAttachments( | 69 virtual void GetOrDownloadAttachments( |
| 56 const AttachmentIdList& attachment_ids, | 70 const AttachmentIdList& attachment_ids, |
| 57 const GetOrDownloadCallback& callback) = 0; | 71 const GetOrDownloadCallback& callback) = 0; |
| 58 | 72 |
| 59 // Schedules the attachments identified by |attachment_ids| to be uploaded to | 73 // Schedules the attachments identified by |attachment_ids| to be uploaded to |
| 60 // the server. | 74 // the server. |
| 61 // | 75 // |
| 62 // Assumes the attachments are already in the attachment store. | 76 // Assumes the attachments are already in the attachment store. |
| 63 // | 77 // |
| 64 // A request to upload attachments is persistent in that uploads will be | 78 // A request to upload attachments is persistent in that uploads will be |
| 65 // automatically retried if transient errors occur. | 79 // automatically retried if transient errors occur. |
| 66 // | 80 // |
| 67 // A request to upload attachments does not persist across restarts of Chrome. | 81 // A request to upload attachments does not persist across restarts of Chrome. |
| 68 // | 82 // |
| 69 // Invokes OnAttachmentUploaded on the Delegate (if provided). | 83 // Invokes OnAttachmentUploaded on the Delegate (if provided). |
| 70 virtual void UploadAttachments(const AttachmentIdList& attachment_ids) = 0; | 84 virtual void UploadAttachments(const AttachmentIdList& attachment_ids) = 0; |
| 71 }; | 85 }; |
| 72 | 86 |
| 73 } // namespace syncer | 87 } // namespace syncer |
| 74 | 88 |
| 75 #endif // COMPONENTS_SYNC_CORE_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | 89 #endif // COMPONENTS_SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
| OLD | NEW |