Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / sync / internal_api / attachments / fake_attachment_downloader.cc
blob1f2795e7dfdd849c42e122f13de4c907068555a3
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"
10 namespace syncer {
12 FakeAttachmentDownloader::FakeAttachmentDownloader() {
15 FakeAttachmentDownloader::~FakeAttachmentDownloader() {
16 DCHECK(CalledOnValidThread());
19 void FakeAttachmentDownloader::DownloadAttachment(
20 const AttachmentId& attachment_id,
21 const DownloadCallback& callback) {
22 DCHECK(CalledOnValidThread());
23 // This is happy fake downloader, it always successfully downloads empty
24 // attachment.
25 scoped_refptr<base::RefCountedMemory> data(new base::RefCountedBytes());
26 scoped_ptr<Attachment> attachment;
27 attachment.reset(
28 new Attachment(Attachment::CreateWithId(attachment_id, data)));
29 base::MessageLoop::current()->PostTask(
30 FROM_HERE,
31 base::Bind(callback, DOWNLOAD_SUCCESS, base::Passed(&attachment)));
34 } // namespace syncer