Chromium Code Reviews| 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 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 enum LoadStatus { | 31 enum LoadStatus { |
| 32 LOAD_SUCCEEDED, | 32 LOAD_SUCCEEDED, |
| 33 STORE_INIT_FAILED, | 33 STORE_INIT_FAILED, |
| 34 STORE_LOAD_FAILED, | 34 STORE_LOAD_FAILED, |
| 35 DATA_PARSING_FAILED, | 35 DATA_PARSING_FAILED, |
| 36 | 36 |
| 37 // NOTE: always keep this entry at the end. | 37 // NOTE: always keep this entry at the end. |
| 38 LOAD_STATUS_COUNT | 38 LOAD_STATUS_COUNT |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 typedef base::Callback<void(LoadStatus, const std::vector<OfflinePageItem>&)> | 41 typedef base::Callback<void(const std::vector<OfflinePageItem>&)> |
| 42 LoadCallback; | 42 LoadCallback; |
| 43 typedef base::Callback<void(StoreState)> InitializeCallback; | |
|
jianli
2016/11/15 21:48:38
nit: consider switching to use "using".
Also, it
fgorski
2016/11/15 23:14:12
I switched to bool based callbacks (after split).
| |
| 43 typedef base::Callback<void(ItemActionStatus)> AddCallback; | 44 typedef base::Callback<void(ItemActionStatus)> AddCallback; |
| 44 typedef base::Callback<void(std::unique_ptr<OfflinePagesUpdateResult>)> | 45 typedef base::Callback<void(std::unique_ptr<OfflinePagesUpdateResult>)> |
| 45 UpdateCallback; | 46 UpdateCallback; |
| 46 typedef base::Callback<void(bool)> ResetCallback; | |
| 47 | 47 |
| 48 OfflinePageMetadataStore(); | 48 OfflinePageMetadataStore(); |
| 49 virtual ~OfflinePageMetadataStore(); | 49 virtual ~OfflinePageMetadataStore(); |
| 50 | 50 |
| 51 // Initializes the store. Should be called before any other methods. | |
| 52 virtual void Initialize(const InitializeCallback& callback) = 0; | |
| 53 | |
| 51 // Get all of the offline pages from the store. | 54 // Get all of the offline pages from the store. |
| 52 virtual void GetOfflinePages(const LoadCallback& callback) = 0; | 55 virtual void GetOfflinePages(const LoadCallback& callback) = 0; |
| 53 | 56 |
| 54 // Asynchronously adds an offline page item metadata to the store. | 57 // Asynchronously adds an offline page item metadata to the store. |
| 55 virtual void AddOfflinePage(const OfflinePageItem& offline_page, | 58 virtual void AddOfflinePage(const OfflinePageItem& offline_page, |
| 56 const AddCallback& callback) = 0; | 59 const AddCallback& callback) = 0; |
| 57 | 60 |
| 58 // Asynchronously updates a set of offline page items in the store. | 61 // Asynchronously updates a set of offline page items in the store. |
| 59 virtual void UpdateOfflinePages(const std::vector<OfflinePageItem>& pages, | 62 virtual void UpdateOfflinePages(const std::vector<OfflinePageItem>& pages, |
| 60 const UpdateCallback& callback) = 0; | 63 const UpdateCallback& callback) = 0; |
| 61 | 64 |
| 62 // Asynchronously removes offline page metadata from the store. | 65 // Asynchronously removes offline page metadata from the store. |
| 63 // Result of the update is passed in callback. | 66 // Result of the update is passed in callback. |
| 64 virtual void RemoveOfflinePages(const std::vector<int64_t>& offline_ids, | 67 virtual void RemoveOfflinePages(const std::vector<int64_t>& offline_ids, |
| 65 const UpdateCallback& callback) = 0; | 68 const UpdateCallback& callback) = 0; |
| 66 | 69 |
| 67 // Resets the store. | 70 // Resets the store. |
| 68 virtual void Reset(const ResetCallback& callback) = 0; | 71 virtual void Reset(const InitializeCallback& callback) = 0; |
|
jianli
2016/11/15 21:48:38
Better to introduce ResetCallback to avoid the con
fgorski
2016/11/15 23:14:12
Done.
| |
| 69 | 72 |
| 70 // Gets the store state. | 73 // Gets the store state. |
| 71 virtual StoreState state() const = 0; | 74 virtual StoreState state() const = 0; |
| 72 }; | 75 }; |
| 73 | 76 |
| 74 } // namespace offline_pages | 77 } // namespace offline_pages |
| 75 | 78 |
| 76 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ | 79 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ |
| OLD | NEW |