| 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_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> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // must be valid throughout AttachmentService lifetime. | 28 // must be valid throughout AttachmentService lifetime. |
| 29 // | 29 // |
| 30 // |attachment_uploader| is optional. If null, attachments will never be | 30 // |attachment_uploader| is optional. If null, attachments will never be |
| 31 // uploaded to the sync server and |delegate|'s OnAttachmentUploaded will | 31 // uploaded to the sync server and |delegate|'s OnAttachmentUploaded will |
| 32 // never be invoked. | 32 // never be invoked. |
| 33 // | 33 // |
| 34 // |attachment_downloader| is optional. If null, attachments will never be | 34 // |attachment_downloader| is optional. If null, attachments will never be |
| 35 // downloaded. Only attachments in |attachment_store| will be returned from | 35 // downloaded. Only attachments in |attachment_store| will be returned from |
| 36 // GetOrDownloadAttachments. | 36 // GetOrDownloadAttachments. |
| 37 | 37 |
| 38 AttachmentServiceImpl(scoped_ptr<AttachmentStore> attachment_store, | 38 AttachmentServiceImpl(scoped_refptr<AttachmentStore> attachment_store, |
| 39 scoped_ptr<AttachmentUploader> attachment_uploader, | 39 scoped_ptr<AttachmentUploader> attachment_uploader, |
| 40 scoped_ptr<AttachmentDownloader> attachment_downloader, | 40 scoped_ptr<AttachmentDownloader> attachment_downloader, |
| 41 Delegate* delegate); | 41 Delegate* delegate); |
| 42 virtual ~AttachmentServiceImpl(); | 42 virtual ~AttachmentServiceImpl(); |
| 43 | 43 |
| 44 // Create an AttachmentServiceImpl suitable for use in tests. | 44 // Create an AttachmentServiceImpl suitable for use in tests. |
| 45 static scoped_ptr<syncer::AttachmentService> CreateForTest(); | 45 static scoped_ptr<syncer::AttachmentService> CreateForTest(); |
| 46 | 46 |
| 47 // AttachmentService implementation. | 47 // AttachmentService implementation. |
| 48 virtual AttachmentStore* GetStore() OVERRIDE; | 48 virtual AttachmentStore* GetStore() OVERRIDE; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 68 void DownloadDone(const scoped_refptr<GetOrDownloadState>& state, | 68 void DownloadDone(const scoped_refptr<GetOrDownloadState>& state, |
| 69 const AttachmentId& attachment_id, | 69 const AttachmentId& attachment_id, |
| 70 const AttachmentDownloader::DownloadResult& result, | 70 const AttachmentDownloader::DownloadResult& result, |
| 71 scoped_ptr<Attachment> attachment); | 71 scoped_ptr<Attachment> attachment); |
| 72 void ProcessQueuedUploads(); | 72 void ProcessQueuedUploads(); |
| 73 void ReadDoneNowUpload( | 73 void ReadDoneNowUpload( |
| 74 const AttachmentStore::Result& result, | 74 const AttachmentStore::Result& result, |
| 75 scoped_ptr<AttachmentMap> attachments, | 75 scoped_ptr<AttachmentMap> attachments, |
| 76 scoped_ptr<AttachmentIdList> unavailable_attachment_ids); | 76 scoped_ptr<AttachmentIdList> unavailable_attachment_ids); |
| 77 | 77 |
| 78 const scoped_ptr<AttachmentStore> attachment_store_; | 78 scoped_refptr<AttachmentStore> attachment_store_; |
| 79 | 79 |
| 80 // May be null. | 80 // May be null. |
| 81 const scoped_ptr<AttachmentUploader> attachment_uploader_; | 81 const scoped_ptr<AttachmentUploader> attachment_uploader_; |
| 82 | 82 |
| 83 // May be null. | 83 // May be null. |
| 84 const scoped_ptr<AttachmentDownloader> attachment_downloader_; | 84 const scoped_ptr<AttachmentDownloader> attachment_downloader_; |
| 85 | 85 |
| 86 // May be null. | 86 // May be null. |
| 87 Delegate* delegate_; | 87 Delegate* delegate_; |
| 88 | 88 |
| 89 // Queue of attachment ids to be uploaded. Every entry in this queue should | 89 // Queue of attachment ids to be uploaded. Every entry in this queue should |
| 90 // also exist in ids_in_queue_. | 90 // also exist in ids_in_queue_. |
| 91 std::deque<AttachmentId> queue_; | 91 std::deque<AttachmentId> queue_; |
| 92 | 92 |
| 93 // Ids of attachments currently being uploaded or queued for upload. | 93 // Ids of attachments currently being uploaded or queued for upload. |
| 94 AttachmentIdSet ids_in_queue_; | 94 AttachmentIdSet ids_in_queue_; |
| 95 | 95 |
| 96 // Must be last data member. | 96 // Must be last data member. |
| 97 base::WeakPtrFactory<AttachmentServiceImpl> weak_ptr_factory_; | 97 base::WeakPtrFactory<AttachmentServiceImpl> weak_ptr_factory_; |
| 98 | 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(AttachmentServiceImpl); | 99 DISALLOW_COPY_AND_ASSIGN(AttachmentServiceImpl); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 } // namespace syncer | 102 } // namespace syncer |
| 103 | 103 |
| 104 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_ | 104 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_ |
| OLD | NEW |