Chromium Code Reviews| Index: sync/api/attachments/attachment_service.h |
| diff --git a/sync/api/attachments/attachment_service.h b/sync/api/attachments/attachment_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..92d75c0583c728b6113dcf7d6b658044377ce841 |
| --- /dev/null |
| +++ b/sync/api/attachments/attachment_service.h |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
| +#define SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/callback.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "sync/api/attachments/attachment.h" |
| +#include "sync/base/sync_export.h" |
| +#include "sync/protocol/sync.pb.h" |
| + |
| +namespace syncer { |
| + |
| +class SyncData; |
| + |
| +// AttachmentService is responsible for managing a model type's attachments. |
| +// |
| +// Outside of sync code, AttachmentService shouldn't be used directly. Instead |
| +// use the functionality provided by SyncData and SyncChangeProcessor. |
| +class SYNC_EXPORT AttachmentService { |
| + public: |
| + // The result of a GetAttachments operation. |
| + enum GetResult { |
| + GET_SUCCESS, // No error. |
| + GET_NOT_FOUND, // Attachment was not found or does not exist. |
| + GET_UNSPECIFIED_ERROR, // An unspecified error occurred. |
| + }; |
| + |
| + typedef base::Callback< |
| + void(const GetResult&, const AttachmentMap& attachments)> GetCallback; |
| + |
| + // The result of a DropAttachments operation. |
| + enum DropResult { |
| + DROP_SUCCESS, // No error. |
| + DROP_UNSPECIFIED_ERROR, // An unspecified error occurred. |
| + }; |
| + |
| + typedef base::Callback<void(const DropResult&)> DropCallback; |
| + |
| + AttachmentService(); |
| + virtual ~AttachmentService(); |
| + |
| + // See SyncData::GetAttachments. |
| + virtual void GetAttachments(const AttachmentIdList& attachment_ids, |
| + const GetCallback& callback) = 0; |
| + |
| + // See SyncData::DropAttachments. |
| + virtual void DropAttachments(const AttachmentIdList& attachment_ids, |
| + const DropCallback& callback) = 0; |
| + |
| + // This method should be called when a SyncData is about to be added to the |
| + // sync database so we have a chance to persist the Attachment locally and |
| + // schedule it for upload to the sync server. |
| + virtual void OnSyncDataAdd(const SyncData& sync_data) = 0; |
| + |
| + // This method should be called when a SyncData is about to be deleted from |
| + // the sync database so we can remove any unreferenced attachments from local |
| + // storage. |
| + virtual void OnSyncDataDelete(const SyncData& sync_data) = 0; |
| + |
| + // This method should be called when a SyncData is about to be updated so we |
| + // can remove unreferenced attachments from local storage and ensure new |
| + // attachments are persisted and uploaded to the sync server. |
| + virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, |
| + const SyncData& updated_sync_data) = 0; |
| +}; |
| + |
| +} // namespace syncer |
| + |
| +#endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVaICE_H_ |
|
tim (not reviewing)
2014/03/10 22:55:58
did this pass presubmit? SERVaICE_H
maniscalco
2014/03/18 20:49:18
Heh, unfortunately, it does pass. Fixed.
|