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

Unified Diff: components/offline_pages/offline_page_test_store.cc

Issue 2339693002: [Offline pages] Splitting Add and Update methods in OPMStore (Closed)
Patch Set: Addressing feedback Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/offline_pages/offline_page_test_store.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/offline_page_test_store.cc
diff --git a/components/offline_pages/offline_page_test_store.cc b/components/offline_pages/offline_page_test_store.cc
index ceb2f76c00ce19128eefd3a97a4fd44ae27708ab..19d2dd2e581900880a3cf36a5e8b1b73f5e8aba2 100644
--- a/components/offline_pages/offline_page_test_store.cc
+++ b/components/offline_pages/offline_page_test_store.cc
@@ -34,13 +34,33 @@ void OfflinePageTestStore::GetOfflinePages(const LoadCallback& callback) {
base::Bind(callback, load_status, GetAllPages()));
}
-void OfflinePageTestStore::AddOrUpdateOfflinePage(
- const OfflinePageItem& offline_page,
+void OfflinePageTestStore::AddOfflinePage(const OfflinePageItem& offline_page,
+ const AddCallback& callback) {
+ // TODO(fgorski): Add and cover scenario with existing item.
+ OfflinePageMetadataStore::ItemActionStatus result;
+ if (scenario_ == TestScenario::SUCCESSFUL) {
+ offline_pages_[offline_page.offline_id] = offline_page;
+ last_saved_page_ = offline_page;
+ result = OfflinePageMetadataStore::SUCCESS;
+ } else if (scenario_ == TestScenario::WRITE_FAILED) {
+ result = OfflinePageMetadataStore::STORE_ERROR;
+ }
+ if (!callback.is_null())
+ task_runner_->PostTask(FROM_HERE, base::Bind(callback, result));
+}
+
+void OfflinePageTestStore::UpdateOfflinePages(
+ const std::vector<OfflinePageItem>& pages,
const UpdateCallback& callback) {
- last_saved_page_ = offline_page;
bool result = scenario_ != TestScenario::WRITE_FAILED;
- if (result)
- offline_pages_[offline_page.offline_id] = offline_page;
+ if (result) {
+ // TODO(fgorski): Cover scenario, where new items are being created, while
+ // they shouldn't.
+ for (auto& page : pages) {
+ offline_pages_[page.offline_id] = page;
+ last_saved_page_ = page;
+ }
+ }
if (!callback.is_null())
task_runner_->PostTask(FROM_HERE, base::Bind(callback, result));
}
« no previous file with comments | « components/offline_pages/offline_page_test_store.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698