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); |