| 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_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_OBSERVER_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_OBSERVER_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 TabContents; | 12 class TabContents; |
| 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 // PrerenderObserver is responsible for recording perceived pageload times | 20 // PrerenderObserver 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 PrerenderObserver : public TabContentsObserver { | 22 class PrerenderObserver : public TabContentsObserver { |
| 23 public: | 23 public: |
| 24 explicit PrerenderObserver(TabContents* tab_contents); | 24 explicit PrerenderObserver(TabContents* tab_contents); |
| 25 virtual ~PrerenderObserver(); | 25 virtual ~PrerenderObserver(); |
| 26 | 26 |
| 27 // TabContentsObserver implementation. | 27 // TabContentsObserver implementation. |
| 28 virtual void ProvisionalChangeToMainFrameUrl(const GURL& url) OVERRIDE; | 28 virtual void ProvisionalChangeToMainFrameUrl(const GURL& url, |
| 29 bool has_opener_set) OVERRIDE; |
| 29 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 30 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 30 virtual void DidStopLoading() OVERRIDE; | 31 virtual void DidStopLoading() OVERRIDE; |
| 31 | 32 |
| 32 // Message handler. | 33 // Message handler. |
| 33 void OnDidStartProvisionalLoadForFrame(int64 frame_id, | 34 void OnDidStartProvisionalLoadForFrame(int64 frame_id, |
| 34 bool main_frame, | 35 bool main_frame, |
| 36 bool has_opener_set, |
| 35 const GURL& url); | 37 const GURL& url); |
| 36 | 38 |
| 37 private: | 39 private: |
| 38 // Retrieves the PrerenderManager, or NULL, if none was found. | 40 // Retrieves the PrerenderManager, or NULL, if none was found. |
| 39 PrerenderManager* MaybeGetPrerenderManager(); | 41 PrerenderManager* MaybeGetPrerenderManager(); |
| 40 | 42 |
| 41 // Checks with the PrerenderManager if the specified URL has been preloaded, | 43 // Checks with the PrerenderManager if the specified URL has been preloaded, |
| 42 // and if so, swap the RenderViewHost with the preload into this TabContents | 44 // and if so, swap the RenderViewHost with the preload into this TabContents |
| 43 // object. | 45 // object. |
| 44 bool MaybeUsePreloadedPage(const GURL& url); | 46 bool MaybeUsePreloadedPage(const GURL& url, bool has_opener_set); |
| 45 | 47 |
| 46 // Returns whether the TabContents being observed is currently prerendering. | 48 // Returns whether the TabContents being observed is currently prerendering. |
| 47 bool IsPrerendering(); | 49 bool IsPrerendering(); |
| 48 | 50 |
| 49 // System time at which the current load was started for the purpose of | 51 // System time at which the current load was started for the purpose of |
| 50 // the perceived page load time (PPLT). | 52 // the perceived page load time (PPLT). |
| 51 base::TimeTicks pplt_load_start_; | 53 base::TimeTicks pplt_load_start_; |
| 52 | 54 |
| 53 DISALLOW_COPY_AND_ASSIGN(PrerenderObserver); | 55 DISALLOW_COPY_AND_ASSIGN(PrerenderObserver); |
| 54 }; | 56 }; |
| 55 | 57 |
| 56 } // namespace prerender | 58 } // namespace prerender |
| 57 | 59 |
| 58 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_OBSERVER_H_ | 60 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_OBSERVER_H_ |
| OLD | NEW |