| OLD | NEW |
| (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 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/location.h" | |
| 9 #include "base/single_thread_task_runner.h" | |
| 10 #include "base/threading/thread_task_runner_handle.h" | |
| 11 #include "sync/internal_api/public/attachments/attachment_util.h" | |
| 12 | |
| 13 namespace syncer { | |
| 14 | |
| 15 FakeAttachmentDownloader::FakeAttachmentDownloader() { | |
| 16 } | |
| 17 | |
| 18 FakeAttachmentDownloader::~FakeAttachmentDownloader() { | |
| 19 DCHECK(CalledOnValidThread()); | |
| 20 } | |
| 21 | |
| 22 void FakeAttachmentDownloader::DownloadAttachment( | |
| 23 const AttachmentId& attachment_id, | |
| 24 const DownloadCallback& callback) { | |
| 25 DCHECK(CalledOnValidThread()); | |
| 26 // This is happy fake downloader, it always successfully downloads empty | |
| 27 // attachment. | |
| 28 scoped_refptr<base::RefCountedMemory> data(new base::RefCountedBytes()); | |
| 29 std::unique_ptr<Attachment> attachment; | |
| 30 attachment.reset( | |
| 31 new Attachment(Attachment::CreateFromParts(attachment_id, data))); | |
| 32 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 33 FROM_HERE, | |
| 34 base::Bind(callback, DOWNLOAD_SUCCESS, base::Passed(&attachment))); | |
| 35 } | |
| 36 | |
| 37 } // namespace syncer | |
| OLD | NEW |