OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/offline_pages/offline_page_test_store.h" | 5 #include "components/offline_pages/offline_page_test_store.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... | |
23 OfflinePageTestStore::~OfflinePageTestStore() {} | 23 OfflinePageTestStore::~OfflinePageTestStore() {} |
24 | 24 |
25 void OfflinePageTestStore::Load(const LoadCallback& callback) { | 25 void OfflinePageTestStore::Load(const LoadCallback& callback) { |
26 OfflinePageMetadataStore::LoadStatus load_status; | 26 OfflinePageMetadataStore::LoadStatus load_status; |
27 if (scenario_ == TestScenario::LOAD_FAILED) { | 27 if (scenario_ == TestScenario::LOAD_FAILED) { |
28 load_status = OfflinePageMetadataStore::STORE_LOAD_FAILED; | 28 load_status = OfflinePageMetadataStore::STORE_LOAD_FAILED; |
29 offline_pages_.clear(); | 29 offline_pages_.clear(); |
30 } else { | 30 } else { |
31 load_status = OfflinePageMetadataStore::LOAD_SUCCEEDED; | 31 load_status = OfflinePageMetadataStore::LOAD_SUCCEEDED; |
32 } | 32 } |
33 DVLOG(1) << "Size of offline pages in store: " << offline_pages_.size(); | |
33 task_runner_->PostTask(FROM_HERE, | 34 task_runner_->PostTask(FROM_HERE, |
34 base::Bind(callback, load_status, GetAllPages())); | 35 base::Bind(callback, load_status, GetAllPages())); |
35 } | 36 } |
36 | 37 |
37 void OfflinePageTestStore::AddOrUpdateOfflinePage( | 38 void OfflinePageTestStore::AddOrUpdateOfflinePage( |
38 const OfflinePageItem& offline_page, | 39 const OfflinePageItem& offline_page, |
39 const UpdateCallback& callback) { | 40 const UpdateCallback& callback) { |
40 last_saved_page_ = offline_page; | 41 last_saved_page_ = offline_page; |
41 bool result = scenario_ != TestScenario::WRITE_FAILED; | 42 bool result = scenario_ != TestScenario::WRITE_FAILED; |
42 if (result) | 43 if (result) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 iter->second.last_access_time = last_access_time; | 77 iter->second.last_access_time = last_access_time; |
77 } | 78 } |
78 | 79 |
79 std::vector<OfflinePageItem> OfflinePageTestStore::GetAllPages() const { | 80 std::vector<OfflinePageItem> OfflinePageTestStore::GetAllPages() const { |
80 std::vector<OfflinePageItem> offline_pages; | 81 std::vector<OfflinePageItem> offline_pages; |
81 for (const auto& id_page_pair : offline_pages_) | 82 for (const auto& id_page_pair : offline_pages_) |
82 offline_pages.push_back(id_page_pair.second); | 83 offline_pages.push_back(id_page_pair.second); |
83 return offline_pages; | 84 return offline_pages; |
84 } | 85 } |
85 | 86 |
87 void OfflinePageTestStore::SetStoreState( | |
jianli
2015/12/15 01:45:25
I am not sure we need this. Why not just calling A
fgorski
2015/12/15 16:33:02
Done.
| |
88 const std::vector<OfflinePageItem>& offline_pages) { | |
89 offline_pages_.clear(); | |
90 for (const auto& offline_page : offline_pages) { | |
91 offline_pages_[offline_page.bookmark_id] = offline_page; | |
92 } | |
93 } | |
94 | |
86 } // namespace offline_pages | 95 } // namespace offline_pages |
OLD | NEW |