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

Unified Diff: components/offline_pages/offline_store_types.h

Issue 2353393002: [Offline pages] Extracting and templatizing types for store callbacks (Closed)
Patch Set: Removing offline_store_types_impl.h 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_types.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_store_types.h
diff --git a/components/offline_pages/offline_store_types.h b/components/offline_pages/offline_store_types.h
new file mode 100644
index 0000000000000000000000000000000000000000..37c701c203a163619d44cf18365414ecadb9d15f
--- /dev/null
+++ b/components/offline_pages/offline_store_types.h
@@ -0,0 +1,58 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_STORE_TYPES_H_
+#define COMPONENTS_OFFLINE_PAGES_OFFLINE_STORE_TYPES_H_
+
+#include <stdint.h>
+
+#include <set>
+#include <utility>
+#include <vector>
+
+// This file contains common types and callbacks used by storage of various
+// offline page related components.
+namespace offline_pages {
+
+// TODO(fgorski): This enum is meant to replace |LoadStatus|.
+// Current store state. When LOADED, the store is operational. When
+// loading or reset fails, it is reflected appropriately.
+enum class StoreState {
+ NOT_LOADED, // Store is not loaded yet.
+ LOADED, // Store is properly loaded and operational.
+ FAILED_LOADING, // Store initialization failed.
+ FAILED_RESET, // Resetting the store failed.
+};
+
+// Statuses referring to actions taken on items in the stores.
+enum class ItemActionStatus {
+ SUCCESS,
+ ALREADY_EXISTS,
+ NOT_FOUND,
+ STORE_ERROR,
+};
+
+// Collective result for store update.
+template <typename T>
+class StoreUpdateResult {
+ public:
+ explicit StoreUpdateResult(StoreState state)
+ : store_state(state) {}
+ ~StoreUpdateResult() {}
+
+ // List of Offline ID to item action status mappings.
+ // It is meant to be consumed by the original caller of the operation.
+ std::vector<std::pair<int64_t, ItemActionStatus>> item_statuses;
+
+ // List of successfully updated offline page items as seen after operation
+ // concludes. It is meant to be used when passing to the observers.
+ std::vector<T> updated_items;
+
+ // State of the store after the operation is done.
+ StoreState store_state;
+};
+
+} // namespace offline_pages
+
+#endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_STORE_TYPES_H_
« no previous file with comments | « components/offline_pages/offline_page_types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698