Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: components/offline_pages/offline_page_metadata_store.h

Issue 2384423003: [Offline pages] Resetting offline page metadata store if initial load fails (Closed)
Patch Set: Rebased and comments addressed Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "components/offline_pages/offline_page_item.h" 13 #include "components/offline_pages/offline_page_item.h"
14 #include "components/offline_pages/offline_store_types.h" 14 #include "components/offline_pages/offline_store_types.h"
15 15
16 class GURL; 16 class GURL;
17 17
18 namespace offline_pages { 18 namespace offline_pages {
19 19
20 typedef StoreUpdateResult<OfflinePageItem> OfflinePagesUpdateResult; 20 typedef StoreUpdateResult<OfflinePageItem> OfflinePagesUpdateResult;
21 21
22 // OfflinePageMetadataStore keeps metadata for the offline pages. 22 // OfflinePageMetadataStore keeps metadata for the offline pages.
23 // Ability to create multiple instances of the store as well as behavior of 23 // Ability to create multiple instances of the store as well as behavior of
24 // asynchronous operations when the object is being destroyed, before such 24 // asynchronous operations when the object is being destroyed, before such
25 // operation finishes will depend on implementation. It should be possible to 25 // operation finishes will depend on implementation. It should be possible to
26 // issue multiple asynchronous operations in parallel. 26 // issue multiple asynchronous operations in parallel.
27 class OfflinePageMetadataStore { 27 class OfflinePageMetadataStore {
28 public: 28 public:
29 // This enum is used in an UMA histogram. Hence the entries here shouldn't 29 typedef base::Callback<void(StoreState, const std::vector<OfflinePageItem>&)>
30 // be deleted or re-ordered and new ones should be added to the end. 30 GetOfflinePagesCallback;
31 enum LoadStatus {
32 LOAD_SUCCEEDED,
33 STORE_INIT_FAILED,
34 STORE_LOAD_FAILED,
35 DATA_PARSING_FAILED,
36
37 // NOTE: always keep this entry at the end.
38 LOAD_STATUS_COUNT
39 };
40
41 typedef base::Callback<void(LoadStatus, const std::vector<OfflinePageItem>&)>
42 LoadCallback;
43 typedef base::Callback<void(ItemActionStatus)> AddCallback; 31 typedef base::Callback<void(ItemActionStatus)> AddCallback;
44 typedef base::Callback<void(std::unique_ptr<OfflinePagesUpdateResult>)> 32 typedef base::Callback<void(std::unique_ptr<OfflinePagesUpdateResult>)>
45 UpdateCallback; 33 UpdateCallback;
46 typedef base::Callback<void(bool)> ResetCallback; 34 typedef base::Callback<void(bool)> ResetCallback;
47 35
48 OfflinePageMetadataStore(); 36 OfflinePageMetadataStore();
49 virtual ~OfflinePageMetadataStore(); 37 virtual ~OfflinePageMetadataStore();
50 38
51 // Get all of the offline pages from the store. 39 // Get all of the offline pages from the store.
52 virtual void GetOfflinePages(const LoadCallback& callback) = 0; 40 virtual void GetOfflinePages(const GetOfflinePagesCallback& callback) = 0;
53 41
54 // Asynchronously adds an offline page item metadata to the store. 42 // Asynchronously adds an offline page item metadata to the store.
55 virtual void AddOfflinePage(const OfflinePageItem& offline_page, 43 virtual void AddOfflinePage(const OfflinePageItem& offline_page,
56 const AddCallback& callback) = 0; 44 const AddCallback& callback) = 0;
57 45
58 // Asynchronously updates a set of offline page items in the store. 46 // Asynchronously updates a set of offline page items in the store.
59 virtual void UpdateOfflinePages(const std::vector<OfflinePageItem>& pages, 47 virtual void UpdateOfflinePages(const std::vector<OfflinePageItem>& pages,
60 const UpdateCallback& callback) = 0; 48 const UpdateCallback& callback) = 0;
61 49
62 // Asynchronously removes offline page metadata from the store. 50 // Asynchronously removes offline page metadata from the store.
63 // Result of the update is passed in callback. 51 // Result of the update is passed in callback.
64 virtual void RemoveOfflinePages(const std::vector<int64_t>& offline_ids, 52 virtual void RemoveOfflinePages(const std::vector<int64_t>& offline_ids,
65 const UpdateCallback& callback) = 0; 53 const UpdateCallback& callback) = 0;
66 54
67 // Resets the store. 55 // Resets the store.
68 virtual void Reset(const ResetCallback& callback) = 0; 56 virtual void Reset(const ResetCallback& callback) = 0;
69 57
70 // Gets the store state. 58 // Gets the store state.
71 virtual StoreState state() const = 0; 59 virtual StoreState state() const = 0;
72 }; 60 };
73 61
74 } // namespace offline_pages 62 } // namespace offline_pages
75 63
76 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_ 64 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698