OLD | NEW |
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_SERVICE_PROXY_H_ | 5 #ifndef SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ |
6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ | 6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // from which the method was called. | 26 // from which the method was called. |
27 // | 27 // |
28 // This class does not own its wrapped AttachmentService object. This class | 28 // This class does not own its wrapped AttachmentService object. This class |
29 // holds a WeakPtr to the wrapped object. Once the the wrapped object is | 29 // holds a WeakPtr to the wrapped object. Once the the wrapped object is |
30 // destroyed, method calls on this object will be no-ops. | 30 // destroyed, method calls on this object will be no-ops. |
31 // | 31 // |
32 // Users of this class should take care to destroy the wrapped object on the | 32 // Users of this class should take care to destroy the wrapped object on the |
33 // correct thread (wrapped_task_runner). | 33 // correct thread (wrapped_task_runner). |
34 // | 34 // |
35 // This class is thread-safe. | 35 // This class is thread-safe. |
36 class SYNC_EXPORT AttachmentServiceProxy : public AttachmentService { | 36 class SYNC_EXPORT AttachmentServiceProxy |
| 37 : public AttachmentService, |
| 38 public base::RefCountedThreadSafe<AttachmentServiceProxy> { |
37 public: | 39 public: |
38 // Default copy and assignment are welcome. | 40 // Default copy and assignment are welcome. |
39 | 41 |
40 // Construct an invalid AttachmentServiceProxy. | 42 // Construct an invalid AttachmentServiceProxy. |
41 AttachmentServiceProxy(); | 43 AttachmentServiceProxy(); |
42 | 44 |
43 // Construct an AttachmentServiceProxy that forwards calls to |wrapped| on the | 45 // Construct an AttachmentServiceProxy that forwards calls to |wrapped| on the |
44 // |wrapped_task_runner| thread. | 46 // |wrapped_task_runner| thread. |
45 AttachmentServiceProxy( | 47 AttachmentServiceProxy( |
46 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, | 48 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner, |
47 base::WeakPtr<syncer::AttachmentService> wrapped); | 49 base::WeakPtr<syncer::AttachmentService> wrapped); |
48 | 50 |
49 virtual ~AttachmentServiceProxy(); | |
50 | |
51 // AttachmentService implementation. | 51 // AttachmentService implementation. |
52 virtual void GetOrDownloadAttachments(const AttachmentIdList& attachment_ids, | 52 virtual void GetOrDownloadAttachments(const AttachmentIdList& attachment_ids, |
53 const GetOrDownloadCallback& callback) | 53 const GetOrDownloadCallback& callback) |
54 OVERRIDE; | 54 OVERRIDE; |
55 virtual void DropAttachments(const AttachmentIdList& attachment_ids, | 55 virtual void DropAttachments(const AttachmentIdList& attachment_ids, |
56 const DropCallback& callback) OVERRIDE; | 56 const DropCallback& callback) OVERRIDE; |
57 virtual void OnSyncDataAdd(const SyncData& sync_data) OVERRIDE; | 57 virtual void OnSyncDataAdd(const SyncData& sync_data) OVERRIDE; |
58 virtual void OnSyncDataDelete(const SyncData& sync_data) OVERRIDE; | 58 virtual void OnSyncDataDelete(const SyncData& sync_data) OVERRIDE; |
59 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, | 59 virtual void OnSyncDataUpdate(const AttachmentIdList& old_attachment_ids, |
60 const SyncData& updated_sync_data) OVERRIDE; | 60 const SyncData& updated_sync_data) OVERRIDE; |
61 | 61 |
| 62 protected: |
| 63 virtual ~AttachmentServiceProxy(); |
| 64 |
62 private: | 65 private: |
| 66 friend class base::RefCountedThreadSafe<AttachmentServiceProxy>; |
| 67 |
63 scoped_refptr<base::SequencedTaskRunner> wrapped_task_runner_; | 68 scoped_refptr<base::SequencedTaskRunner> wrapped_task_runner_; |
64 // wrapped_ must only be dereferenced on the wrapped_task_runner_ thread. | 69 // wrapped_ must only be dereferenced on the wrapped_task_runner_ thread. |
65 base::WeakPtr<AttachmentService> wrapped_; | 70 base::WeakPtr<AttachmentService> wrapped_; |
66 }; | 71 }; |
67 | 72 |
68 } // namespace syncer | 73 } // namespace syncer |
69 | 74 |
70 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ | 75 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_PROXY_H_ |
OLD | NEW |