Chromium Code Reviews| Index: components/offline_pages/offline_page_metadata_store.h |
| diff --git a/components/offline_pages/offline_page_metadata_store.h b/components/offline_pages/offline_page_metadata_store.h |
| index 63a35e464bdcd448da68500251c49e7db293a62a..27430779547831f192db5c525a619c5be9ba7efe 100644 |
| --- a/components/offline_pages/offline_page_metadata_store.h |
| +++ b/components/offline_pages/offline_page_metadata_store.h |
| @@ -10,12 +10,46 @@ |
| #include <vector> |
| #include "base/callback.h" |
| +#include "components/offline_pages/offline_page_item.h" |
| class GURL; |
| namespace offline_pages { |
| -struct OfflinePageItem; |
| +// TODO(fgorski): This enum is meant to replace |LoadStatus|. |
| +// Current store state. When LOADED, the store is operational. When |
| +// initialization or reset fails, it is reflected appropriately. |
| +enum class StoreState { |
| + NOT_LOADED, |
| + LOADED, |
| + FAILED_INITIALIZATION, |
|
Dmitry Titov
2016/09/20 20:43:37
It would be goog to have those values documented.
fgorski
2016/09/20 22:15:02
Done.
|
| + FAILED_RESET, |
| +}; |
| + |
| +// Statuses referring to actions taken on items in the store. |
| +enum class ItemActionStatus { |
| + SUCCESS, |
| + ALREADY_EXISTS, |
| + DOESNT_EXIST, |
|
Dmitry Titov
2016/09/20 20:43:37
Naming suggestion: DOESNT_EXIST -> NOT_FOUND?
fgorski
2016/09/20 22:15:02
Done.
|
| + STORE_ERROR, |
| +}; |
| + |
| +class StoreUpdateResult { |
| + public: |
| + explicit StoreUpdateResult(StoreState 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<OfflinePageItem> updated_items; |
| + |
| + // State of the store after the operation is done. |
| + StoreState store_state; |
| +}; |
| // OfflinePageMetadataStore keeps metadata for the offline pages. |
| // Ability to create multiple instances of the store as well as behavior of |
| @@ -36,28 +70,11 @@ class OfflinePageMetadataStore { |
| LOAD_STATUS_COUNT |
| }; |
| - // TODO(fgorski): This enum is meant to replace |LoadStatus|. |
| - // Current store state. When LOADED, the store is operational. When |
| - // initialization or reset fails, it is reflected appropriately. |
| - enum StoreState { |
| - NOT_LOADED, |
| - LOADED, |
| - FAILED_INITIALIZATION, |
| - FAILED_RESET, |
| - }; |
| - |
| - // Statuses referring to actions taken on items in the store. |
| - enum ItemActionStatus { |
| - SUCCESS, |
| - ALREADY_EXISTS, |
| - DOESNT_EXIST, |
| - STORE_ERROR, |
| - }; |
| - |
| typedef base::Callback<void(LoadStatus, const std::vector<OfflinePageItem>&)> |
| LoadCallback; |
| typedef base::Callback<void(ItemActionStatus)> AddCallback; |
| - typedef base::Callback<void(bool)> UpdateCallback; |
| + typedef base::Callback<void(std::unique_ptr<StoreUpdateResult>)> |
| + UpdateCallback; |
| typedef base::Callback<void(bool)> ResetCallback; |
| OfflinePageMetadataStore(); |