OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 "components/download/internal/noop_store.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "components/download/internal/entry.h" |
| 10 |
| 11 namespace download { |
| 12 |
| 13 NoopStore::NoopStore() : initialized_(false), weak_ptr_factory_(this) {} |
| 14 |
| 15 NoopStore::~NoopStore() = default; |
| 16 |
| 17 bool NoopStore::IsInitialized() { |
| 18 return initialized_; |
| 19 } |
| 20 |
| 21 void NoopStore::Initialize(InitCallback callback) { |
| 22 DCHECK(!IsInitialized()); |
| 23 |
| 24 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 25 FROM_HERE, |
| 26 base::BindOnce(&NoopStore::OnInitFinished, weak_ptr_factory_.GetWeakPtr(), |
| 27 std::move(callback))); |
| 28 } |
| 29 |
| 30 void NoopStore::Destroy(StoreCallback callback) { |
| 31 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 32 FROM_HERE, base::BindOnce(std::move(callback), true /** success */)); |
| 33 } |
| 34 |
| 35 void NoopStore::Update(const Entry& entry, StoreCallback callback) { |
| 36 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 37 FROM_HERE, base::BindOnce(std::move(callback), true /** success */)); |
| 38 } |
| 39 |
| 40 void NoopStore::Remove(const std::string& guid, StoreCallback callback) { |
| 41 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 42 FROM_HERE, base::BindOnce(std::move(callback), true /** success */)); |
| 43 } |
| 44 |
| 45 void NoopStore::OnInitFinished(InitCallback callback) { |
| 46 initialized_ = true; |
| 47 |
| 48 std::unique_ptr<std::vector<Entry>> entries = |
| 49 base::MakeUnique<std::vector<Entry>>(); |
| 50 std::move(callback).Run(true /** success */, std::move(entries)); |
| 51 } |
| 52 |
| 53 } // namespace download |
OLD | NEW |