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 "base/time.h" | 8 #include "base/time.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 | 14 |
15 class TabContents; | 15 class TabContents; |
16 typedef TabContents TabContentsWrapper; | |
17 | 16 |
18 namespace prerender { | 17 namespace prerender { |
19 | 18 |
20 class PrerenderManager; | 19 class PrerenderManager; |
21 | 20 |
22 // PrerenderTabHelper is responsible for recording perceived pageload times | 21 // PrerenderTabHelper is responsible for recording perceived pageload times |
23 // to compare PLT's with prerendering enabled and disabled. | 22 // to compare PLT's with prerendering enabled and disabled. |
24 class PrerenderTabHelper : public content::NotificationObserver, | 23 class PrerenderTabHelper : public content::NotificationObserver, |
25 public content::WebContentsObserver { | 24 public content::WebContentsObserver { |
26 public: | 25 public: |
27 explicit PrerenderTabHelper(TabContentsWrapper* tab); | 26 explicit PrerenderTabHelper(TabContents* tab); |
28 virtual ~PrerenderTabHelper(); | 27 virtual ~PrerenderTabHelper(); |
29 | 28 |
30 // content::WebContentsObserver implementation. | 29 // content::WebContentsObserver implementation. |
31 virtual void DidStopLoading() OVERRIDE; | 30 virtual void DidStopLoading() OVERRIDE; |
32 virtual void DidStartProvisionalLoadForFrame( | 31 virtual void DidStartProvisionalLoadForFrame( |
33 int64 frame_id, | 32 int64 frame_id, |
34 bool is_main_frame, | 33 bool is_main_frame, |
35 const GURL& validated_url, | 34 const GURL& validated_url, |
36 bool is_error_page, | 35 bool is_error_page, |
37 content::RenderViewHost* render_view_host) OVERRIDE; | 36 content::RenderViewHost* render_view_host) OVERRIDE; |
(...skipping 23 matching lines...) Expand all Loading... |
61 bool IsPrerendered(); | 60 bool IsPrerendered(); |
62 | 61 |
63 void HandleResourceReceivedRedirect(const GURL& new_url); | 62 void HandleResourceReceivedRedirect(const GURL& new_url); |
64 | 63 |
65 // content::NotificationObserver | 64 // content::NotificationObserver |
66 virtual void Observe( | 65 virtual void Observe( |
67 int type, | 66 int type, |
68 const content::NotificationSource& source, | 67 const content::NotificationSource& source, |
69 const content::NotificationDetails& details) OVERRIDE; | 68 const content::NotificationDetails& details) OVERRIDE; |
70 | 69 |
71 // TabContentsWrapper we're created for. | 70 // TabContents we're created for. |
72 TabContentsWrapper* tab_; | 71 TabContents* tab_; |
73 | 72 |
74 // System time at which the current load was started for the purpose of | 73 // System time at which the current load was started for the purpose of |
75 // the perceived page load time (PPLT). | 74 // the perceived page load time (PPLT). |
76 base::TimeTicks pplt_load_start_; | 75 base::TimeTicks pplt_load_start_; |
77 | 76 |
78 // System time at which the actual pageload started (pre-swapin), if | 77 // System time at which the actual pageload started (pre-swapin), if |
79 // a applicable (in cases when a prerender that was still loading was | 78 // a applicable (in cases when a prerender that was still loading was |
80 // swapped in). | 79 // swapped in). |
81 base::TimeTicks actual_load_start_; | 80 base::TimeTicks actual_load_start_; |
82 | 81 |
83 // Current URL being loaded. | 82 // Current URL being loaded. |
84 GURL url_; | 83 GURL url_; |
85 | 84 |
86 content::NotificationRegistrar notification_registrar_; | 85 content::NotificationRegistrar notification_registrar_; |
87 | 86 |
88 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); | 87 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); |
89 }; | 88 }; |
90 | 89 |
91 } // namespace prerender | 90 } // namespace prerender |
92 | 91 |
93 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ | 92 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
OLD | NEW |