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

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

Issue 10905301: Switch CoreTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 #include "chrome/browser/prerender/prerender_manager.h" 5 #include "chrome/browser/prerender/prerender_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 389
390 // Start pending prerender requests from the PrerenderContents, if there are 390 // Start pending prerender requests from the PrerenderContents, if there are
391 // any. 391 // any.
392 prerender_contents->StartPendingPrerenders(); 392 prerender_contents->StartPendingPrerenders();
393 393
394 TabContents* new_tab_contents = 394 TabContents* new_tab_contents =
395 prerender_contents->ReleasePrerenderContents(); 395 prerender_contents->ReleasePrerenderContents();
396 TabContents* old_tab_contents = TabContents::FromWebContents(web_contents); 396 TabContents* old_tab_contents = TabContents::FromWebContents(web_contents);
397 DCHECK(new_tab_contents); 397 DCHECK(new_tab_contents);
398 DCHECK(old_tab_contents); 398 DCHECK(old_tab_contents);
399 WebContents* new_web_contents = new_tab_contents->web_contents();
400 WebContents* old_web_contents = web_contents;
399 401
gavinp 2012/09/14 23:42:21 Why create all these aliases, including a rename o
Avi (use Gerrit) 2012/09/17 16:05:12 I'm in the process of killing TabContents, so this
gavinp 2012/09/19 04:03:51 I'd rather review that change when it happens, I t
400 MarkWebContentsAsPrerendered(new_tab_contents->web_contents()); 402 MarkWebContentsAsPrerendered(new_web_contents);
401 403
402 // Merge the browsing history. 404 // Merge the browsing history.
403 new_tab_contents->web_contents()->GetController().CopyStateFromAndPrune( 405 new_web_contents->GetController().CopyStateFromAndPrune(
404 &old_tab_contents->web_contents()->GetController()); 406 &old_web_contents->GetController());
405 old_tab_contents->core_tab_helper()->delegate()-> 407 CoreTabHelper::FromWebContents(old_web_contents)->delegate()->
gavinp 2012/09/14 23:42:21 i.e. change only this line.
406 SwapTabContents(old_tab_contents, new_tab_contents); 408 SwapTabContents(old_web_contents, new_web_contents);
407 prerender_contents->CommitHistory(new_tab_contents); 409 prerender_contents->CommitHistory(new_tab_contents);
408 410
409 GURL icon_url = prerender_contents->icon_url(); 411 GURL icon_url = prerender_contents->icon_url();
410 if (!icon_url.is_empty()) { 412 if (!icon_url.is_empty()) {
411 std::vector<FaviconURL> urls; 413 std::vector<FaviconURL> urls;
412 urls.push_back(FaviconURL(icon_url, FaviconURL::FAVICON)); 414 urls.push_back(FaviconURL(icon_url, FaviconURL::FAVICON));
413 new_tab_contents->favicon_tab_helper()->OnUpdateFaviconURL( 415 new_tab_contents->favicon_tab_helper()->OnUpdateFaviconURL(
414 prerender_contents->page_id(), 416 prerender_contents->page_id(),
415 urls); 417 urls);
416 } 418 }
417 419
418 // Update PPLT metrics: 420 // Update PPLT metrics:
419 // If the tab has finished loading, record a PPLT of 0. 421 // If the tab has finished loading, record a PPLT of 0.
420 // If the tab is still loading, reset its start time to the current time. 422 // If the tab is still loading, reset its start time to the current time.
421 PrerenderTabHelper* prerender_tab_helper = 423 PrerenderTabHelper* prerender_tab_helper =
422 new_tab_contents->prerender_tab_helper(); 424 new_tab_contents->prerender_tab_helper();
423 DCHECK(prerender_tab_helper != NULL); 425 DCHECK(prerender_tab_helper != NULL);
424 prerender_tab_helper->PrerenderSwappedIn(); 426 prerender_tab_helper->PrerenderSwappedIn();
425 427
426 if (old_tab_contents->web_contents()->NeedToFireBeforeUnload()) { 428 if (old_web_contents->NeedToFireBeforeUnload()) {
427 // Schedule the delete to occur after the tab has run its unload handlers. 429 // Schedule the delete to occur after the tab has run its unload handlers.
428 on_close_tab_contents_deleters_.push_back( 430 on_close_tab_contents_deleters_.push_back(
429 new OnCloseTabContentsDeleter(this, old_tab_contents)); 431 new OnCloseTabContentsDeleter(this, old_tab_contents));
430 old_tab_contents->web_contents()->GetRenderViewHost()-> 432 old_web_contents->GetRenderViewHost()->FirePageBeforeUnload(false);
431 FirePageBeforeUnload(false);
432 } else { 433 } else {
433 // No unload handler to run, so delete asap. 434 // No unload handler to run, so delete asap.
434 ScheduleDeleteOldTabContents(old_tab_contents, NULL); 435 ScheduleDeleteOldTabContents(old_tab_contents, NULL);
435 } 436 }
436 437
437 // TODO(cbentzel): Should prerender_contents move to the pending delete 438 // TODO(cbentzel): Should prerender_contents move to the pending delete
438 // list, instead of deleting directly here? 439 // list, instead of deleting directly here?
439 AddToHistory(prerender_contents.get()); 440 AddToHistory(prerender_contents.get());
440 RecordNavigation(url); 441 RecordNavigation(url);
441 return true; 442 return true;
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 if (!render_process_host || !render_process_host->GetBrowserContext()) 1290 if (!render_process_host || !render_process_host->GetBrowserContext())
1290 return NULL; 1291 return NULL;
1291 Profile* profile = Profile::FromBrowserContext( 1292 Profile* profile = Profile::FromBrowserContext(
1292 render_process_host->GetBrowserContext()); 1293 render_process_host->GetBrowserContext());
1293 if (!profile) 1294 if (!profile)
1294 return NULL; 1295 return NULL;
1295 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); 1296 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile);
1296 } 1297 }
1297 1298
1298 } // namespace prerender 1299 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698