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_MODEL_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 // Marks that the offline page related to the passed |offline_id| has been | 97 // Marks that the offline page related to the passed |offline_id| has been |
98 // accessed. Its access info, including last access time and access count, | 98 // accessed. Its access info, including last access time and access count, |
99 // will be updated. Requires that the model is loaded. | 99 // will be updated. Requires that the model is loaded. |
100 virtual void MarkPageAccessed(int64_t offline_id) = 0; | 100 virtual void MarkPageAccessed(int64_t offline_id) = 0; |
101 | 101 |
102 // Deletes pages based on |offline_ids|. | 102 // Deletes pages based on |offline_ids|. |
103 virtual void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, | 103 virtual void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, |
104 const DeletePageCallback& callback) = 0; | 104 const DeletePageCallback& callback) = 0; |
105 | 105 |
| 106 // Deletes all pages associated with any of |client_ids|. |
| 107 virtual void DeletePagesByClientIds(const std::vector<ClientId>& client_ids, |
| 108 const DeletePageCallback& callback) = 0; |
| 109 |
| 110 // Retrieves all pages associated with any of |client_ids|. |
| 111 virtual void GetPagesByClientIds( |
| 112 const std::vector<ClientId>& client_ids, |
| 113 const MultipleOfflinePageItemCallback& callback) = 0; |
| 114 |
106 // Deletes cached offline pages matching the URL predicate. | 115 // Deletes cached offline pages matching the URL predicate. |
107 virtual void DeleteCachedPagesByURLPredicate( | 116 virtual void DeleteCachedPagesByURLPredicate( |
108 const UrlPredicate& predicate, | 117 const UrlPredicate& predicate, |
109 const DeletePageCallback& callback) = 0; | 118 const DeletePageCallback& callback) = 0; |
110 | 119 |
111 // Returns via callback all GURLs in |urls| that are equal to the online URL | 120 // Returns via callback all GURLs in |urls| that are equal to the online URL |
112 // of any offline page. | 121 // of any offline page. |
113 virtual void CheckPagesExistOffline( | 122 virtual void CheckPagesExistOffline( |
114 const std::set<GURL>& urls, | 123 const std::set<GURL>& urls, |
115 const CheckPagesExistOfflineCallback& callback) = 0; | 124 const CheckPagesExistOfflineCallback& callback) = 0; |
116 | 125 |
117 // Gets all offline pages. | 126 // Gets all offline pages. |
118 virtual void GetAllPages(const MultipleOfflinePageItemCallback& callback) = 0; | 127 virtual void GetAllPages(const MultipleOfflinePageItemCallback& callback) = 0; |
119 | 128 |
120 // Gets all offline pages including expired ones. | 129 // Gets all offline pages including expired ones. |
121 virtual void GetAllPagesWithExpired( | 130 virtual void GetAllPagesWithExpired( |
122 const MultipleOfflinePageItemCallback& callback) = 0; | 131 const MultipleOfflinePageItemCallback& callback) = 0; |
123 | 132 |
124 // Gets all offline ids where the offline page has the matching client id. | 133 // Gets all offline ids where the offline page has the matching client id. |
125 virtual void GetOfflineIdsForClientId( | 134 virtual void GetOfflineIdsForClientId( |
126 const ClientId& client_id, | 135 const ClientId& client_id, |
127 const MultipleOfflineIdCallback& callback) = 0; | 136 const MultipleOfflineIdCallback& callback) = 0; |
128 | 137 |
129 // Gets all offline ids where the offline page has the matching client id. | |
130 // Requires that the model is loaded. May not return matching IDs depending | |
131 // on the internal state of the model. | |
132 // | |
133 // This function is deprecated. Use |GetOfflineIdsForClientId| instead. | |
134 virtual const std::vector<int64_t> MaybeGetOfflineIdsForClientId( | |
135 const ClientId& client_id) const = 0; | |
136 | |
137 // Returns zero or one offline pages associated with a specified |offline_id|. | 138 // Returns zero or one offline pages associated with a specified |offline_id|. |
138 virtual void GetPageByOfflineId( | 139 virtual void GetPageByOfflineId( |
139 int64_t offline_id, | 140 int64_t offline_id, |
140 const SingleOfflinePageItemCallback& callback) = 0; | 141 const SingleOfflinePageItemCallback& callback) = 0; |
141 | 142 |
142 // Returns an offline page associated with a specified |offline_id|. nullptr | |
143 // is returned if not found. | |
144 virtual const OfflinePageItem* MaybeGetPageByOfflineId( | |
145 int64_t offline_id) const = 0; | |
146 | |
147 // Returns the offline pages that are stored under |online_url|. | 143 // Returns the offline pages that are stored under |online_url|. |
148 virtual void GetPagesByOnlineURL( | 144 virtual void GetPagesByOnlineURL( |
149 const GURL& online_url, | 145 const GURL& online_url, |
150 const MultipleOfflinePageItemCallback& callback) = 0; | 146 const MultipleOfflinePageItemCallback& callback) = 0; |
151 | 147 |
152 // Returns an offline page saved for |online_url|. A nullptr is returned if | |
153 // not found. See |GetBestPageForOnlineURL| for selection criteria. | |
154 virtual const OfflinePageItem* MaybeGetBestPageForOnlineURL( | |
155 const GURL& online_url) const = 0; | |
156 | |
157 // Marks pages with |offline_ids| as expired and deletes the associated | 148 // Marks pages with |offline_ids| as expired and deletes the associated |
158 // archive files. | 149 // archive files. |
159 virtual void ExpirePages(const std::vector<int64_t>& offline_ids, | 150 virtual void ExpirePages(const std::vector<int64_t>& offline_ids, |
160 const base::Time& expiration_time, | 151 const base::Time& expiration_time, |
161 const base::Callback<void(bool)>& callback) = 0; | 152 const base::Callback<void(bool)>& callback) = 0; |
162 | 153 |
163 // Returns the policy controller. | 154 // Returns the policy controller. |
164 virtual ClientPolicyController* GetPolicyController() = 0; | 155 virtual ClientPolicyController* GetPolicyController() = 0; |
165 | 156 |
166 // TODO(dougarnett): Remove this and its uses. | 157 // TODO(dougarnett): Remove this and its uses. |
167 virtual bool is_loaded() const = 0; | 158 virtual bool is_loaded() const = 0; |
168 | 159 |
169 // Returns the logger. Ownership is retained by the model. | 160 // Returns the logger. Ownership is retained by the model. |
170 virtual OfflineEventLogger* GetLogger() = 0; | 161 virtual OfflineEventLogger* GetLogger() = 0; |
171 }; | 162 }; |
172 | 163 |
173 } // namespace offline_pages | 164 } // namespace offline_pages |
174 | 165 |
175 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 166 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
OLD | NEW |