OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PRERENDER_PRERENDER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 256 |
257 // Adds a condition. This is owned by the PrerenderManager. | 257 // Adds a condition. This is owned by the PrerenderManager. |
258 void AddCondition(const PrerenderCondition* condition); | 258 void AddCondition(const PrerenderCondition* condition); |
259 | 259 |
260 // Records that some visible tab navigated (or was redirected) to the | 260 // Records that some visible tab navigated (or was redirected) to the |
261 // provided URL. | 261 // provided URL. |
262 void RecordNavigation(const GURL& url); | 262 void RecordNavigation(const GURL& url); |
263 | 263 |
264 Profile* profile() const { return profile_; } | 264 Profile* profile() const { return profile_; } |
265 | 265 |
| 266 // Classes which will be tested in prerender unit browser tests should use |
| 267 // these methods to get times for comparison, so that the test framework can |
| 268 // mock advancing/retarding time. |
| 269 virtual base::Time GetCurrentTime() const; |
| 270 virtual base::TimeTicks GetCurrentTimeTicks() const; |
| 271 |
266 protected: | 272 protected: |
267 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> { | 273 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> { |
268 public: | 274 public: |
269 struct OrderByExpiryTime; | 275 struct OrderByExpiryTime; |
270 | 276 |
271 PrerenderData(PrerenderManager* manager, | 277 PrerenderData(PrerenderManager* manager, |
272 PrerenderContents* contents, | 278 PrerenderContents* contents, |
273 base::TimeTicks expiry_time); | 279 base::TimeTicks expiry_time); |
274 | 280 |
275 ~PrerenderData(); | 281 ~PrerenderData(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 | 418 |
413 // Posts a task to call PeriodicCleanup. Results in quicker destruction of | 419 // Posts a task to call PeriodicCleanup. Results in quicker destruction of |
414 // objects. If |this| is deleted before the task is run, the task will | 420 // objects. If |this| is deleted before the task is run, the task will |
415 // automatically be cancelled. | 421 // automatically be cancelled. |
416 void PostCleanupTask(); | 422 void PostCleanupTask(); |
417 | 423 |
418 base::TimeTicks GetExpiryTimeForNewPrerender() const; | 424 base::TimeTicks GetExpiryTimeForNewPrerender() const; |
419 base::TimeTicks GetExpiryTimeForNavigatedAwayPrerender() const; | 425 base::TimeTicks GetExpiryTimeForNavigatedAwayPrerender() const; |
420 | 426 |
421 void DeleteOldEntries(); | 427 void DeleteOldEntries(); |
422 virtual base::Time GetCurrentTime() const; | |
423 virtual base::TimeTicks GetCurrentTimeTicks() const; | |
424 virtual PrerenderContents* CreatePrerenderContents( | 428 virtual PrerenderContents* CreatePrerenderContents( |
425 const GURL& url, | 429 const GURL& url, |
426 const content::Referrer& referrer, | 430 const content::Referrer& referrer, |
427 Origin origin, | 431 Origin origin, |
428 uint8 experiment_id); | 432 uint8 experiment_id); |
429 | 433 |
430 // Insures the |active_prerenders_| are sorted by increasing expiry time. Call | 434 // Insures the |active_prerenders_| are sorted by increasing expiry time. Call |
431 // after every mutation of active_prerenders_ that can possibly make it | 435 // after every mutation of active_prerenders_ that can possibly make it |
432 // unsorted (e.g. an insert, or changing an expiry time). | 436 // unsorted (e.g. an insert, or changing an expiry time). |
433 void SortActivePrerenders(); | 437 void SortActivePrerenders(); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 | 572 |
569 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 573 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
570 }; | 574 }; |
571 | 575 |
572 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 576 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
573 int render_process_id); | 577 int render_process_id); |
574 | 578 |
575 } // namespace prerender | 579 } // namespace prerender |
576 | 580 |
577 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 581 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |