| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/tab_contents/tab_contents_observer.h" | 8 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 9 | 9 |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 | 11 |
| 12 class TabContentsWrapper; | 12 class TabContentsWrapper; |
| 13 class GURL; | 13 class GURL; |
| 14 | 14 |
| 15 namespace prerender { | 15 namespace prerender { |
| 16 | 16 |
| 17 class PrerenderContents; | 17 class PrerenderContents; |
| 18 class PrerenderManager; | 18 class PrerenderManager; |
| 19 | 19 |
| 20 // PrerenderTabHelper is responsible for recording perceived pageload times | 20 // PrerenderTabHelper is responsible for recording perceived pageload times |
| 21 // to compare PLT's with prerendering enabled and disabled. | 21 // to compare PLT's with prerendering enabled and disabled. |
| 22 class PrerenderTabHelper : public TabContentsObserver { | 22 class PrerenderTabHelper : public TabContentsObserver { |
| 23 public: | 23 public: |
| 24 explicit PrerenderTabHelper(TabContentsWrapper* tab); | 24 explicit PrerenderTabHelper(TabContentsWrapper* tab); |
| 25 virtual ~PrerenderTabHelper(); | 25 virtual ~PrerenderTabHelper(); |
| 26 | 26 |
| 27 // TabContentsObserver implementation. | 27 // TabContentsObserver implementation. |
| 28 virtual void ProvisionalChangeToMainFrameUrl(const GURL& url, | 28 virtual void ProvisionalChangeToMainFrameUrl(const GURL& url, |
| 29 bool has_opener_set) OVERRIDE; | 29 bool has_opener_set) OVERRIDE; |
| 30 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 31 virtual void DidStopLoading() OVERRIDE; | 30 virtual void DidStopLoading() OVERRIDE; |
| 32 | 31 |
| 33 // Called when this prerendered TabContents has just been swapped in. | 32 // Called when this prerendered TabContents has just been swapped in. |
| 34 void PrerenderSwappedIn(); | 33 void PrerenderSwappedIn(); |
| 35 | 34 |
| 35 void DidStartProvisionalLoadForFrame(int64 frame_id, |
| 36 bool is_main_frame, |
| 37 bool has_opener_set, |
| 38 const GURL& url); |
| 39 |
| 40 void UpdateTargetURL(int32 page_id, const GURL& url); |
| 41 |
| 36 private: | 42 private: |
| 37 // The data we store for a hover (time the hover occurred & URL). | 43 // The data we store for a hover (time the hover occurred & URL). |
| 38 class HoverData; | 44 class HoverData; |
| 39 | 45 |
| 40 // Message handler. | |
| 41 void OnDidStartProvisionalLoadForFrame(int64 frame_id, | |
| 42 bool main_frame, | |
| 43 bool has_opener_set, | |
| 44 const GURL& url); | |
| 45 | |
| 46 void OnMsgUpdateTargetURL(int32 page_id, const GURL& url); | |
| 47 | |
| 48 // Retrieves the PrerenderManager, or NULL, if none was found. | 46 // Retrieves the PrerenderManager, or NULL, if none was found. |
| 49 PrerenderManager* MaybeGetPrerenderManager() const; | 47 PrerenderManager* MaybeGetPrerenderManager() const; |
| 50 | 48 |
| 51 // Checks with the PrerenderManager if the specified URL has been preloaded, | 49 // Checks with the PrerenderManager if the specified URL has been preloaded, |
| 52 // and if so, swap the RenderViewHost with the preload into this TabContents | 50 // and if so, swap the RenderViewHost with the preload into this TabContents |
| 53 // object. | 51 // object. |
| 54 bool MaybeUsePrerenderedPage(const GURL& url, bool has_opener_set); | 52 bool MaybeUsePrerenderedPage(const GURL& url, bool has_opener_set); |
| 55 | 53 |
| 56 // Returns whether the TabContents being observed is currently prerendering. | 54 // Returns whether the TabContents being observed is currently prerendering. |
| 57 bool IsPrerendering(); | 55 bool IsPrerendering(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 76 // Information about the current hover independent of thresholds. | 74 // Information about the current hover independent of thresholds. |
| 77 GURL current_hover_url_; | 75 GURL current_hover_url_; |
| 78 base::TimeTicks current_hover_time_; | 76 base::TimeTicks current_hover_time_; |
| 79 | 77 |
| 80 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); | 78 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); |
| 81 }; | 79 }; |
| 82 | 80 |
| 83 } // namespace prerender | 81 } // namespace prerender |
| 84 | 82 |
| 85 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ | 83 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ |
| OLD | NEW |