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

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

Issue 6685012: Give prerendering RVH's RenderWidgetHostViews. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 'queued' renamed to 'pending' Created 9 years, 8 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) 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_CONTENTS_H_ 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "chrome/browser/prerender/prerender_final_status.h" 14 #include "chrome/browser/prerender/prerender_final_status.h"
15 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" 15 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
16 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" 16 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h"
17 #include "chrome/common/view_types.h" 17 #include "chrome/common/view_types.h"
18 #include "content/browser/renderer_host/render_view_host_delegate.h" 18 #include "content/browser/renderer_host/render_view_host_delegate.h"
19 #include "content/common/notification_registrar.h" 19 #include "content/common/notification_registrar.h"
20 #include "content/common/window_container_type.h" 20 #include "content/common/window_container_type.h"
21 #include "webkit/glue/window_open_disposition.h" 21 #include "webkit/glue/window_open_disposition.h"
22 22
23 class RenderViewHost;
23 class TabContents; 24 class TabContents;
24 struct FaviconURL; 25 struct FaviconURL;
26 struct ViewHostMsg_FrameNavigate_Params;
25 struct WebPreferences; 27 struct WebPreferences;
26 struct ViewHostMsg_FrameNavigate_Params;
27 28
28 namespace base { 29 namespace base {
29 class ProcessMetrics; 30 class ProcessMetrics;
30 } 31 }
31 32
32 namespace gfx { 33 namespace gfx {
33 class Rect; 34 class Rect;
34 } 35 }
35 36
36 namespace prerender { 37 namespace prerender {
(...skipping 22 matching lines...) Expand all
59 const std::vector<GURL>& alias_urls, const GURL& referrer) = 0; 60 const std::vector<GURL>& alias_urls, const GURL& referrer) = 0;
60 61
61 private: 62 private:
62 DISALLOW_COPY_AND_ASSIGN(Factory); 63 DISALLOW_COPY_AND_ASSIGN(Factory);
63 }; 64 };
64 65
65 virtual ~PrerenderContents(); 66 virtual ~PrerenderContents();
66 67
67 static Factory* CreateFactory(); 68 static Factory* CreateFactory();
68 69
69 virtual void StartPrerendering(); 70 // |source_render_view_host| is the RenderViewHost that initiated
71 // prerendering. It must be non-NULL and have its own view. It is used
72 // solely to determine the window bounds while prerendering.
73 virtual void StartPrerendering(const RenderViewHost* source_render_view_host);
70 74
71 // Verifies that the prerendering is not using too many resources, and kills 75 // Verifies that the prerendering is not using too many resources, and kills
72 // it if not. 76 // it if not.
73 void DestroyWhenUsingTooManyResources(); 77 void DestroyWhenUsingTooManyResources();
74 78
75 RenderViewHost* render_view_host() { return render_view_host_; } 79 RenderViewHost* render_view_host() { return render_view_host_; }
76 // Allows replacing of the RenderViewHost owned by this class, including 80 // Allows replacing of the RenderViewHost owned by this class, including
77 // replacing with a NULL value. When a caller uses this, the caller will 81 // replacing with a NULL value. When a caller uses this, the caller will
78 // own (and is responsible for freeing) the old RVH. 82 // own (and is responsible for freeing) the old RVH.
79 void set_render_view_host(RenderViewHost* rvh) { render_view_host_ = rvh; } 83 void set_render_view_host(RenderViewHost* rvh) { render_view_host_ = rvh; }
(...skipping 13 matching lines...) Expand all
93 // Sets the parameter to the value of the associated RenderViewHost's route id 97 // Sets the parameter to the value of the associated RenderViewHost's route id
94 // and returns a boolean indicating the validity of that id. 98 // and returns a boolean indicating the validity of that id.
95 virtual bool GetRouteId(int* route_id) const; 99 virtual bool GetRouteId(int* route_id) const;
96 100
97 // Set the final status for how the PrerenderContents was used. This 101 // Set the final status for how the PrerenderContents was used. This
98 // should only be called once, and should be called before the prerender 102 // should only be called once, and should be called before the prerender
99 // contents are destroyed. 103 // contents are destroyed.
100 void set_final_status(FinalStatus final_status); 104 void set_final_status(FinalStatus final_status);
101 FinalStatus final_status() const; 105 FinalStatus final_status() const;
102 106
107 // Set instead of |final_status_| when it is not safe to immediately destroy
108 // the PrerenderContents. It is not guaranteed that the pending status will
109 // be the final FinalStatus if the PrerenderContents is cancelled for some
110 // other reason in the meantime, but it is guaranteed that once set, the RVH
111 // of the PrerenderContents will not be used.
112 void set_pending_final_status(FinalStatus pending_final_status);
113 FinalStatus pending_final_status() const;
114
103 base::TimeTicks load_start_time() const { return load_start_time_; } 115 base::TimeTicks load_start_time() const { return load_start_time_; }
104 116
105 // Indicates whether this prerendered page can be used for the provided 117 // Indicates whether this prerendered page can be used for the provided
106 // URL, i.e. whether there is a match. 118 // URL, i.e. whether there is a match.
107 bool MatchesURL(const GURL& url) const; 119 bool MatchesURL(const GURL& url) const;
108 120
109 // RenderViewHostDelegate implementation. 121 // RenderViewHostDelegate implementation.
110 virtual RenderViewHostDelegate::View* GetViewDelegate(); 122 virtual RenderViewHostDelegate::View* GetViewDelegate();
111 virtual const GURL& GetURL() const; 123 virtual const GURL& GetURL() const;
112 virtual ViewType::Type GetRenderViewType() const; 124 virtual ViewType::Type GetRenderViewType() const;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 NotificationRegistrar registrar_; 266 NotificationRegistrar registrar_;
255 267
256 // A vector of URLs that this prerendered page matches against. 268 // A vector of URLs that this prerendered page matches against.
257 // This array can contain more than element as a result of redirects, 269 // This array can contain more than element as a result of redirects,
258 // such as HTTP redirects or javascript redirects. 270 // such as HTTP redirects or javascript redirects.
259 std::vector<GURL> alias_urls_; 271 std::vector<GURL> alias_urls_;
260 272
261 bool has_stopped_loading_; 273 bool has_stopped_loading_;
262 274
263 FinalStatus final_status_; 275 FinalStatus final_status_;
276 FinalStatus pending_final_status_;
264 277
265 bool prerendering_has_started_; 278 bool prerendering_has_started_;
266 279
267 // Time at which we started to load the URL. This is used to compute 280 // Time at which we started to load the URL. This is used to compute
268 // the time elapsed from initiating a prerender until the time the 281 // the time elapsed from initiating a prerender until the time the
269 // (potentially only partially) prerendered page is shown to the user. 282 // (potentially only partially) prerendered page is shown to the user.
270 base::TimeTicks load_start_time_; 283 base::TimeTicks load_start_time_;
271 284
272 // Process Metrics of the render process associated with the 285 // Process Metrics of the render process associated with the
273 // RenderViewHost for this object. 286 // RenderViewHost for this object.
274 scoped_ptr<base::ProcessMetrics> process_metrics_; 287 scoped_ptr<base::ProcessMetrics> process_metrics_;
275 288
276 // Maximum amount of private memory that may be used per PrerenderContents, 289 // Maximum amount of private memory that may be used per PrerenderContents,
277 // in MB. 290 // in MB.
278 static const int kMaxPrerenderPrivateMB = 100; 291 static const int kMaxPrerenderPrivateMB = 100;
279 292
280 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); 293 DISALLOW_COPY_AND_ASSIGN(PrerenderContents);
281 }; 294 };
282 295
283 } // prerender 296 } // prerender
284 297
285 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ 298 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698