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

Side by Side Diff: sync/internal_api/public/attachments/attachment_store_proxy.h

Issue 601553004: Refactor FakeAttachmentStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_STORE_PROXY_H_
6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_STORE_PROXY_H_
7
8 #include <map>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/stl_util.h"
13 #include "base/threading/non_thread_safe.h"
14 #include "sync/api/attachments/attachment_store.h"
15 #include "sync/base/sync_export.h"
16
17 namespace base {
18 class SequencedTaskRunner;
19 } // namespace base
20
21 namespace sync_pb {
22 class AttachmentId;
23 } // namespace sync_pb
24
25 namespace syncer {
26
27 class Attachment;
28
29 // AttachmentStoreproxy is helper to post AttachmentStore calls to backend on
maniscalco 2014/09/29 20:57:52 s/Storeproxy/StoreProxy/
pavely 2014/09/29 23:27:08 Done.
30 // different thread. Backend is expected to know on which thread to post
31 // callbacks with results.
32 // AttachmentStoreProxy takes ownership of backend. Backend is deleted by
maniscalco 2014/09/29 20:57:52 I'd remove the mention of using DeleteSoon as it's
pavely 2014/09/29 23:27:08 Done.
33 // posting DeleteSoon on backend thread.
34 class SYNC_EXPORT AttachmentStoreProxy : public AttachmentStore,
maniscalco 2014/09/29 20:57:52 Consider adding a unit test for this class. Sure,
pavely 2014/09/29 23:27:08 Done.
35 public base::NonThreadSafe {
36 public:
37 AttachmentStoreProxy(
maniscalco 2014/09/29 20:57:52 As we discussed, AttachmentStoreProxy is similar t
maniscalco 2014/09/29 20:57:52 It's worth documenting that this class promises to
maniscalco 2014/09/29 20:57:52 nit: I think the style guide would have us pass ba
pavely 2014/09/29 23:27:08 Done.
pavely 2014/09/29 23:27:08 No, it is not that strict. http://google-styleguid
pavely 2014/09/29 23:27:08 Done.
38 scoped_ptr<AttachmentStoreBase> backend,
39 const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner);
40
41 // AttachmentStore implementation.
42 virtual void Read(const AttachmentIdList& id,
43 const ReadCallback& callback) OVERRIDE;
44 virtual void Write(const AttachmentList& attachments,
45 const WriteCallback& callback) OVERRIDE;
46 virtual void Drop(const AttachmentIdList& id,
47 const DropCallback& callback) OVERRIDE;
48
49 private:
50 virtual ~AttachmentStoreProxy();
51
52 // AttachmentStoreProxy controls backend's lifetime. It is safe for
53 // AttachmentStoreProxy to bind backend through base::Unretained for posts.
54 // Backend is deleted by posting DeleteSoon on backend_task_runner, after this
55 // backend_ pointer is invalid.
56 scoped_ptr<AttachmentStoreBase> backend_;
57 scoped_refptr<base::SequencedTaskRunner> backend_task_runner_;
58
59 DISALLOW_COPY_AND_ASSIGN(AttachmentStoreProxy);
60 };
61
62 } // namespace syncer
63
64 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_STORE_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698