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

Side by Side 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 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
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 // Test support. 45 // Test support.
46 // A factory that supplies the instances of an OfflinePageArchiver. 46 // A factory that supplies the instances of an OfflinePageArchiver.
47 // This is used for testing, where we want to use a specific mock. 47 // This is used for testing, where we want to use a specific mock.
48 class TestArchiveFactory { 48 class TestArchiveFactory {
49 public: 49 public:
50 virtual ~TestArchiveFactory() {} 50 virtual ~TestArchiveFactory() {}
51 virtual std::unique_ptr<OfflinePageArchiver> CreateArchiver( 51 virtual std::unique_ptr<OfflinePageArchiver> CreateArchiver(
52 content::WebContents* web_contents) = 0; 52 content::WebContents* web_contents) = 0;
53 }; 53 };
54 // Test method, overrides the normally used MHTML Archivers with a test 54
55 // mocks created by specified function. 55
56 void SetArchiveFactoryForTest( 56 // Delegate that is used by RecentTabHelper to get external dependencies.
57 std::unique_ptr<TestArchiveFactory> test_archive_factory); 57 // Default implementation lives in .cc file, while tests provide an override.
58 // Test method, overrides the task_runner_ so FastForwardBy() can be used. 58 class Delegate {
59 void SetTaskRunnerForTest( 59 public:
60 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); 60 virtual ~Delegate() {}
61 virtual std::unique_ptr<OfflinePageArchiver> CreatePageArchiver(
62 content::WebContents* web_contents) = 0;
63 virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() = 0;
64 // There is no expectations that tab_id is always present.
65 virtual bool GetTabId(content::WebContents* web_contents, int* tab_id) = 0;
66 };
67 void SetDelegate(std::unique_ptr<RecentTabHelper::Delegate> delegate);
61 68
62 private: 69 private:
63 explicit RecentTabHelper(content::WebContents* web_contents); 70 explicit RecentTabHelper(content::WebContents* web_contents);
64 friend class content::WebContentsUserData<RecentTabHelper>; 71 friend class content::WebContentsUserData<RecentTabHelper>;
65 72
66 73
74 void LazyInitialize();
67 void ContinueSnapshotWithIdsToPurge(const std::vector<int64_t>& page_ids); 75 void ContinueSnapshotWithIdsToPurge(const std::vector<int64_t>& page_ids);
68 void ContinueSnapshotAfterPurge(OfflinePageModel::DeletePageResult result); 76 void ContinueSnapshotAfterPurge(OfflinePageModel::DeletePageResult result);
69 void SavePageCallback(OfflinePageModel::SavePageResult result, 77 void SavePageCallback(OfflinePageModel::SavePageResult result,
70 int64_t offline_id); 78 int64_t offline_id);
71 79
72 void ReportSnapshotCompleted(); 80 void ReportSnapshotCompleted();
73 bool IsSamePage() const; 81 bool IsSamePage() const;
74 ClientId client_id() const; 82 ClientId client_id() const;
75 83
76 // Page model is a service, no ownership. 84 // Page model is a service, no ownership.
77 OfflinePageModel* page_model_; 85 OfflinePageModel* page_model_;
78
79 // If true, never make snapshots off the attached WebContents. 86 // If true, never make snapshots off the attached WebContents.
80 bool never_do_snapshots_; 87 bool never_do_snapshots_;
88 // If empty, the tab does not have AndroidId and can not capture pages.
89 std::string tab_id_;
81 90
82 // The URL of the page that is currently being snapshotted. Used to check, 91 // The URL of the page that is currently being snapshotted. Used to check,
83 // during async operations, that WebContents still contains the same page. 92 // during async operations, that WebContents still contains the same page.
84 GURL snapshot_url_; 93 GURL snapshot_url_;
85 std::unique_ptr<SnapshotController> snapshot_controller_; 94 std::unique_ptr<SnapshotController> snapshot_controller_;
86 std::unique_ptr<TestArchiveFactory> test_archive_factory_; 95
96 std::unique_ptr<Delegate> delegate_;
87 97
88 base::WeakPtrFactory<RecentTabHelper> weak_ptr_factory_; 98 base::WeakPtrFactory<RecentTabHelper> weak_ptr_factory_;
89 99
90 DISALLOW_COPY_AND_ASSIGN(RecentTabHelper); 100 DISALLOW_COPY_AND_ASSIGN(RecentTabHelper);
91 }; 101 };
92 102
93 } // namespace offline_pages 103 } // namespace offline_pages
94 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_RECENT_TAB_HELPER_H_ 104 #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