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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 | 11 |
12 class GURL; | 12 class GURL; |
13 | 13 |
14 namespace offline_pages { | 14 namespace offline_pages { |
15 | 15 |
16 struct OfflinePageItem; | 16 struct OfflinePageItem; |
17 | 17 |
18 // OfflinePageMetadataStore keeps metadata for the offline pages. | 18 // OfflinePageMetadataStore keeps metadata for the offline pages. |
19 // Ability to create multiple instances of the store as well as behavior of | 19 // Ability to create multiple instances of the store as well as behavior of |
20 // asynchronous operations when the object is being destroyed, before such | 20 // asynchronous operations when the object is being destroyed, before such |
21 // operation finishes will depend on implementation. It should be possible to | 21 // operation finishes will depend on implementation. It should be possible to |
22 // issue multiple asynchronous operations in parallel. | 22 // issue multiple asynchronous operations in parallel. |
23 class OfflinePageMetadataStore { | 23 class OfflinePageMetadataStore { |
24 public: | 24 public: |
25 typedef base::Callback<void(bool, const std::vector<OfflinePageItem>&)> | 25 // This enum is used in an UMA histogram. Hence the entries here shouldn't |
| 26 // be deleted or re-ordered and new ones should be added to the end. |
| 27 enum LoadStatus { |
| 28 LOAD_SUCCEEDED, |
| 29 STORE_INIT_FAILED, |
| 30 STORE_LOAD_FAILED, |
| 31 DATA_PARSING_FAILED, |
| 32 |
| 33 // NOTE: always keep this entry at the end. |
| 34 LOAD_STATUS_COUNT |
| 35 }; |
| 36 |
| 37 typedef base::Callback<void(LoadStatus, const std::vector<OfflinePageItem>&)> |
26 LoadCallback; | 38 LoadCallback; |
27 typedef base::Callback<void(bool)> UpdateCallback; | 39 typedef base::Callback<void(bool)> UpdateCallback; |
| 40 typedef base::Callback<void(bool)> ResetCallback; |
28 | 41 |
29 OfflinePageMetadataStore(); | 42 OfflinePageMetadataStore(); |
30 virtual ~OfflinePageMetadataStore(); | 43 virtual ~OfflinePageMetadataStore(); |
31 | 44 |
32 // Get all of the offline pages from the store. | 45 // Get all of the offline pages from the store. |
33 virtual void Load(const LoadCallback& callback) = 0; | 46 virtual void Load(const LoadCallback& callback) = 0; |
34 | 47 |
35 // Asynchronously adds or updates offline page metadata to the store. | 48 // Asynchronously adds or updates offline page metadata to the store. |
36 // Result of the update is passed in callback. | 49 // Result of the update is passed in callback. |
37 virtual void AddOrUpdateOfflinePage(const OfflinePageItem& offline_page, | 50 virtual void AddOrUpdateOfflinePage(const OfflinePageItem& offline_page, |
38 const UpdateCallback& callback) = 0; | 51 const UpdateCallback& callback) = 0; |
39 | 52 |
40 // Asynchronously removes offline page metadata from the store. | 53 // Asynchronously removes offline page metadata from the store. |
41 // Result of the update is passed in callback. | 54 // Result of the update is passed in callback. |
42 virtual void RemoveOfflinePages(const std::vector<int64>& bookmark_ids, | 55 virtual void RemoveOfflinePages(const std::vector<int64>& bookmark_ids, |
43 const UpdateCallback& callback) = 0; | 56 const UpdateCallback& callback) = 0; |
| 57 |
| 58 // Resets the store. |
| 59 virtual void Reset(const ResetCallback& callback) = 0; |
44 }; | 60 }; |
45 | 61 |
46 } // namespace offline_pages | 62 } // namespace offline_pages |
47 | 63 |
48 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ | 64 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ |
OLD | NEW |