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

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

Issue 2881173003: Download Service : Added leveldb proto layer (Closed)
Patch Set: Removed Model::Destroy 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
« no previous file with comments | « components/download/internal/test/test_store.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() : ready_(false), init_called_(false) {}
13 : ready_(false), init_called_(false), destroy_called_(false) {}
14 13
15 TestStore::~TestStore() {} 14 TestStore::~TestStore() {}
16 15
17 bool TestStore::IsInitialized() { 16 bool TestStore::IsInitialized() {
18 return ready_; 17 return ready_;
19 } 18 }
20 19
21 void TestStore::Initialize(InitCallback callback) { 20 void TestStore::Initialize(InitCallback callback) {
22 init_called_ = true; 21 init_called_ = true;
23 init_callback_ = std::move(callback); 22 init_callback_ = std::move(callback);
24 } 23 }
25 24
26 void TestStore::Destroy(StoreCallback callback) {
27 destroy_called_ = true;
28 destroy_callback_ = std::move(callback);
29 }
30
31 void TestStore::Update(const Entry& entry, StoreCallback callback) { 25 void TestStore::Update(const Entry& entry, StoreCallback callback) {
32 updated_entries_.push_back(entry); 26 updated_entries_.push_back(entry);
33 update_callback_ = std::move(callback); 27 update_callback_ = std::move(callback);
34 } 28 }
35 29
36 void TestStore::Remove(const std::string& guid, StoreCallback callback) { 30 void TestStore::Remove(const std::string& guid, StoreCallback callback) {
37 removed_entries_.push_back(guid); 31 removed_entries_.push_back(guid);
38 remove_callback_ = std::move(callback); 32 remove_callback_ = std::move(callback);
39 } 33 }
40 34
41 // Callback trigger methods. 35 // Callback trigger methods.
42 void TestStore::TriggerInit(bool success, 36 void TestStore::TriggerInit(bool success,
43 std::unique_ptr<std::vector<Entry>> entries) { 37 std::unique_ptr<std::vector<Entry>> entries) {
44 ready_ = success; 38 ready_ = success;
45 DCHECK(init_callback_); 39 DCHECK(init_callback_);
46 std::move(init_callback_).Run(success, std::move(entries)); 40 std::move(init_callback_).Run(success, std::move(entries));
47 } 41 }
48 42
49 void TestStore::TriggerDestroy(bool success) {
50 DCHECK(destroy_callback_);
51 std::move(destroy_callback_).Run(success);
52 }
53
54 void TestStore::TriggerUpdate(bool success) { 43 void TestStore::TriggerUpdate(bool success) {
55 DCHECK(update_callback_); 44 DCHECK(update_callback_);
56 std::move(update_callback_).Run(success); 45 std::move(update_callback_).Run(success);
57 } 46 }
58 47
59 void TestStore::TriggerRemove(bool success) { 48 void TestStore::TriggerRemove(bool success) {
60 DCHECK(remove_callback_); 49 DCHECK(remove_callback_);
61 std::move(remove_callback_).Run(success); 50 std::move(remove_callback_).Run(success);
62 } 51 }
63 52
64 const Entry* TestStore::LastUpdatedEntry() const { 53 const Entry* TestStore::LastUpdatedEntry() const {
65 return &updated_entries_.back(); 54 return &updated_entries_.back();
66 } 55 }
67 56
68 std::string TestStore::LastRemovedEntry() const { 57 std::string TestStore::LastRemovedEntry() const {
69 return removed_entries_.back(); 58 return removed_entries_.back();
70 } 59 }
71 60
72 } // namespace test 61 } // namespace test
73 } // namespace download 62 } // namespace download
OLDNEW
« no previous file with comments | « 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