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

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

Issue 2635023005: Minor improvements to RecentTabHelper. (Closed)
Patch Set: A couple more things I had forgotten. 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
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
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // the request so the Background Offliner starts working on it. 66 // the request so the Background Offliner starts working on it.
67 // 5. If Chrome is killed at any point, next time Background Offliner loads 67 // 5. If Chrome is killed at any point, next time Background Offliner loads
68 // it converts all suspended requests from last session into active. 68 // it converts all suspended requests from last session into active.
69 void ObserveAndDownloadCurrentPage(const ClientId& client_id, 69 void ObserveAndDownloadCurrentPage(const ClientId& client_id,
70 int64_t request_id); 70 int64_t request_id);
71 71
72 private: 72 private:
73 // Keeps client_id/request_id that will be used for the offline snapshot. 73 // Keeps client_id/request_id that will be used for the offline snapshot.
74 struct DownloadPageInfo { 74 struct DownloadPageInfo {
75 public: 75 public:
76 DownloadPageInfo(const ClientId& client_id, 76 DownloadPageInfo(const ClientId& client_id,
dewittj 2017/01/17 23:21:52 nit: rename to SnapshotProgressInfo (or something
carlosk 2017/01/18 03:06:10 Done.
77 int64_t request_id) 77 int64_t request_id)
78 : client_id_(client_id), 78 : client_id_(client_id),
79 request_id_(request_id), 79 request_id_(request_id),
80 page_snapshot_completed_(false) {} 80 page_snapshot_completed_(false) {}
dewittj 2017/01/17 23:21:52 Maybe another constructor that just accepts a tab_
carlosk 2017/01/18 03:06:10 Done. I also made its members follow the correct
81 81
82 // The ClientID to go with the offline page. 82 // The ClientID to go with the offline page.
83 ClientId client_id_; 83 ClientId client_id_;
84 // Id of the suspended request in Background Offliner. Used to un-suspend 84 // Id of the suspended request in Background Offliner. Used to un-suspend
85 // the request if the capture of the current page was not possible (e.g. 85 // the request if the capture of the current page was not possible (e.g.
86 // the user navigated to another page before current one was loaded). 86 // the user navigated to another page before current one was loaded).
87 // 0 if this is a "last_1" info. 87 // 0 if this is a "last_1" info.
dewittj 2017/01/17 23:21:52 nit: last_1 is used here and last N is used elsewh
carlosk 2017/01/18 03:06:10 Done.
88 int64_t request_id_; 88 int64_t request_id_;
89 // True if there was at least one snapshot successfully completed. 89 // True if there was at least one snapshot successfully completed.
90 bool page_snapshot_completed_; 90 bool page_snapshot_completed_;
91 }; 91 };
92 92
93 explicit RecentTabHelper(content::WebContents* web_contents); 93 explicit RecentTabHelper(content::WebContents* web_contents);
94 friend class content::WebContentsUserData<RecentTabHelper>; 94 friend class content::WebContentsUserData<RecentTabHelper>;
95 95
96 void EnsureInitialized(); 96 void EnsureInitialized();
97 void ContinueSnapshotWithIdsToPurge(const std::vector<int64_t>& page_ids); 97 void ContinueSnapshotWithIdsToPurge(const std::vector<int64_t>& page_ids);
98 void ContinueSnapshotAfterPurge(OfflinePageModel::DeletePageResult result); 98 void ContinueSnapshotAfterPurge(OfflinePageModel::DeletePageResult result);
99 void SavePageCallback(OfflinePageModel::SavePageResult result, 99 void SavePageCallback(OfflinePageModel::SavePageResult result,
100 int64_t offline_id); 100 int64_t offline_id);
101 void ReportSnapshotCompleted(); 101 void ReportSnapshotCompleted();
102 void ReportDownloadStatusToRequestCoordinator(); 102 void ReportDownloadStatusToRequestCoordinator();
103 bool IsSamePage() const; 103 bool IsSamePage() const;
104 ClientId GetRecentPagesClientId() const; 104 ClientId GetRecentPagesClientId() const;
105 bool isSnapshottingForLastN() const;
dewittj 2017/01/17 23:21:52 This method feels like it should be part of Downlo
carlosk 2017/01/18 03:06:10 Done.
105 106
106 // Page model is a service, no ownership. Can be null - for example, in 107 // Page model is a service, no ownership. Can be null - for example, in
107 // case when tab is in incognito profile. 108 // case when tab is in incognito profile.
108 OfflinePageModel* page_model_; 109 OfflinePageModel* page_model_ = nullptr;
109 110
110 // If false, never make snapshots off the attached WebContents. 111 // If false, never make snapshots off the attached WebContents.
111 // Not page-specific. 112 // Not page-specific.
112 bool snapshots_enabled_; 113 bool snapshots_enabled_ = false;
113 114
114 // Becomes true during navigation if the page is ready for snapshot as 115 // Becomes true during navigation if the page is ready for snapshot as
115 // indicated by at least one callback from SnapshotController. 116 // indicated by at least one callback from SnapshotController.
116 bool is_page_ready_for_snapshot_; 117 bool is_page_ready_for_snapshot_ = false;
117 118
118 // Info for the offline page to capture. Null if the tab is not capturing 119 // Info for the offline page to capture. Null if the tab is not capturing
119 // current page. 120 // current page.
120 std::unique_ptr<DownloadPageInfo> download_info_; 121 std::unique_ptr<DownloadPageInfo> download_info_;
121 122
122 // If empty, the tab does not have AndroidId and can not capture pages. 123 // If empty, the tab does not have AndroidId and can not capture pages.
123 std::string tab_id_; 124 std::string tab_id_;
124 125
125 // The URL of the page that is currently being snapshotted. Used to check, 126 // The URL of the page that is currently being snapshotted. Used to check,
126 // during async operations, that WebContents still contains the same page. 127 // during async operations, that WebContents still contains the same page.
127 GURL snapshot_url_; 128 GURL snapshot_url_;
128 // This starts out null and used as a flag for EnsureInitialized() to do the 129 // This starts out null and used as a flag for EnsureInitialized() to do the
129 // initialization only once. 130 // initialization only once.
130 std::unique_ptr<SnapshotController> snapshot_controller_; 131 std::unique_ptr<SnapshotController> snapshot_controller_;
131 132
132 std::unique_ptr<Delegate> delegate_; 133 std::unique_ptr<Delegate> delegate_;
133 134
134 base::WeakPtrFactory<RecentTabHelper> weak_ptr_factory_; 135 base::WeakPtrFactory<RecentTabHelper> weak_ptr_factory_;
135 136
136 DISALLOW_COPY_AND_ASSIGN(RecentTabHelper); 137 DISALLOW_COPY_AND_ASSIGN(RecentTabHelper);
137 }; 138 };
138 139
139 } // namespace offline_pages 140 } // namespace offline_pages
140 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_ 141 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698