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

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

Issue 15041004: Replace PruneAllButActive with PruneAllButVisible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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 #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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 if (!prerender_data) 420 if (!prerender_data)
421 return false; 421 return false;
422 DCHECK(prerender_data->contents()); 422 DCHECK(prerender_data->contents());
423 if (IsNoSwapInExperiment(prerender_data->contents()->experiment_id())) 423 if (IsNoSwapInExperiment(prerender_data->contents()->experiment_id()))
424 return false; 424 return false;
425 425
426 if (WebContents* new_web_contents = 426 if (WebContents* new_web_contents =
427 prerender_data->contents()->prerender_contents()) { 427 prerender_data->contents()->prerender_contents()) {
428 if (web_contents == new_web_contents) 428 if (web_contents == new_web_contents)
429 return false; // Do not swap in to ourself. 429 return false; // Do not swap in to ourself.
430
431 // We cannot swap in if there is no last committed entry, because we would
432 // show a blank page under an existing entry from the current tab. Even if
433 // there is a pending entry, it may not commit.
434 // TODO(creis): If there is a pending navigation and no last committed
435 // entry, we might be able to transfer the network request instead.
436 if (!new_web_contents->GetController().CanPruneAllButVisible())
437 return false;
430 } 438 }
431 439
432 // Do not use the prerendered version if there is an opener object. 440 // Do not use the prerendered version if there is an opener object.
433 if (web_contents->HasOpener()) { 441 if (web_contents->HasOpener()) {
434 prerender_data->contents()->Destroy(FINAL_STATUS_WINDOW_OPENER); 442 prerender_data->contents()->Destroy(FINAL_STATUS_WINDOW_OPENER);
435 return false; 443 return false;
436 } 444 }
437 445
438 // If we are just in the control group (which can be detected by noticing 446 // If we are just in the control group (which can be detected by noticing
439 // that prerendering hasn't even started yet), record that |web_contents| now 447 // that prerendering hasn't even started yet), record that |web_contents| now
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 521
514 WebContents* new_web_contents = 522 WebContents* new_web_contents =
515 prerender_contents->ReleasePrerenderContents(); 523 prerender_contents->ReleasePrerenderContents();
516 WebContents* old_web_contents = web_contents; 524 WebContents* old_web_contents = web_contents;
517 DCHECK(new_web_contents); 525 DCHECK(new_web_contents);
518 DCHECK(old_web_contents); 526 DCHECK(old_web_contents);
519 527
520 MarkWebContentsAsPrerendered(new_web_contents, prerender_contents->origin()); 528 MarkWebContentsAsPrerendered(new_web_contents, prerender_contents->origin());
521 529
522 // Merge the browsing history. 530 // Merge the browsing history.
523 new_web_contents->GetController().CopyStateFromAndPrune( 531 CHECK(new_web_contents->GetController().CopyStateFromAndPrune(
524 &old_web_contents->GetController()); 532 &old_web_contents->GetController()));
525 CoreTabHelper::FromWebContents(old_web_contents)->delegate()-> 533 CoreTabHelper::FromWebContents(old_web_contents)->delegate()->
526 SwapTabContents(old_web_contents, new_web_contents); 534 SwapTabContents(old_web_contents, new_web_contents);
527 prerender_contents->CommitHistory(new_web_contents); 535 prerender_contents->CommitHistory(new_web_contents);
528 536
529 GURL icon_url = prerender_contents->icon_url(); 537 GURL icon_url = prerender_contents->icon_url();
530 538
531 if (!icon_url.is_empty()) { 539 if (!icon_url.is_empty()) {
532 #if defined(OS_ANDROID) 540 #if defined(OS_ANDROID)
533 // Do the delayed icon fetch since we didn't download 541 // Do the delayed icon fetch since we didn't download
534 // the favicon during prerendering on mobile devices. 542 // the favicon during prerendering on mobile devices.
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 logged_in_state_->erase(domain_key); 1545 logged_in_state_->erase(domain_key);
1538 } 1546 }
1539 1547
1540 void PrerenderManager::LoggedInPredictorDataReceived( 1548 void PrerenderManager::LoggedInPredictorDataReceived(
1541 scoped_ptr<LoggedInStateMap> new_map) { 1549 scoped_ptr<LoggedInStateMap> new_map) {
1542 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1550 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1543 logged_in_state_.swap(new_map); 1551 logged_in_state_.swap(new_map);
1544 } 1552 }
1545 1553
1546 } // namespace prerender 1554 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698