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

Unified Diff: chrome/browser/android/offline_pages/recent_tab_helper.h

Issue 2092983002: Change the RecentTabHelper to only capture the last one page in a tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed unused variable 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/offline_pages/recent_tab_helper.h
diff --git a/chrome/browser/android/offline_pages/recent_tab_helper.h b/chrome/browser/android/offline_pages/recent_tab_helper.h
index 025f52b8fbce9d61a67d79cb7270e2b931dd1321..8d65fa9e9ab4c2539aa1a78ff3e07a6defe7f0c6 100644
--- a/chrome/browser/android/offline_pages/recent_tab_helper.h
+++ b/chrome/browser/android/offline_pages/recent_tab_helper.h
@@ -51,19 +51,27 @@ class RecentTabHelper
virtual std::unique_ptr<OfflinePageArchiver> CreateArchiver(
content::WebContents* web_contents) = 0;
};
- // Test method, overrides the normally used MHTML Archivers with a test
- // mocks created by specified function.
- void SetArchiveFactoryForTest(
- std::unique_ptr<TestArchiveFactory> test_archive_factory);
- // Test method, overrides the task_runner_ so FastForwardBy() can be used.
- void SetTaskRunnerForTest(
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
+
+
+ // Delegate that is used by RecentTabHelper to get external dependencies.
+ // Default implementation lives in .cc file, while tests provide an override.
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+ virtual std::unique_ptr<OfflinePageArchiver> CreatePageArchiver(
+ content::WebContents* web_contents) = 0;
+ virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() = 0;
+ // There is no expectations that tab_id is always present.
+ virtual bool GetTabId(content::WebContents* web_contents, int* tab_id) = 0;
+ };
+ void SetDelegate(std::unique_ptr<RecentTabHelper::Delegate> delegate);
private:
explicit RecentTabHelper(content::WebContents* web_contents);
friend class content::WebContentsUserData<RecentTabHelper>;
+ void LazyInitialize();
void ContinueSnapshotWithIdsToPurge(const std::vector<int64_t>& page_ids);
void ContinueSnapshotAfterPurge(OfflinePageModel::DeletePageResult result);
void SavePageCallback(OfflinePageModel::SavePageResult result,
@@ -75,15 +83,17 @@ class RecentTabHelper
// Page model is a service, no ownership.
OfflinePageModel* page_model_;
-
// If true, never make snapshots off the attached WebContents.
bool never_do_snapshots_;
+ // If empty, the tab does not have AndroidId and can not capture pages.
+ std::string tab_id_;
// The URL of the page that is currently being snapshotted. Used to check,
// during async operations, that WebContents still contains the same page.
GURL snapshot_url_;
std::unique_ptr<SnapshotController> snapshot_controller_;
- std::unique_ptr<TestArchiveFactory> test_archive_factory_;
+
+ std::unique_ptr<Delegate> delegate_;
base::WeakPtrFactory<RecentTabHelper> weak_ptr_factory_;
« 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