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