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

Unified Diff: chrome/browser/prerender/prerender_manager.h

Issue 2304953002: NoState Prefetch: nostate prefetch browser tests. (Closed)
Patch Set: Remove injection at factory Created 4 years, 2 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/prerender/prerender_manager.h
diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h
index 8f335719c06c6326398d5fdc61287bfc8d1d3936..4e18a2ee20f6c57ae3dd3ee2e46535160430de47 100644
--- a/chrome/browser/prerender/prerender_manager.h
+++ b/chrome/browser/prerender/prerender_manager.h
@@ -99,6 +99,13 @@ class PrerenderManager : public content::NotificationObserver,
CLEAR_MAX = 0x1 << 2
};
+ // Used to manipulate time for testing.
+ class TimeOverride {
+ public:
+ virtual base::Time GetCurrentTime() const = 0;
+ virtual base::TimeTicks GetCurrentTimeTicks() const = 0;
+ };
+
// Owned by a Profile object for the lifetime of the profile.
explicit PrerenderManager(Profile* profile);
~PrerenderManager() override;
@@ -312,11 +319,11 @@ class PrerenderManager : public content::NotificationObserver,
Profile* profile() const { return profile_; }
- // Classes which will be tested in prerender unit browser tests should use
- // these methods to get times for comparison, so that the test framework can
- // mock advancing/retarding time.
- virtual base::Time GetCurrentTime() const;
- virtual base::TimeTicks GetCurrentTimeTicks() const;
+ base::Time GetCurrentTime() const;
+ base::TimeTicks GetCurrentTimeTicks() const;
+
+ // For testing.
+ void SetTimeOverride(std::unique_ptr<TimeOverride> override);
pasko 2016/10/05 12:35:24 The convention is to call it like: SetTimeOverride
// Notification that a prerender has completed and its bytes should be
// recorded.
@@ -596,6 +603,8 @@ class PrerenderManager : public content::NotificationObserver,
using PrerenderProcessSet = std::set<content::RenderProcessHost*>;
PrerenderProcessSet prerender_process_hosts_;
+ std::unique_ptr<TimeOverride> time_override_;
+
base::WeakPtrFactory<PrerenderManager> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(PrerenderManager);

Powered by Google App Engine
This is Rietveld 408576698