| 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_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
| 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // Called when the URL of the main frame changed, either when the load | 45 // Called when the URL of the main frame changed, either when the load |
| 46 // commits, or a redirect happens. | 46 // commits, or a redirect happens. |
| 47 void MainFrameUrlDidChange(const GURL& url); | 47 void MainFrameUrlDidChange(const GURL& url); |
| 48 | 48 |
| 49 // Called when this prerendered WebContents has just been swapped in. | 49 // Called when this prerendered WebContents has just been swapped in. |
| 50 void PrerenderSwappedIn(); | 50 void PrerenderSwappedIn(); |
| 51 | 51 |
| 52 // Called when a control prerender is resolved. Applies to the next load. | 52 // Called when a control prerender is resolved. Applies to the next load. |
| 53 void WouldHavePrerenderedNextLoad(Origin origin); | 53 void WouldHavePrerenderedNextLoad(Origin origin); |
| 54 | 54 |
| 55 // Computes the time delta from prerender load start to swapped in time. This |
| 56 // adjustment is the difference between actual load or paint times and |
| 57 // perceived times. Returns false if this is called outside the interval from |
| 58 // swap in to page load. |
| 59 bool LoadToPerceivedDelta(base::TimeDelta* delta); |
| 60 |
| 61 Origin origin() const { return origin_; } |
| 62 |
| 55 private: | 63 private: |
| 56 explicit PrerenderTabHelper(content::WebContents* web_contents); | 64 explicit PrerenderTabHelper(content::WebContents* web_contents); |
| 57 friend class content::WebContentsUserData<PrerenderTabHelper>; | 65 friend class content::WebContentsUserData<PrerenderTabHelper>; |
| 58 | 66 |
| 59 void RecordPerceivedPageLoadTime( | 67 void RecordPerceivedPageLoadTime( |
| 60 base::TimeDelta perceived_page_load_time, | 68 base::TimeDelta perceived_page_load_time, |
| 61 double fraction_plt_elapsed_at_swap_in); | 69 double fraction_plt_elapsed_at_swap_in); |
| 62 | 70 |
| 63 // Retrieves the PrerenderManager, or NULL, if none was found. | 71 // Retrieves the PrerenderManager, or NULL, if none was found. |
| 64 PrerenderManager* MaybeGetPrerenderManager() const; | 72 PrerenderManager* MaybeGetPrerenderManager() const; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 90 // System time at which the current load was started for the purpose of | 98 // System time at which the current load was started for the purpose of |
| 91 // the perceived page load time (PPLT). If null, there is no current | 99 // the perceived page load time (PPLT). If null, there is no current |
| 92 // load. | 100 // load. |
| 93 base::TimeTicks pplt_load_start_; | 101 base::TimeTicks pplt_load_start_; |
| 94 | 102 |
| 95 // System time at which the actual pageload started (pre-swapin), if | 103 // System time at which the actual pageload started (pre-swapin), if |
| 96 // a applicable (in cases when a prerender that was still loading was | 104 // a applicable (in cases when a prerender that was still loading was |
| 97 // swapped in). | 105 // swapped in). |
| 98 base::TimeTicks actual_load_start_; | 106 base::TimeTicks actual_load_start_; |
| 99 | 107 |
| 108 // Record the most recent load and swap times. These differ from |
| 109 // |pplt_load_start_| and |actual_load_start_| in that they are not reset in |
| 110 // various circumstances, like a load being stopped. There is no guarantee |
| 111 // about their correctness. For example, if a load somehow starts after a |
| 112 // swap, then |last_load_ > last_swap_|. |
| 113 base::TimeTicks last_load_; |
| 114 base::TimeTicks last_swap_; |
| 115 |
| 100 // Current URL being loaded. | 116 // Current URL being loaded. |
| 101 GURL url_; | 117 GURL url_; |
| 102 | 118 |
| 103 base::WeakPtrFactory<PrerenderTabHelper> weak_factory_; | 119 base::WeakPtrFactory<PrerenderTabHelper> weak_factory_; |
| 104 | 120 |
| 105 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); | 121 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); |
| 106 }; | 122 }; |
| 107 | 123 |
| 108 } // namespace prerender | 124 } // namespace prerender |
| 109 | 125 |
| 110 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ | 126 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
| OLD | NEW |