OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_STORE_TYPES_H_ | |
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_STORE_TYPES_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <utility> | |
11 #include <vector> | |
12 | |
13 // This file contains common types and callbacks used by storage of various | |
14 // offline page related components. | |
15 namespace offline_pages { | |
16 | |
17 // TODO(fgorski): This enum is meant to replace |LoadStatus|. | |
18 // Current store state. When LOADED, the store is operational. When | |
19 // loading or reset fails, it is reflected appropriately. | |
20 enum class StoreState { | |
21 NOT_LOADED, // Store is not loaded yet. | |
22 LOADED, // Store is properly loaded and operational. | |
23 FAILED_LOADING, // Store initialization failed. | |
24 FAILED_RESET, // Resetting the store failed. | |
25 }; | |
26 | |
27 // Statuses referring to actions taken on items in the stores. | |
28 // GENERATED_JAVA_ENUM_PACKAGE:org.chromium.components.offlinepages | |
29 enum class ItemActionStatus { | |
30 SUCCESS, | |
31 ALREADY_EXISTS, | |
32 NOT_FOUND, | |
33 STORE_ERROR, | |
34 }; | |
35 | |
36 // List of item action statuses mapped to item ID. | |
37 typedef std::vector<std::pair<int64_t, ItemActionStatus>> MultipleItemStatuses; | |
38 | |
39 // Collective result for store update. | |
40 template <typename T> | |
41 class StoreUpdateResult { | |
42 public: | |
43 explicit StoreUpdateResult(StoreState state) | |
44 : store_state(state) {} | |
45 ~StoreUpdateResult() {} | |
46 | |
47 // List of Offline ID to item action status mappings. | |
48 // It is meant to be consumed by the original caller of the operation. | |
49 MultipleItemStatuses item_statuses; | |
50 | |
51 // List of successfully updated offline page items as seen after operation | |
52 // concludes. It is meant to be used when passing to the observers. | |
53 std::vector<T> updated_items; | |
54 | |
55 // State of the store after the operation is done. | |
56 StoreState store_state; | |
57 }; | |
58 | |
59 } // namespace offline_pages | |
60 | |
61 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_STORE_TYPES_H_ | |
OLD | NEW |