OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ | |
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <vector> | |
11 | |
12 #include "base/callback.h" | |
13 #include "components/offline_pages/offline_page_item.h" | |
14 #include "components/offline_pages/offline_store_types.h" | |
15 | |
16 namespace offline_pages { | |
17 | |
18 typedef StoreUpdateResult<OfflinePageItem> OfflinePagesUpdateResult; | |
19 | |
20 // OfflinePageMetadataStore keeps metadata for the offline pages. | |
21 // Ability to create multiple instances of the store as well as behavior of | |
22 // asynchronous operations when the object is being destroyed, before such | |
23 // operation finishes will depend on implementation. It should be possible to | |
24 // issue multiple asynchronous operations in parallel. | |
25 class OfflinePageMetadataStore { | |
26 public: | |
27 // This enum is used in an UMA histogram. Hence the entries here shouldn't | |
28 // be deleted or re-ordered and new ones should be added to the end. | |
29 enum LoadStatus { | |
30 LOAD_SUCCEEDED, | |
31 STORE_INIT_FAILED, | |
32 STORE_LOAD_FAILED, | |
33 DATA_PARSING_FAILED, | |
34 | |
35 // NOTE: always keep this entry at the end. | |
36 LOAD_STATUS_COUNT | |
37 }; | |
38 | |
39 typedef base::Callback<void(const std::vector<OfflinePageItem>&)> | |
40 LoadCallback; | |
41 typedef base::Callback<void(bool)> InitializeCallback; | |
42 typedef base::Callback<void(ItemActionStatus)> AddCallback; | |
43 typedef base::Callback<void(std::unique_ptr<OfflinePagesUpdateResult>)> | |
44 UpdateCallback; | |
45 typedef base::Callback<void(bool)> ResetCallback; | |
46 | |
47 OfflinePageMetadataStore(); | |
48 virtual ~OfflinePageMetadataStore(); | |
49 | |
50 // Initializes the store. Should be called before any other methods. | |
51 virtual void Initialize(const InitializeCallback& callback) = 0; | |
52 | |
53 // Get all of the offline pages from the store. | |
54 virtual void GetOfflinePages(const LoadCallback& callback) = 0; | |
55 | |
56 // Asynchronously adds an offline page item metadata to the store. | |
57 virtual void AddOfflinePage(const OfflinePageItem& offline_page, | |
58 const AddCallback& callback) = 0; | |
59 | |
60 // Asynchronously updates a set of offline page items in the store. | |
61 virtual void UpdateOfflinePages(const std::vector<OfflinePageItem>& pages, | |
62 const UpdateCallback& callback) = 0; | |
63 | |
64 // Asynchronously removes offline page metadata from the store. | |
65 // Result of the update is passed in callback. | |
66 virtual void RemoveOfflinePages(const std::vector<int64_t>& offline_ids, | |
67 const UpdateCallback& callback) = 0; | |
68 | |
69 // Resets the store. | |
70 virtual void Reset(const ResetCallback& callback) = 0; | |
71 | |
72 // Gets the store state. | |
73 virtual StoreState state() const = 0; | |
74 }; | |
75 | |
76 } // namespace offline_pages | |
77 | |
78 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ | |
OLD | NEW |