Chromium Code Reviews| 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 // content::NotificationObserver | |
| 65 virtual void Observe(int type, | |
| 66 const content::NotificationSource& source, | |
| 67 const content::NotificationDetails& details) OVERRIDE; | |
| 68 | |
| 69 // Adds an alias URL, for one of the many redirections. If the URL can not | |
|
cbentzel
2012/05/17 17:42:39
This comment looks like a bad copy-and-paste.
Deprecated (see juliatuttle)
2012/05/17 18:42:21
Done.
| |
| 65 // TabContentsWrapper we're created for. | 70 // TabContentsWrapper we're created for. |
| 66 TabContentsWrapper* tab_; | 71 TabContentsWrapper* tab_; |
| 67 | 72 |
| 68 // 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 |
| 69 // the perceived page load time (PPLT). | 74 // the perceived page load time (PPLT). |
| 70 base::TimeTicks pplt_load_start_; | 75 base::TimeTicks pplt_load_start_; |
| 71 | 76 |
| 72 // System time at which the actual pageload started (pre-swapin), if | 77 // System time at which the actual pageload started (pre-swapin), if |
| 73 // 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 |
| 74 // swapped in). | 79 // swapped in). |
| 75 base::TimeTicks actual_load_start_; | 80 base::TimeTicks actual_load_start_; |
| 76 | 81 |
| 77 // Current URL being loaded. | 82 // Current URL being loaded. |
| 78 GURL url_; | 83 GURL url_; |
| 79 | 84 |
| 85 content::NotificationRegistrar notification_registrar_; | |
| 86 | |
| 80 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); | 87 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); |
| 81 }; | 88 }; |
| 82 | 89 |
| 83 } // namespace prerender | 90 } // namespace prerender |
| 84 | 91 |
| 85 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ | 92 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
| OLD | NEW |