blob: 73bc0fbf16e1c8a005d896c0b5db8373c991a16e [file] [log] [blame]
// Copyright 2015 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.
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "sync/api/attachments/attachment.h"
#include "sync/api/attachments/attachment_id.h"
#include "sync/api/attachments/attachment_store.h"
#include "sync/base/sync_export.h"
namespace base {
class SequencedTaskRunner;
} // namespace base
namespace syncer {
// Interface for AttachmentStore backends.
// AttachmentStoreBackend provides interface for different backends (on-disk,
// in-memory). Factory methods in AttachmentStore create corresponding backend
// and pass reference to AttachmentStore.
// All functions in AttachmentStoreBackend mirror corresponding functions in
// AttachmentStore.
// All callbacks and result codes are used directly from AttachmentStore.
// AttachmentStoreFrontend only passes callbacks and results without modifying
// them, there is no need to declare separate set.
class SYNC_EXPORT AttachmentStoreBackend {
explicit AttachmentStoreBackend(
const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner);
virtual ~AttachmentStoreBackend();
virtual void Init(const AttachmentStore::InitCallback& callback) = 0;
virtual void Read(const AttachmentIdList& ids,
const AttachmentStore::ReadCallback& callback) = 0;
virtual void Write(AttachmentStore::Component component,
const AttachmentList& attachments,
const AttachmentStore::WriteCallback& callback) = 0;
virtual void SetReference(AttachmentStore::Component component,
const AttachmentIdList& ids) = 0;
virtual void DropReference(AttachmentStore::Component component,
const AttachmentIdList& ids,
const AttachmentStore::DropCallback& callback) = 0;
virtual void ReadMetadata(
const AttachmentIdList& ids,
const AttachmentStore::ReadMetadataCallback& callback) = 0;
virtual void ReadAllMetadata(
AttachmentStore::Component component,
const AttachmentStore::ReadMetadataCallback& callback) = 0;
// Helper function to post callback on callback_task_runner.
void PostCallback(const base::Closure& callback);
scoped_refptr<base::SequencedTaskRunner> callback_task_runner_;
} // namespace syncer