| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/download/internal/noop_store.h" | 5 #include "components/download/internal/test/noop_store.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "components/download/internal/entry.h" | 9 #include "components/download/internal/entry.h" |
| 10 | 10 |
| 11 namespace download { | 11 namespace download { |
| 12 | 12 |
| 13 NoopStore::NoopStore() : initialized_(false), weak_ptr_factory_(this) {} | 13 NoopStore::NoopStore() : initialized_(false), weak_ptr_factory_(this) {} |
| 14 | 14 |
| 15 NoopStore::~NoopStore() = default; | 15 NoopStore::~NoopStore() = default; |
| 16 | 16 |
| 17 bool NoopStore::IsInitialized() { | 17 bool NoopStore::IsInitialized() { |
| 18 return initialized_; | 18 return initialized_; |
| 19 } | 19 } |
| 20 | 20 |
| 21 void NoopStore::Initialize(InitCallback callback) { | 21 void NoopStore::Initialize(const InitCallback& callback) { |
| 22 DCHECK(!IsInitialized()); | 22 DCHECK(!IsInitialized()); |
| 23 | 23 |
| 24 base::ThreadTaskRunnerHandle::Get()->PostTask( | 24 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 25 FROM_HERE, | 25 FROM_HERE, base::Bind(&NoopStore::OnInitFinished, |
| 26 base::BindOnce(&NoopStore::OnInitFinished, weak_ptr_factory_.GetWeakPtr(), | 26 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 27 std::move(callback))); | |
| 28 } | 27 } |
| 29 | 28 |
| 30 void NoopStore::Destroy(StoreCallback callback) { | 29 void NoopStore::Destroy(const StoreCallback& callback) { |
| 31 base::ThreadTaskRunnerHandle::Get()->PostTask( | 30 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 32 FROM_HERE, base::BindOnce(std::move(callback), true /** success */)); | 31 FROM_HERE, base::Bind(callback, true /** success */)); |
| 33 } | 32 } |
| 34 | 33 |
| 35 void NoopStore::Update(const Entry& entry, StoreCallback callback) { | 34 void NoopStore::Update(const Entry& entry, const StoreCallback& callback) { |
| 36 base::ThreadTaskRunnerHandle::Get()->PostTask( | 35 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 37 FROM_HERE, base::BindOnce(std::move(callback), true /** success */)); | 36 FROM_HERE, base::Bind(callback, true /** success */)); |
| 38 } | 37 } |
| 39 | 38 |
| 40 void NoopStore::Remove(const std::string& guid, StoreCallback callback) { | 39 void NoopStore::Remove(const std::string& guid, const StoreCallback& callback) { |
| 41 base::ThreadTaskRunnerHandle::Get()->PostTask( | 40 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 42 FROM_HERE, base::BindOnce(std::move(callback), true /** success */)); | 41 FROM_HERE, base::Bind(callback, true /** success */)); |
| 43 } | 42 } |
| 44 | 43 |
| 45 void NoopStore::OnInitFinished(InitCallback callback) { | 44 void NoopStore::OnInitFinished(const InitCallback& callback) { |
| 46 initialized_ = true; | 45 initialized_ = true; |
| 47 | 46 |
| 48 std::unique_ptr<std::vector<Entry>> entries = | 47 std::unique_ptr<std::vector<Entry>> entries = |
| 49 base::MakeUnique<std::vector<Entry>>(); | 48 base::MakeUnique<std::vector<Entry>>(); |
| 50 std::move(callback).Run(true /** success */, std::move(entries)); | 49 callback.Run(true /** success */, std::move(entries)); |
| 51 } | 50 } |
| 52 | 51 |
| 53 } // namespace download | 52 } // namespace download |
| OLD | NEW |