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

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

Issue 2026843003: [Offline Pages] Removing client in storage manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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_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>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/supports_user_data.h" 15 #include "base/supports_user_data.h"
16 #include "components/offline_pages/offline_page_archiver.h" 16 #include "components/offline_pages/offline_page_archiver.h"
17 #include "components/offline_pages/offline_page_storage_manager.h" 17 #include "components/offline_pages/offline_page_storage_manager.h"
18 #include "components/offline_pages/offline_page_types.h" 18 #include "components/offline_pages/offline_page_types.h"
19 19
20 class GURL; 20 class GURL;
21 namespace base { 21 namespace base {
22 class Time; 22 class Time;
23 } // namespace base 23 } // namespace base
24 24
25 namespace offline_pages { 25 namespace offline_pages {
26 26
27 static const char* const kBookmarkNamespace = "bookmark"; 27 static const char* const kBookmarkNamespace = "bookmark";
28 static const char* const kLastNNamespace = "last_n";
dougarnett 2016/06/01 01:41:11 Btw, i was hoping we could get these constants out
chili 2016/06/01 03:54:37 Jian's CL (https://codereview.chromium.org/2022283
jianli 2016/06/01 20:41:21 Yes, please wait and sync after my patch (need to
romax 2016/06/01 20:58:43 Is this the one to wait for? Or what's the CL numb
28 static const int64_t kInvalidOfflineId = 0; 29 static const int64_t kInvalidOfflineId = 0;
29 30
30 struct ClientId; 31 struct ClientId;
31 struct OfflinePageItem; 32 struct OfflinePageItem;
32 33
33 // Service for saving pages offline, storing the offline copy and metadata, and 34 // Service for saving pages offline, storing the offline copy and metadata, and
34 // retrieving them upon request. 35 // retrieving them upon request.
35 // 36 //
36 // Example usage: 37 // Example usage:
37 // class ArchiverImpl : public OfflinePageArchiver { 38 // class ArchiverImpl : public OfflinePageArchiver {
38 // // This is a class that knows how to create archiver 39 // // This is a class that knows how to create archiver
39 // void CreateArchiver(...) override; 40 // void CreateArchiver(...) override;
40 // ... 41 // ...
41 // } 42 // }
42 // 43 //
43 // // In code using the OfflinePagesModel to save a page: 44 // // In code using the OfflinePagesModel to save a page:
44 // std::unique_ptr<ArchiverImpl> archiver(new ArchiverImpl()); 45 // std::unique_ptr<ArchiverImpl> archiver(new ArchiverImpl());
45 // // Callback is of type SavePageCallback. 46 // // Callback is of type SavePageCallback.
46 // model->SavePage(url, std::move(archiver), callback); 47 // model->SavePage(url, std::move(archiver), callback);
47 // 48 //
48 // TODO(fgorski): Things to describe: 49 // TODO(fgorski): Things to describe:
49 // * how to cancel requests and what to expect 50 // * how to cancel requests and what to expect
50 class OfflinePageModel : public base::SupportsUserData, 51 class OfflinePageModel : public base::SupportsUserData {
51 public OfflinePageStorageManager::Client {
52 public: 52 public:
53 // Observer of the OfflinePageModel. 53 // Observer of the OfflinePageModel.
54 class Observer { 54 class Observer {
55 public: 55 public:
56 // Invoked when the model has finished loading. 56 // Invoked when the model has finished loading.
57 virtual void OfflinePageModelLoaded(OfflinePageModel* model) = 0; 57 virtual void OfflinePageModelLoaded(OfflinePageModel* model) = 0;
58 58
59 // Invoked when the model is being updated, due to adding, removing or 59 // Invoked when the model is being updated, due to adding, removing or
60 // updating an offline page. 60 // updating an offline page.
61 virtual void OfflinePageModelChanged(OfflinePageModel* model) = 0; 61 virtual void OfflinePageModelChanged(OfflinePageModel* model) = 0;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 virtual void SavePage(const GURL& url, 94 virtual void SavePage(const GURL& url,
95 const ClientId& client_id, 95 const ClientId& client_id,
96 std::unique_ptr<OfflinePageArchiver> archiver, 96 std::unique_ptr<OfflinePageArchiver> archiver,
97 const SavePageCallback& callback) = 0; 97 const SavePageCallback& callback) = 0;
98 98
99 // Marks that the offline page related to the passed |offline_id| has been 99 // Marks that the offline page related to the passed |offline_id| has been
100 // accessed. Its access info, including last access time and access count, 100 // accessed. Its access info, including last access time and access count,
101 // will be updated. Requires that the model is loaded. 101 // will be updated. Requires that the model is loaded.
102 virtual void MarkPageAccessed(int64_t offline_id) = 0; 102 virtual void MarkPageAccessed(int64_t offline_id) = 0;
103 103
104 // TODO(romax): Pull this interface up from OfflinePageStorageManager::Client
105 // void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids,
106 // const DeletePageCallback& callback);
107
108 // Wipes out all the data by deleting all saved files and clearing the store. 104 // Wipes out all the data by deleting all saved files and clearing the store.
109 virtual void ClearAll(const base::Closure& callback) = 0; 105 virtual void ClearAll(const base::Closure& callback) = 0;
110 106
107 // Deletes pages based on |ofline_ids|.
108 virtual void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids,
109 const DeletePageCallback& callback) = 0;
110
111 // Deletes offline pages matching the URL predicate. 111 // Deletes offline pages matching the URL predicate.
112 virtual void DeletePagesByURLPredicate( 112 virtual void DeletePagesByURLPredicate(
113 const UrlPredicate& predicate, 113 const UrlPredicate& predicate,
114 const DeletePageCallback& callback) = 0; 114 const DeletePageCallback& callback) = 0;
115 115
116 // Returns true via callback if there are offline pages in the given 116 // Returns true via callback if there are offline pages in the given
117 // |name_space|. 117 // |name_space|.
118 virtual void HasPages(const std::string& name_space, 118 virtual void HasPages(const std::string& name_space,
119 const HasPagesCallback& callback) = 0; 119 const HasPagesCallback& callback) = 0;
120 120
121 // Returns via callback all GURLs in |urls| that are equal to the online URL 121 // Returns via callback all GURLs in |urls| that are equal to the online URL
122 // of any offline page. 122 // of any offline page.
123 virtual void CheckPagesExistOffline( 123 virtual void CheckPagesExistOffline(
124 const std::set<GURL>& urls, 124 const std::set<GURL>& urls,
125 const CheckPagesExistOfflineCallback& callback) = 0; 125 const CheckPagesExistOfflineCallback& callback) = 0;
126 126
127 // Gets all offline pages.
128 virtual void GetAllPages(const MultipleOfflinePageItemCallback& callback) = 0;
jianli 2016/06/01 20:41:21 Please add const modifier.
romax 2016/06/01 20:58:44 i'm not sure where to add a const?
jianli 2016/06/01 20:59:37 virtual void GetAllPages(const MultipleOfflinePage
129
127 // Gets all offline ids where the offline page has the matching client id. 130 // Gets all offline ids where the offline page has the matching client id.
128 virtual void GetOfflineIdsForClientId( 131 virtual void GetOfflineIdsForClientId(
129 const ClientId& client_id, 132 const ClientId& client_id,
130 const MultipleOfflineIdCallback& callback) = 0; 133 const MultipleOfflineIdCallback& callback) = 0;
131 134
132 // Gets all offline ids where the offline page has the matching client id. 135 // Gets all offline ids where the offline page has the matching client id.
133 // Requires that the model is loaded. May not return matching IDs depending 136 // Requires that the model is loaded. May not return matching IDs depending
134 // on the internal state of the model. 137 // on the internal state of the model.
135 // 138 //
136 // This function is deprecated. Use |GetOfflineIdsForClientId| instead. 139 // This function is deprecated. Use |GetOfflineIdsForClientId| instead.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // not found. See |GetBestPageForOnlineURL| for selection criteria. 183 // not found. See |GetBestPageForOnlineURL| for selection criteria.
181 virtual const OfflinePageItem* MaybeGetBestPageForOnlineURL( 184 virtual const OfflinePageItem* MaybeGetBestPageForOnlineURL(
182 const GURL& online_url) const = 0; 185 const GURL& online_url) const = 0;
183 186
184 // Checks that all of the offline pages have corresponding offline copies. 187 // Checks that all of the offline pages have corresponding offline copies.
185 // If a page is discovered to be missing an offline copy, its offline page 188 // If a page is discovered to be missing an offline copy, its offline page
186 // metadata will be removed and |OfflinePageDeleted| will be sent to model 189 // metadata will be removed and |OfflinePageDeleted| will be sent to model
187 // observers. 190 // observers.
188 virtual void CheckForExternalFileDeletion() = 0; 191 virtual void CheckForExternalFileDeletion() = 0;
189 192
193 // Marks pages with |offline_ids| as expired and delete the associated archive
jianli 2016/06/01 20:41:21 nit: deletes
romax 2016/06/01 20:58:43 Done.
194 // files.
195 virtual void ExpirePages(const std::vector<int64_t>& offline_ids,
196 const base::Time& expiration_time,
197 const base::Callback<void(bool)>& callback) = 0;
198
190 // Returns the policy controller. 199 // Returns the policy controller.
191 virtual ClientPolicyController* GetPolicyController() = 0; 200 virtual ClientPolicyController* GetPolicyController() = 0;
192 201
193 // TODO(dougarnett): Remove this and its uses. 202 // TODO(dougarnett): Remove this and its uses.
194 virtual bool is_loaded() const = 0; 203 virtual bool is_loaded() const = 0;
195 }; 204 };
196 205
197 } // namespace offline_pages 206 } // namespace offline_pages
198 207
199 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ 208 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_
OLDNEW
« no previous file with comments | « components/offline_pages/client_policy_controller.cc ('k') | components/offline_pages/offline_page_model_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698