Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: components/download/internal/test/test_store.cc

Issue 2881173003: Download Service : Added leveldb proto layer (Closed)
Patch Set: more comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/test/test_store.h" 5 #include "components/download/internal/test/test_store.h"
6 6
7 #include "components/download/internal/entry.h" 7 #include "components/download/internal/entry.h"
8 8
9 namespace download { 9 namespace download {
10 namespace test { 10 namespace test {
11 11
12 TestStore::TestStore() 12 TestStore::TestStore()
13 : ready_(false), init_called_(false), destroy_called_(false) {} 13 : ready_(false), init_called_(false), destroy_called_(false) {}
14 14
15 TestStore::~TestStore() {} 15 TestStore::~TestStore() {}
16 16
17 bool TestStore::IsInitialized() { 17 bool TestStore::IsInitialized() {
18 return ready_; 18 return ready_;
19 } 19 }
20 20
21 void TestStore::Initialize(InitCallback callback) { 21 void TestStore::Initialize(const InitCallback& callback) {
22 init_called_ = true; 22 init_called_ = true;
23 init_callback_ = std::move(callback); 23 init_callback_ = callback;
24 } 24 }
25 25
26 void TestStore::Destroy(StoreCallback callback) { 26 void TestStore::Destroy(const StoreCallback& callback) {
27 destroy_called_ = true; 27 destroy_called_ = true;
28 destroy_callback_ = std::move(callback); 28 destroy_callback_ = callback;
29 } 29 }
30 30
31 void TestStore::Update(const Entry& entry, StoreCallback callback) { 31 void TestStore::Update(const Entry& entry, const StoreCallback& callback) {
32 updated_entries_.push_back(entry); 32 updated_entries_.push_back(entry);
33 update_callback_ = std::move(callback); 33 update_callback_ = callback;
34 } 34 }
35 35
36 void TestStore::Remove(const std::string& guid, StoreCallback callback) { 36 void TestStore::Remove(const std::string& guid, const StoreCallback& callback) {
37 removed_entries_.push_back(guid); 37 removed_entries_.push_back(guid);
38 remove_callback_ = std::move(callback); 38 remove_callback_ = callback;
39 } 39 }
40 40
41 // Callback trigger methods. 41 // Callback trigger methods.
42 void TestStore::TriggerInit(bool success, 42 void TestStore::TriggerInit(bool success,
43 std::unique_ptr<std::vector<Entry>> entries) { 43 std::unique_ptr<std::vector<Entry>> entries) {
44 ready_ = success; 44 ready_ = success;
45 DCHECK(init_callback_); 45 DCHECK(init_callback_);
46 std::move(init_callback_).Run(success, std::move(entries)); 46 init_callback_.Run(success, std::move(entries));
47 } 47 }
48 48
49 void TestStore::TriggerDestroy(bool success) { 49 void TestStore::TriggerDestroy(bool success) {
50 DCHECK(destroy_callback_); 50 DCHECK(destroy_callback_);
51 std::move(destroy_callback_).Run(success); 51 destroy_callback_.Run(success);
52 } 52 }
53 53
54 void TestStore::TriggerUpdate(bool success) { 54 void TestStore::TriggerUpdate(bool success) {
55 DCHECK(update_callback_); 55 DCHECK(update_callback_);
56 std::move(update_callback_).Run(success); 56 update_callback_.Run(success);
57 } 57 }
58 58
59 void TestStore::TriggerRemove(bool success) { 59 void TestStore::TriggerRemove(bool success) {
60 DCHECK(remove_callback_); 60 DCHECK(remove_callback_);
61 std::move(remove_callback_).Run(success); 61 remove_callback_.Run(success);
62 } 62 }
63 63
64 const Entry* TestStore::LastUpdatedEntry() const { 64 const Entry* TestStore::LastUpdatedEntry() const {
65 return &updated_entries_.back(); 65 return &updated_entries_.back();
66 } 66 }
67 67
68 std::string TestStore::LastRemovedEntry() const { 68 std::string TestStore::LastRemovedEntry() const {
69 return removed_entries_.back(); 69 return removed_entries_.back();
70 } 70 }
71 71
72 } // namespace test 72 } // namespace test
73 } // namespace download 73 } // namespace download
OLDNEW
« components/download/internal/store.h ('K') | « components/download/internal/test/test_store.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698