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