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

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: added unittests, process 'no id' case 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
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..c5db7362834dc1c76337bd71251c9ff8910ba7b3 100644
--- a/chrome/browser/android/offline_pages/recent_tab_helper.h
+++ b/chrome/browser/android/offline_pages/recent_tab_helper.h
@@ -51,13 +51,20 @@ 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(int* tab_id, content::WebContents* web_contents) = 0;
+ };
+ void Initialize(std::unique_ptr<RecentTabHelper::Delegate> delegate);
private:
explicit RecentTabHelper(content::WebContents* web_contents);
@@ -75,15 +82,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_;

Powered by Google App Engine
This is Rietveld 408576698