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

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

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

Powered by Google App Engine
This is Rietveld 408576698