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

Side by Side Diff: chrome/browser/android/offline_pages/recent_tab_helper.h

Issue 2651433004: Last_n: Minor follow-up fixes post user interaction triggers. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/recent_tab_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_
6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_ 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "components/offline_pages/core/downloads/download_ui_item.h" 12 #include "components/offline_pages/core/downloads/download_ui_item.h"
13 #include "components/offline_pages/core/offline_page_model.h" 13 #include "components/offline_pages/core/offline_page_model.h"
14 #include "components/offline_pages/core/snapshot_controller.h" 14 #include "components/offline_pages/core/snapshot_controller.h"
15 #include "content/public/browser/web_contents_observer.h" 15 #include "content/public/browser/web_contents_observer.h"
16 #include "content/public/browser/web_contents_user_data.h" 16 #include "content/public/browser/web_contents_user_data.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 namespace content { 19 namespace content {
20 class NavigationHandle; 20 class NavigationHandle;
21 } 21 }
22 22
23 namespace offline_pages { 23 namespace offline_pages {
24 24
25 using PageQuality = SnapshotController::PageQuality;
26
27 // Attaches to every WebContent shown in a tab. Waits until the WebContent is 25 // Attaches to every WebContent shown in a tab. Waits until the WebContent is
28 // loaded to proper degree and then makes a snapshot of the page. Removes the 26 // loaded to proper degree and then makes a snapshot of the page. Removes the
29 // oldest snapshot in the 'ring buffer'. As a result, there is always up to N 27 // oldest snapshot in the 'ring buffer'. As a result, there is always up to N
30 // snapshots of recent pages on the device. 28 // snapshots of recent pages on the device.
31 class RecentTabHelper 29 class RecentTabHelper
32 : public content::WebContentsObserver, 30 : public content::WebContentsObserver,
33 public content::WebContentsUserData<RecentTabHelper>, 31 public content::WebContentsUserData<RecentTabHelper>,
34 public SnapshotController::Client { 32 public SnapshotController::Client {
35 public: 33 public:
36 ~RecentTabHelper() override; 34 ~RecentTabHelper() override;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // the request if the capture of the current page was not possible (e.g. 91 // the request if the capture of the current page was not possible (e.g.
94 // the user navigated to another page before current one was loaded). 92 // the user navigated to another page before current one was loaded).
95 // 0 if this is a "last_n" info. 93 // 0 if this is a "last_n" info.
96 int64_t request_id = OfflinePageModel::kInvalidOfflineId; 94 int64_t request_id = OfflinePageModel::kInvalidOfflineId;
97 95
98 // True if there was at least one snapshot successfully completed. 96 // True if there was at least one snapshot successfully completed.
99 bool page_snapshot_completed = false; 97 bool page_snapshot_completed = false;
100 98
101 // Expected snapshot quality should the saving succeed. This value is only 99 // Expected snapshot quality should the saving succeed. This value is only
102 // valid if |page_snapshot_completed| is true. 100 // valid if |page_snapshot_completed| is true.
103 PageQuality expected_page_quality = PageQuality::POOR; 101 SnapshotController::PageQuality expected_page_quality =
102 SnapshotController::PageQuality::POOR;
104 }; 103 };
105 104
106 explicit RecentTabHelper(content::WebContents* web_contents); 105 explicit RecentTabHelper(content::WebContents* web_contents);
107 friend class content::WebContentsUserData<RecentTabHelper>; 106 friend class content::WebContentsUserData<RecentTabHelper>;
108 107
109 bool EnsureInitialized(); 108 bool EnsureInitialized();
110 void ContinueSnapshotWithIdsToPurge(SnapshotProgressInfo* snapshot_info, 109 void ContinueSnapshotWithIdsToPurge(SnapshotProgressInfo* snapshot_info,
111 const std::vector<int64_t>& page_ids); 110 const std::vector<int64_t>& page_ids);
112 void ContinueSnapshotAfterPurge(SnapshotProgressInfo* snapshot_info, 111 void ContinueSnapshotAfterPurge(SnapshotProgressInfo* snapshot_info,
113 OfflinePageModel::DeletePageResult result); 112 OfflinePageModel::DeletePageResult result);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 std::unique_ptr<SnapshotController> snapshot_controller_; 148 std::unique_ptr<SnapshotController> snapshot_controller_;
150 149
151 std::unique_ptr<Delegate> delegate_; 150 std::unique_ptr<Delegate> delegate_;
152 151
153 // Set at each navigation to control if last_n should save snapshots of the 152 // Set at each navigation to control if last_n should save snapshots of the
154 // current page being loaded. 153 // current page being loaded.
155 bool last_n_listen_to_tab_hidden_ = false; 154 bool last_n_listen_to_tab_hidden_ = false;
156 155
157 // Track the page quality status of the last saved snapshot for the current 156 // Track the page quality status of the last saved snapshot for the current
158 // page. It is generally reset upon new navigations. 157 // page. It is generally reset upon new navigations.
159 PageQuality last_n_latest_saved_quality_ = PageQuality::POOR; 158 SnapshotController::PageQuality last_n_latest_saved_quality_ =
159 SnapshotController::PageQuality::POOR;
160 160
161 base::WeakPtrFactory<RecentTabHelper> weak_ptr_factory_; 161 base::WeakPtrFactory<RecentTabHelper> weak_ptr_factory_;
162 162
163 DISALLOW_COPY_AND_ASSIGN(RecentTabHelper); 163 DISALLOW_COPY_AND_ASSIGN(RecentTabHelper);
164 }; 164 };
165 165
166 } // namespace offline_pages 166 } // namespace offline_pages
167 167
168 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_ 168 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/recent_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698