blob: d07e8f0eedb29efd1a0be9f2551d131375112e4d [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/sync/engine/attachments/fake_attachment_downloader.h"
#include <memory>
#include "base/bind.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/sync/engine/attachments/attachment_util.h"
namespace syncer {
FakeAttachmentDownloader::FakeAttachmentDownloader() {}
FakeAttachmentDownloader::~FakeAttachmentDownloader() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}
void FakeAttachmentDownloader::DownloadAttachment(
const AttachmentId& attachment_id,
const DownloadCallback& callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// This is happy fake downloader, it always successfully downloads empty
// attachment.
scoped_refptr<base::RefCountedMemory> data(new base::RefCountedBytes());
std::unique_ptr<Attachment> attachment = std::make_unique<Attachment>(
Attachment::CreateFromParts(attachment_id, data));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(callback, DOWNLOAD_SUCCESS, base::Passed(&attachment)));
}
} // namespace syncer