Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / sync / internal_api / attachments / fake_attachment_downloader.cc
blob299c4184287ff8eabb82bb96265a668a0fd54969
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.
5 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h"
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h"
9 #include "sync/internal_api/public/attachments/attachment_util.h"
11 namespace syncer {
13 FakeAttachmentDownloader::FakeAttachmentDownloader() {
16 FakeAttachmentDownloader::~FakeAttachmentDownloader() {
17 DCHECK(CalledOnValidThread());
20 void FakeAttachmentDownloader::DownloadAttachment(
21 const AttachmentId& attachment_id,
22 const DownloadCallback& callback) {
23 DCHECK(CalledOnValidThread());
24 // This is happy fake downloader, it always successfully downloads empty
25 // attachment.
26 scoped_refptr<base::RefCountedMemory> data(new base::RefCountedBytes());
27 scoped_ptr<Attachment> attachment;
28 attachment.reset(
29 new Attachment(Attachment::CreateFromParts(attachment_id, data)));
30 base::MessageLoop::current()->PostTask(
31 FROM_HERE,
32 base::Bind(callback, DOWNLOAD_SUCCESS, base::Passed(&attachment)));
35 } // namespace syncer