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

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

Issue 538403004: Revert of Replace AttachmentStore's StoreAttachments with UploadAttachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_ 5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_
6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_ 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_
7 7
8 #include <deque>
9
10 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
12 #include "base/threading/non_thread_safe.h" 10 #include "base/threading/non_thread_safe.h"
13 #include "sync/api/attachments/attachment_store.h" 11 #include "sync/api/attachments/attachment_store.h"
14 #include "sync/internal_api/public/attachments/attachment_downloader.h" 12 #include "sync/internal_api/public/attachments/attachment_downloader.h"
15 #include "sync/internal_api/public/attachments/attachment_service.h" 13 #include "sync/internal_api/public/attachments/attachment_service.h"
16 #include "sync/internal_api/public/attachments/attachment_service_proxy.h" 14 #include "sync/internal_api/public/attachments/attachment_service_proxy.h"
17 #include "sync/internal_api/public/attachments/attachment_uploader.h" 15 #include "sync/internal_api/public/attachments/attachment_uploader.h"
18 16
19 namespace syncer { 17 namespace syncer {
(...skipping 18 matching lines...) Expand all
38 AttachmentServiceImpl(scoped_ptr<AttachmentStore> attachment_store, 36 AttachmentServiceImpl(scoped_ptr<AttachmentStore> attachment_store,
39 scoped_ptr<AttachmentUploader> attachment_uploader, 37 scoped_ptr<AttachmentUploader> attachment_uploader,
40 scoped_ptr<AttachmentDownloader> attachment_downloader, 38 scoped_ptr<AttachmentDownloader> attachment_downloader,
41 Delegate* delegate); 39 Delegate* delegate);
42 virtual ~AttachmentServiceImpl(); 40 virtual ~AttachmentServiceImpl();
43 41
44 // Create an AttachmentServiceImpl suitable for use in tests. 42 // Create an AttachmentServiceImpl suitable for use in tests.
45 static scoped_ptr<syncer::AttachmentService> CreateForTest(); 43 static scoped_ptr<syncer::AttachmentService> CreateForTest();
46 44
47 // AttachmentService implementation. 45 // AttachmentService implementation.
48 virtual AttachmentStore* GetStore() OVERRIDE; 46 virtual void GetOrDownloadAttachments(const AttachmentIdList& attachment_ids,
49 virtual void GetOrDownloadAttachments( 47 const GetOrDownloadCallback& callback)
50 const AttachmentIdList& attachment_ids, 48 OVERRIDE;
51 const GetOrDownloadCallback& callback) OVERRIDE;
52 virtual void DropAttachments(const AttachmentIdList& attachment_ids, 49 virtual void DropAttachments(const AttachmentIdList& attachment_ids,
53 const DropCallback& callback) OVERRIDE; 50 const DropCallback& callback) OVERRIDE;
54 virtual void UploadAttachments( 51 virtual void StoreAttachments(const AttachmentList& attachments,
55 const AttachmentIdSet& attachment_ids) OVERRIDE; 52 const StoreCallback& callback) OVERRIDE;
56 53
57 private: 54 private:
58 class GetOrDownloadState; 55 class GetOrDownloadState;
59 56
60 void ReadDone(const scoped_refptr<GetOrDownloadState>& state, 57 void ReadDone(const scoped_refptr<GetOrDownloadState>& state,
61 const AttachmentStore::Result& result, 58 const AttachmentStore::Result& result,
62 scoped_ptr<AttachmentMap> attachments, 59 scoped_ptr<AttachmentMap> attachments,
63 scoped_ptr<AttachmentIdList> unavailable_attachment_ids); 60 scoped_ptr<AttachmentIdList> unavailable_attachment_ids);
64 void DropDone(const DropCallback& callback, 61 void DropDone(const DropCallback& callback,
65 const AttachmentStore::Result& result); 62 const AttachmentStore::Result& result);
63 void WriteDone(const StoreCallback& callback,
64 const AttachmentStore::Result& result);
66 void UploadDone(const AttachmentUploader::UploadResult& result, 65 void UploadDone(const AttachmentUploader::UploadResult& result,
67 const AttachmentId& attachment_id); 66 const AttachmentId& attachment_id);
68 void DownloadDone(const scoped_refptr<GetOrDownloadState>& state, 67 void DownloadDone(const scoped_refptr<GetOrDownloadState>& state,
69 const AttachmentId& attachment_id, 68 const AttachmentId& attachment_id,
70 const AttachmentDownloader::DownloadResult& result, 69 const AttachmentDownloader::DownloadResult& result,
71 scoped_ptr<Attachment> attachment); 70 scoped_ptr<Attachment> attachment);
72 void ProcessQueuedUploads();
73 void ReadDoneNowUpload(
74 const AttachmentStore::Result& result,
75 scoped_ptr<AttachmentMap> attachments,
76 scoped_ptr<AttachmentIdList> unavailable_attachment_ids);
77 71
78 const scoped_ptr<AttachmentStore> attachment_store_; 72 const scoped_ptr<AttachmentStore> attachment_store_;
79 73
80 // May be null. 74 // May be null.
81 const scoped_ptr<AttachmentUploader> attachment_uploader_; 75 const scoped_ptr<AttachmentUploader> attachment_uploader_;
82 76
83 // May be null. 77 // May be null.
84 const scoped_ptr<AttachmentDownloader> attachment_downloader_; 78 const scoped_ptr<AttachmentDownloader> attachment_downloader_;
85 79
86 // May be null. 80 // May be null.
87 Delegate* delegate_; 81 Delegate* delegate_;
88 82
89 // Queue of attachment ids to be uploaded. Every entry in this queue should
90 // also exist in ids_in_queue_.
91 std::deque<AttachmentId> queue_;
92
93 // Ids of attachments currently being uploaded or queued for upload.
94 AttachmentIdSet ids_in_queue_;
95
96 // Must be last data member. 83 // Must be last data member.
97 base::WeakPtrFactory<AttachmentServiceImpl> weak_ptr_factory_; 84 base::WeakPtrFactory<AttachmentServiceImpl> weak_ptr_factory_;
98 85
99 DISALLOW_COPY_AND_ASSIGN(AttachmentServiceImpl); 86 DISALLOW_COPY_AND_ASSIGN(AttachmentServiceImpl);
100 }; 87 };
101 88
102 } // namespace syncer 89 } // namespace syncer
103 90
104 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_ 91 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698