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

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

Issue 7059019: Ensure that PageID's of prerendered pages do not exceed the Page ID of the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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) 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 #include "chrome/browser/prerender/prerender_contents.h" 5 #include "chrome/browser/prerender/prerender_contents.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 render_view_host_(NULL), 131 render_view_host_(NULL),
132 prerender_url_(url), 132 prerender_url_(url),
133 referrer_(referrer), 133 referrer_(referrer),
134 profile_(profile), 134 profile_(profile),
135 page_id_(0), 135 page_id_(0),
136 ALLOW_THIS_IN_INITIALIZER_LIST(tab_contents_observer_registrar_(this)), 136 ALLOW_THIS_IN_INITIALIZER_LIST(tab_contents_observer_registrar_(this)),
137 has_stopped_loading_(false), 137 has_stopped_loading_(false),
138 final_status_(FINAL_STATUS_MAX), 138 final_status_(FINAL_STATUS_MAX),
139 prerendering_has_started_(false), 139 prerendering_has_started_(false),
140 child_id_(-1), 140 child_id_(-1),
141 route_id_(-1) { 141 route_id_(-1),
142 starting_page_id_(-1) {
142 DCHECK(prerender_manager != NULL); 143 DCHECK(prerender_manager != NULL);
143 } 144 }
144 145
145 bool PrerenderContents::Init() { 146 bool PrerenderContents::Init() {
146 if (!AddAliasURL(prerender_url_)) 147 if (!AddAliasURL(prerender_url_))
147 return false; 148 return false;
148 return true; 149 return true;
149 } 150 }
150 151
151 // static 152 // static
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 prerender_contents_.reset(new TabContentsWrapper(new_contents)); 256 prerender_contents_.reset(new TabContentsWrapper(new_contents));
256 tab_contents_observer_registrar_.Observe(new_contents); 257 tab_contents_observer_registrar_.Observe(new_contents);
257 prerender_contents_->download_tab_helper()->set_delegate(this); 258 prerender_contents_->download_tab_helper()->set_delegate(this);
258 259
259 TabContents* source_tc = 260 TabContents* source_tc =
260 source_render_view_host->delegate()->GetAsTabContents(); 261 source_render_view_host->delegate()->GetAsTabContents();
261 if (source_tc) { 262 if (source_tc) {
262 // So that history merging will work, get the max page ID 263 // So that history merging will work, get the max page ID
263 // of the old page, and add a safety margin of 10 to it (for things 264 // of the old page, and add a safety margin of 10 to it (for things
264 // such as redirects). 265 // such as redirects).
265 int32 max_page_id = source_tc->GetMaxPageID(); 266 starting_page_id_ = source_tc->GetMaxPageID();
266 if (max_page_id != -1) { 267 if (starting_page_id_ < 0)
267 prerender_contents_->controller().set_max_restored_page_id( 268 starting_page_id_ = 0;
268 max_page_id + 10); 269 starting_page_id_ += kPrerenderPageIdOffset;
269 } 270 prerender_contents_->controller().set_max_restored_page_id(
271 starting_page_id_);
270 272
271 tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); 273 tab_contents_delegate_.reset(new TabContentsDelegateImpl(this));
272 new_contents->set_delegate(tab_contents_delegate_.get()); 274 new_contents->set_delegate(tab_contents_delegate_.get());
273 275
274 // Set the size of the new TC to that of the old TC. 276 // Set the size of the new TC to that of the old TC.
275 gfx::Rect tab_bounds; 277 gfx::Rect tab_bounds;
276 source_tc->view()->GetContainerBounds(&tab_bounds); 278 source_tc->view()->GetContainerBounds(&tab_bounds);
277 prerender_contents_->view()->SizeContents(tab_bounds.size()); 279 prerender_contents_->view()->SizeContents(tab_bounds.size());
278 } 280 }
279 281
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 } 824 }
823 return render_view_host_; 825 return render_view_host_;
824 } 826 }
825 827
826 void PrerenderContents::CommitHistory(TabContents* tc) { 828 void PrerenderContents::CommitHistory(TabContents* tc) {
827 if (tab_contents_delegate_.get()) 829 if (tab_contents_delegate_.get())
828 tab_contents_delegate_->CommitHistory(tc); 830 tab_contents_delegate_->CommitHistory(tc);
829 } 831 }
830 832
831 } // namespace prerender 833 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_contents.h ('k') | chrome/browser/prerender/prerender_final_status.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698