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