blob: 1d623ce90ba556bbab9aba342d5df7c59a654ca7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// 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_STORE_H_
#define SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_H_
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "sync/base/sync_export.h"
namespace base {
class RefCountedMemory;
} // namespace base
namespace syncer {
class Attachment;
class AttachmentId;
// A place to locally store and access Attachments.
class SYNC_EXPORT AttachmentStore {
public:
AttachmentStore();
virtual ~AttachmentStore();
// TODO(maniscalco): Consider udpating Read and Write methods to support
// resumable transfers (bug 353292).
enum Result {
SUCCESS, // No error.
NOT_FOUND, // Attachment was not found or does not exist.
UNSPECIFIED_ERROR, // An unspecified error occurred.
};
typedef base::Callback<void(const Result&, scoped_ptr<Attachment>)>
ReadCallback;
typedef base::Callback<void(const Result&, const AttachmentId& id)>
WriteCallback;
typedef base::Callback<void(const Result&)> DropCallback;
// Asynchronously reads the attachment identified by |id|.
//
// |callback| will be invoked when finished. If the attachment does not exist,
// |callback|'s Result will be NOT_FOUND and |callback|'s attachment will be
// null.
virtual void Read(const AttachmentId& id, const ReadCallback& callback) = 0;
// Asynchronously writes |bytes| to the store.
//
// |callback| will be invoked when finished.
virtual void Write(const scoped_refptr<base::RefCountedMemory>& bytes,
const WriteCallback& callback) = 0;
// Asynchronously drops the attchment with the given id from this store.
//
// This does not remove the attachment from the server. |callback| will be
// invoked when finished. If the attachment does not exist, |callback|'s
// Result will be NOT_FOUND.
virtual void Drop(const AttachmentId& id, const DropCallback& callback) = 0;
};
} // namespace syncer
#endif // SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_H_
|