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(bool /* success */)> InitializeCallback; | |
40 typedef base::Callback<void(bool /* success */)> ResetCallback; | |
41 typedef base::Callback<void(const std::vector<OfflinePageItem>&)> | |
42 LoadCallback; | |
43 typedef base::Callback<void(ItemActionStatus)> AddCallback; | |
44 typedef base::Callback<void(std::unique_ptr<OfflinePagesUpdateResult>)> | |
45 UpdateCallback; | |
46 | |
47 virtual ~OfflinePageMetadataStore(); | |
48 | |
49 // Initializes the store. Should be called before any other methods. | |
50 virtual void Initialize(const InitializeCallback& callback) = 0; | |
51 | |
52 // Get all of the offline pages from the store. | |
53 virtual void GetOfflinePages(const LoadCallback& callback) = 0; | |
54 | |
55 // Asynchronously adds an offline page item metadata to the store. | |
56 virtual void AddOfflinePage(const OfflinePageItem& offline_page, | |
57 const AddCallback& callback) = 0; | |
58 | |
59 // Asynchronously updates a set of offline page items in the store. | |
60 virtual void UpdateOfflinePages(const std::vector<OfflinePageItem>& pages, | |
61 const UpdateCallback& callback) = 0; | |
62 | |
63 // Asynchronously removes offline page metadata from the store. | |
64 // Result of the update is passed in callback. | |
65 virtual void RemoveOfflinePages(const std::vector<int64_t>& offline_ids, | |
66 const UpdateCallback& callback) = 0; | |
67 | |
68 // Resets the store. | |
69 virtual void Reset(const ResetCallback& callback) = 0; | |
70 | |
71 // Gets the store state. | |
72 virtual StoreState state() const = 0; | |
73 }; | |
74 | |
75 } // namespace offline_pages | |
76 | |
77 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ | |
OLD | NEW |