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

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

Issue 436373002: Move non-API code out of sync/api/attachments/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Apply CR feedback. Created 6 years, 4 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 | Annotate | Revision Log
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_API_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_
6 #define SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/threading/non_thread_safe.h"
11 #include "sync/api/attachments/attachment_downloader.h"
12 #include "sync/api/attachments/attachment_service.h"
13 #include "sync/api/attachments/attachment_service_proxy.h"
14 #include "sync/api/attachments/attachment_store.h"
15 #include "sync/api/attachments/attachment_uploader.h"
16
17 namespace syncer {
18
19 // Implementation of AttachmentService.
20 class SYNC_EXPORT AttachmentServiceImpl : public AttachmentService,
21 public base::NonThreadSafe {
22 public:
23 // |delegate| is optional delegate for AttachmentService to notify about
24 // asynchronous events (AttachmentUploaded). Pass NULL if delegate is not
25 // provided. AttachmentService doesn't take ownership of delegate, the pointer
26 // must be valid throughout AttachmentService lifetime.
27 //
28 // |attachment_uploader| is optional. If null, attachments will never be
29 // uploaded to the sync server and |delegate|'s OnAttachmentUploaded will
30 // never be invoked.
31 //
32 // |attachment_downloader| is optional. If null, attachments will never be
33 // downloaded. Only attachments in |attachment_store| will be returned from
34 // GetOrDownloadAttachments.
35
36 AttachmentServiceImpl(scoped_ptr<AttachmentStore> attachment_store,
37 scoped_ptr<AttachmentUploader> attachment_uploader,
38 scoped_ptr<AttachmentDownloader> attachment_downloader,
39 Delegate* delegate);
40 virtual ~AttachmentServiceImpl();
41
42 // Create an AttachmentServiceImpl suitable for use in tests.
43 static scoped_ptr<syncer::AttachmentService> CreateForTest();
44
45 // AttachmentService implementation.
46 virtual void GetOrDownloadAttachments(const AttachmentIdList& attachment_ids,
47 const GetOrDownloadCallback& callback)
48 OVERRIDE;
49 virtual void DropAttachments(const AttachmentIdList& attachment_ids,
50 const DropCallback& callback) OVERRIDE;
51 virtual void StoreAttachments(const AttachmentList& attachments,
52 const StoreCallback& callback) OVERRIDE;
53
54 private:
55 class GetOrDownloadState;
56
57 void ReadDone(const scoped_refptr<GetOrDownloadState>& state,
58 const AttachmentStore::Result& result,
59 scoped_ptr<AttachmentMap> attachments,
60 scoped_ptr<AttachmentIdList> unavailable_attachment_ids);
61 void DropDone(const DropCallback& callback,
62 const AttachmentStore::Result& result);
63 void WriteDone(const StoreCallback& callback,
64 const AttachmentStore::Result& result);
65 void UploadDone(const AttachmentUploader::UploadResult& result,
66 const AttachmentId& attachment_id);
67 void DownloadDone(const scoped_refptr<GetOrDownloadState>& state,
68 const AttachmentId& attachment_id,
69 const AttachmentDownloader::DownloadResult& result,
70 scoped_ptr<Attachment> attachment);
71
72 const scoped_ptr<AttachmentStore> attachment_store_;
73
74 // May be null.
75 const scoped_ptr<AttachmentUploader> attachment_uploader_;
76
77 // May be null.
78 const scoped_ptr<AttachmentDownloader> attachment_downloader_;
79
80 // May be null.
81 Delegate* delegate_;
82
83 // Must be last data member.
84 base::WeakPtrFactory<AttachmentServiceImpl> weak_ptr_factory_;
85
86 DISALLOW_COPY_AND_ASSIGN(AttachmentServiceImpl);
87 };
88
89 } // namespace syncer
90
91 #endif // SYNC_API_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « sync/api/attachments/attachment_service.cc ('k') | sync/api/attachments/attachment_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698