Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: sync/api/attachments/attachment_store.h

Issue 548373003: Move AttachmentStore ownership to datatype (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SyncableService related changes Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_API_ATTACHMENTS_ATTACHMENT_STORE_H_ 5 #ifndef SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_H_
6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_H_ 6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "sync/api/attachments/attachment.h" 11 #include "sync/api/attachments/attachment.h"
12 #include "sync/api/attachments/attachment_id.h" 12 #include "sync/api/attachments/attachment_id.h"
13 #include "sync/base/sync_export.h" 13 #include "sync/base/sync_export.h"
14 14
15 namespace base { 15 namespace base {
16 class RefCountedMemory; 16 class RefCountedMemory;
17 } // namespace base 17 } // namespace base
18 18
19 namespace syncer { 19 namespace syncer {
20 20
21 class Attachment; 21 class Attachment;
22 class AttachmentId; 22 class AttachmentId;
23 23
24 // A place to locally store and access Attachments. 24 // A place to locally store and access Attachments.
25 // 25 //
26 // Destroying this object does not necessarily cancel outstanding async 26 // Destroying this object does not necessarily cancel outstanding async
27 // operations. If you need cancel like semantics, use WeakPtr in the callbacks. 27 // operations. If you need cancel like semantics, use WeakPtr in the callbacks.
28 class SYNC_EXPORT AttachmentStore { 28 class SYNC_EXPORT AttachmentStore : public base::RefCounted<AttachmentStore> {
29 public: 29 public:
30 AttachmentStore(); 30 AttachmentStore();
31 virtual ~AttachmentStore();
32 31
33 // TODO(maniscalco): Consider udpating Read and Write methods to support 32 // TODO(maniscalco): Consider udpating Read and Write methods to support
34 // resumable transfers (bug 353292). 33 // resumable transfers (bug 353292).
35 34
36 enum Result { 35 enum Result {
37 SUCCESS, // No error, all completed successfully. 36 SUCCESS, // No error, all completed successfully.
38 UNSPECIFIED_ERROR, // An unspecified error occurred for one or more items. 37 UNSPECIFIED_ERROR, // An unspecified error occurred for one or more items.
39 }; 38 };
40 39
41 typedef base::Callback<void(const Result&, 40 typedef base::Callback<void(const Result&,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // 74 //
76 // This does not remove attachments from the server. 75 // This does not remove attachments from the server.
77 // 76 //
78 // |callback| will be invoked when finished. Attempting to drop an attachment 77 // |callback| will be invoked when finished. Attempting to drop an attachment
79 // that does not exist is not an error. If any of the existing attachment 78 // that does not exist is not an error. If any of the existing attachment
80 // could not be dropped, |callback|'s Result will be UNSPECIFIED_ERROR. When 79 // could not be dropped, |callback|'s Result will be UNSPECIFIED_ERROR. When
81 // this happens, some or none of the attachments may have been dropped 80 // this happens, some or none of the attachments may have been dropped
82 // successfully. 81 // successfully.
83 virtual void Drop(const AttachmentIdList& ids, 82 virtual void Drop(const AttachmentIdList& ids,
84 const DropCallback& callback) = 0; 83 const DropCallback& callback) = 0;
84
85 protected:
86 friend class base::RefCounted<AttachmentStore>;
87 virtual ~AttachmentStore();
85 }; 88 };
86 89
87 } // namespace syncer 90 } // namespace syncer
88 91
89 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_H_ 92 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698