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

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

Issue 2484223005: Store original request URL in offline page metadata table (Closed)
Patch Set: Add and update tests Created 4 years, 1 month 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>
(...skipping 29 matching lines...) Expand all
40 // 40 //
41 // // In code using the OfflinePagesModel to save a page: 41 // // In code using the OfflinePagesModel to save a page:
42 // std::unique_ptr<ArchiverImpl> archiver(new ArchiverImpl()); 42 // std::unique_ptr<ArchiverImpl> archiver(new ArchiverImpl());
43 // // Callback is of type SavePageCallback. 43 // // Callback is of type SavePageCallback.
44 // model->SavePage(url, std::move(archiver), callback); 44 // model->SavePage(url, std::move(archiver), callback);
45 // 45 //
46 // TODO(fgorski): Things to describe: 46 // TODO(fgorski): Things to describe:
47 // * how to cancel requests and what to expect 47 // * how to cancel requests and what to expect
48 class OfflinePageModel : public base::SupportsUserData { 48 class OfflinePageModel : public base::SupportsUserData {
49 public: 49 public:
50 // Describes the info about the page to save.
51 struct SavePageInfo {
fgorski 2016/11/10 23:56:13 How about renaming it to SavePageParams? Why? Beca
jianli 2016/11/16 01:25:40 Done.
52 SavePageInfo();
53
54 // The last committed URL of the page to save.
55 GURL url;
56
57 // The identification used by the client.
58 ClientId client_id;
59
60 // Used for the offline_id for the saved file if non-zero. If it is
61 // kInvalidOfflineId, a new, random ID will be generated.
62 int64_t proposed_offline_id;
63
64 // The original URL of the page to save. Empty if no redirect occurs.
65 GURL original_url;
66 };
67
50 // Observer of the OfflinePageModel. 68 // Observer of the OfflinePageModel.
51 class Observer { 69 class Observer {
52 public: 70 public:
53 // Invoked when the model has finished loading. 71 // Invoked when the model has finished loading.
54 virtual void OfflinePageModelLoaded(OfflinePageModel* model) = 0; 72 virtual void OfflinePageModelLoaded(OfflinePageModel* model) = 0;
55 73
56 // Invoked when the model is being updated, due to adding, removing or 74 // Invoked when the model is being updated, due to adding, removing or
57 // updating an offline page. 75 // updating an offline page.
58 virtual void OfflinePageModelChanged(OfflinePageModel* model) = 0; 76 virtual void OfflinePageModelChanged(OfflinePageModel* model) = 0;
59 77
(...skipping 16 matching lines...) Expand all
76 static bool CanSaveURL(const GURL& url); 94 static bool CanSaveURL(const GURL& url);
77 95
78 OfflinePageModel(); 96 OfflinePageModel();
79 ~OfflinePageModel() override; 97 ~OfflinePageModel() override;
80 98
81 virtual void AddObserver(Observer* observer) = 0; 99 virtual void AddObserver(Observer* observer) = 0;
82 virtual void RemoveObserver(Observer* observer) = 0; 100 virtual void RemoveObserver(Observer* observer) = 0;
83 101
84 static const int64_t kInvalidOfflineId = 0; 102 static const int64_t kInvalidOfflineId = 0;
85 103
86 // Attempts to save a page addressed by |url| offline. Requires that the model 104 // Attempts to save a page addressed by |url| offline. Requires that the model
fgorski 2016/11/10 23:56:13 url is not longer passed here.
jianli 2016/11/16 01:25:40 Done.
87 // is loaded. Generates a new offline id and returns 105 // is loaded. Generates a new offline id or uses the proposed offline id and
88 // it. |proposed_offline_id| is used for the offline_id for the saved file if 106 // returns it.
89 // it is non-zero. If it is kInvalidOfflineId, a new, random ID will be 107 virtual void SavePage(const SavePageInfo& save_page_info,
90 // generated.
91 virtual void SavePage(const GURL& url,
92 const ClientId& client_id,
93 int64_t proposed_offline_id,
94 std::unique_ptr<OfflinePageArchiver> archiver, 108 std::unique_ptr<OfflinePageArchiver> archiver,
95 const SavePageCallback& callback) = 0; 109 const SavePageCallback& callback) = 0;
96 110
97 // Marks that the offline page related to the passed |offline_id| has been 111 // 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, 112 // accessed. Its access info, including last access time and access count,
99 // will be updated. Requires that the model is loaded. 113 // will be updated. Requires that the model is loaded.
100 virtual void MarkPageAccessed(int64_t offline_id) = 0; 114 virtual void MarkPageAccessed(int64_t offline_id) = 0;
101 115
102 // Deletes pages based on |offline_ids|. 116 // Deletes pages based on |offline_ids|.
103 virtual void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids, 117 virtual void DeletePagesByOfflineId(const std::vector<int64_t>& offline_ids,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // TODO(dougarnett): Remove this and its uses. 171 // TODO(dougarnett): Remove this and its uses.
158 virtual bool is_loaded() const = 0; 172 virtual bool is_loaded() const = 0;
159 173
160 // Returns the logger. Ownership is retained by the model. 174 // Returns the logger. Ownership is retained by the model.
161 virtual OfflineEventLogger* GetLogger() = 0; 175 virtual OfflineEventLogger* GetLogger() = 0;
162 }; 176 };
163 177
164 } // namespace offline_pages 178 } // namespace offline_pages
165 179
166 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ 180 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698