Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: chrome/browser/prerender/prerender_tab_helper.h

Issue 10316020: Remove WebContentsImpl::OnDidRedirectProvisionalLoad. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move redirect handling into a helper method. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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,
41 const GURL& validated_url, 40 const GURL& validated_url,
42 content::PageTransition transition_type, 41 content::PageTransition transition_type,
43 content::RenderViewHost* render_view_host) OVERRIDE; 42 content::RenderViewHost* render_view_host) OVERRIDE;
44 // Called when this prerendered TabContents has just been swapped in. 43 // Called when this prerendered TabContents has just been swapped in.
45 void PrerenderSwappedIn(); 44 void PrerenderSwappedIn();
46 45
46 // content::NotificationObserver
cbentzel 2012/05/17 18:52:05 Why did this move to the public interface in this
47 virtual void Observe(int type,
48 const content::NotificationSource& source,
49 const content::NotificationDetails& details) OVERRIDE;
50
47 private: 51 private:
48 // Helper class to compute pixel-based stats on the paint progress 52 // Helper class to compute pixel-based stats on the paint progress
49 // between when a prerendered page is swapped in and when the onload event 53 // between when a prerendered page is swapped in and when the onload event
50 // fires. 54 // fires.
51 class PixelStats; 55 class PixelStats;
52 scoped_ptr<PixelStats> pixel_stats_; 56 scoped_ptr<PixelStats> pixel_stats_;
53 57
54 // Retrieves the PrerenderManager, or NULL, if none was found. 58 // Retrieves the PrerenderManager, or NULL, if none was found.
55 PrerenderManager* MaybeGetPrerenderManager() const; 59 PrerenderManager* MaybeGetPrerenderManager() const;
56 60
57 // Returns whether the WebContents being observed is currently prerendering. 61 // Returns whether the WebContents being observed is currently prerendering.
58 bool IsPrerendering(); 62 bool IsPrerendering();
59 63
60 // Returns whether the WebContents being observed was prerendered. 64 // Returns whether the WebContents being observed was prerendered.
61 bool IsPrerendered(); 65 bool IsPrerendered();
62 66
63 bool IsTopSite(const GURL& url); 67 bool IsTopSite(const GURL& url);
64 68
69 void HandleResourceReceivedRedirect(const GURL& new_url);
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_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_tab_helper.cc » ('j') | chrome/browser/prerender/prerender_tab_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698