| 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_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 11 #include "sync/api/attachments/attachment.h" | 12 #include "sync/api/attachments/attachment.h" |
| 12 #include "sync/base/sync_export.h" | 13 #include "sync/base/sync_export.h" |
| 13 | 14 |
| 14 namespace syncer { | 15 namespace syncer { |
| 15 | 16 |
| 16 class AttachmentStore; | 17 class AttachmentStore; |
| 17 class SyncData; | 18 class SyncData; |
| 18 | 19 |
| 19 // AttachmentService is responsible for managing a model type's attachments. | 20 // AttachmentService is responsible for managing a model type's attachments. |
| 20 // | 21 // |
| 21 // Outside of sync code, AttachmentService shouldn't be used directly. Instead | 22 // Outside of sync code, AttachmentService shouldn't be used directly. Instead |
| 22 // use the functionality provided by SyncData and SyncChangeProcessor. | 23 // use the functionality provided by SyncData and SyncChangeProcessor. |
| 23 // | 24 // |
| 24 // Destroying this object does not necessarily cancel outstanding async | 25 // Destroying this object does not necessarily cancel outstanding async |
| 25 // operations. If you need cancel like semantics, use WeakPtr in the callbacks. | 26 // operations. If you need cancel like semantics, use WeakPtr in the callbacks. |
| 26 class SYNC_EXPORT AttachmentService { | 27 class SYNC_EXPORT AttachmentService { |
| 27 public: | 28 public: |
| 28 // The result of a GetOrDownloadAttachments operation. | 29 // The result of a GetOrDownloadAttachments operation. |
| 29 enum GetOrDownloadResult { | 30 enum GetOrDownloadResult { |
| 30 GET_SUCCESS, // No error, all attachments returned. | 31 GET_SUCCESS, // No error, all attachments returned. |
| 31 GET_UNSPECIFIED_ERROR, // An unspecified error occurred. | 32 GET_UNSPECIFIED_ERROR, // An unspecified error occurred. |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 typedef base::Callback< | 35 typedef base::Callback<void(const GetOrDownloadResult&, |
| 35 void(const GetOrDownloadResult&, scoped_ptr<AttachmentMap> attachments)> | 36 std::unique_ptr<AttachmentMap> attachments)> |
| 36 GetOrDownloadCallback; | 37 GetOrDownloadCallback; |
| 37 | 38 |
| 38 // An interface that embedder code implements to be notified about different | 39 // An interface that embedder code implements to be notified about different |
| 39 // events that originate from AttachmentService. | 40 // events that originate from AttachmentService. |
| 40 // This interface will be called from the same thread AttachmentService was | 41 // This interface will be called from the same thread AttachmentService was |
| 41 // created and called. | 42 // created and called. |
| 42 class Delegate { | 43 class Delegate { |
| 43 public: | 44 public: |
| 44 virtual ~Delegate() {} | 45 virtual ~Delegate() {} |
| 45 | 46 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 66 // | 67 // |
| 67 // A request to upload attachments does not persist across restarts of Chrome. | 68 // A request to upload attachments does not persist across restarts of Chrome. |
| 68 // | 69 // |
| 69 // Invokes OnAttachmentUploaded on the Delegate (if provided). | 70 // Invokes OnAttachmentUploaded on the Delegate (if provided). |
| 70 virtual void UploadAttachments(const AttachmentIdList& attachment_ids) = 0; | 71 virtual void UploadAttachments(const AttachmentIdList& attachment_ids) = 0; |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 } // namespace syncer | 74 } // namespace syncer |
| 74 | 75 |
| 75 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_H_ | 76 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
| OLD | NEW |