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

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

Issue 2564163002: [Offline Pages] Remove load state from public OfflinePageModel API. (Closed)
Patch Set: Fix broken tests. Created 4 years 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_CORE_OFFLINE_PAGE_MODEL_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_MODEL_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_MODEL_H_ 6 #define COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_MODEL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // kInvalidOfflineId, a new, random ID will be generated. 68 // kInvalidOfflineId, a new, random ID will be generated.
69 int64_t proposed_offline_id; 69 int64_t proposed_offline_id;
70 70
71 // The original URL of the page to save. Empty if no redirect occurs. 71 // The original URL of the page to save. Empty if no redirect occurs.
72 GURL original_url; 72 GURL original_url;
73 }; 73 };
74 74
75 // Observer of the OfflinePageModel. 75 // Observer of the OfflinePageModel.
76 class Observer { 76 class Observer {
77 public: 77 public:
78 // Invoked when the model has finished loading.
79 virtual void OfflinePageModelLoaded(OfflinePageModel* model) = 0;
80
81 // Invoked when the model is being updated due to adding an offline page. 78 // Invoked when the model is being updated due to adding an offline page.
82 virtual void OfflinePageAdded(OfflinePageModel* model, 79 virtual void OfflinePageAdded(OfflinePageModel* model,
83 const OfflinePageItem& added_page) = 0; 80 const OfflinePageItem& added_page) = 0;
84 81
85 // Invoked when an offline copy related to |offline_id| was deleted. 82 // Invoked when an offline copy related to |offline_id| was deleted.
86 virtual void OfflinePageDeleted(int64_t offline_id, 83 virtual void OfflinePageDeleted(int64_t offline_id,
87 const ClientId& client_id) = 0; 84 const ClientId& client_id) = 0;
88 85
89 protected: 86 protected:
90 virtual ~Observer() = default; 87 virtual ~Observer() = default;
(...skipping 10 matching lines...) Expand all
101 static bool CanSaveURL(const GURL& url); 98 static bool CanSaveURL(const GURL& url);
102 99
103 OfflinePageModel(); 100 OfflinePageModel();
104 ~OfflinePageModel() override; 101 ~OfflinePageModel() override;
105 102
106 virtual void AddObserver(Observer* observer) = 0; 103 virtual void AddObserver(Observer* observer) = 0;
107 virtual void RemoveObserver(Observer* observer) = 0; 104 virtual void RemoveObserver(Observer* observer) = 0;
108 105
109 static const int64_t kInvalidOfflineId = 0; 106 static const int64_t kInvalidOfflineId = 0;
110 107
111 // Attempts to save a page offline per |save_page_params|. Requires that the 108 // Attempts to save a page offline per |save_page_params|. Generates a new
112 // model is loaded. Generates a new offline id or uses the proposed offline 109 // offline id or uses the proposed offline id in |save_page_params| and
113 // id in |save_page_params| and returns it. 110 // returns it.
114 virtual void SavePage(const SavePageParams& save_page_params, 111 virtual void SavePage(const SavePageParams& save_page_params,
115 std::unique_ptr<OfflinePageArchiver> archiver, 112 std::unique_ptr<OfflinePageArchiver> archiver,
116 const SavePageCallback& callback) = 0; 113 const SavePageCallback& callback) = 0;
117 114
118 // Marks that the offline page related to the passed |offline_id| has been 115 // Marks that the offline page related to the passed |offline_id| has been
119 // accessed. Its access info, including last access time and access count, 116 // accessed. Its access info, including last access time and access count,
120 // will be updated. Requires that the model is loaded. 117 // will be updated.
121 virtual void MarkPageAccessed(int64_t offline_id) = 0; 118 virtual void MarkPageAccessed(int64_t offline_id) = 0;
122 119
123 // Deletes pages based on |offline_ids|. 120 // Deletes pages based on |offline_ids|.
124 virtual void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, 121 virtual void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids,
125 const DeletePageCallback& callback) = 0; 122 const DeletePageCallback& callback) = 0;
126 123
127 // Deletes all pages associated with any of |client_ids|. 124 // Deletes all pages associated with any of |client_ids|.
128 virtual void DeletePagesByClientIds(const std::vector<ClientId>& client_ids, 125 virtual void DeletePagesByClientIds(const std::vector<ClientId>& client_ids,
129 const DeletePageCallback& callback) = 0; 126 const DeletePageCallback& callback) = 0;
130 127
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // Returns the offline pages that are related to |url|. |url_search_mode| 161 // Returns the offline pages that are related to |url|. |url_search_mode|
165 // controls how the url match is done. See URLSearchMode for more details. 162 // controls how the url match is done. See URLSearchMode for more details.
166 virtual void GetPagesByURL( 163 virtual void GetPagesByURL(
167 const GURL& url, 164 const GURL& url,
168 URLSearchMode url_search_mode, 165 URLSearchMode url_search_mode,
169 const MultipleOfflinePageItemCallback& callback) = 0; 166 const MultipleOfflinePageItemCallback& callback) = 0;
170 167
171 // Returns the policy controller. 168 // Returns the policy controller.
172 virtual ClientPolicyController* GetPolicyController() = 0; 169 virtual ClientPolicyController* GetPolicyController() = 0;
173 170
174 // TODO(dougarnett): Remove this and its uses.
175 virtual bool is_loaded() const = 0;
176
177 // Returns the logger. Ownership is retained by the model. 171 // Returns the logger. Ownership is retained by the model.
178 virtual OfflineEventLogger* GetLogger() = 0; 172 virtual OfflineEventLogger* GetLogger() = 0;
179 }; 173 };
180 174
181 } // namespace offline_pages 175 } // namespace offline_pages
182 176
183 #endif // COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_MODEL_H_ 177 #endif // COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698