| 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(const InitCallback& callback) { |
| 22 DCHECK(!IsInitialized()); |
| 23 |
| 24 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 25 FROM_HERE, base::Bind(&NoopStore::OnInitFinished, |
| 26 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 27 } |
| 28 |
| 29 void NoopStore::Destroy(const StoreCallback& callback) { |
| 30 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 31 FROM_HERE, base::Bind(callback, true /** success */)); |
| 32 } |
| 33 |
| 34 void NoopStore::Update(const Entry& entry, const StoreCallback& callback) { |
| 35 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 36 FROM_HERE, base::Bind(callback, true /** success */)); |
| 37 } |
| 38 |
| 39 void NoopStore::Remove(const std::string& guid, const StoreCallback& callback) { |
| 40 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 41 FROM_HERE, base::Bind(callback, true /** success */)); |
| 42 } |
| 43 |
| 44 void NoopStore::OnInitFinished(const InitCallback& callback) { |
| 45 initialized_ = true; |
| 46 |
| 47 std::unique_ptr<std::vector<Entry>> entries = |
| 48 base::MakeUnique<std::vector<Entry>>(); |
| 49 callback.Run(true /** success */, std::move(entries)); |
| 50 } |
| 51 |
| 52 } // namespace download |
| OLD | NEW |