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