OLD | NEW |
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_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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 it != alias_urls_.end(); | 408 it != alias_urls_.end(); |
409 ++it) { | 409 ++it) { |
410 InformRenderProcessAboutPrerender(*it, false, creator_child_id_); | 410 InformRenderProcessAboutPrerender(*it, false, creator_child_id_); |
411 } | 411 } |
412 } | 412 } |
413 | 413 |
414 // If we still have a TabContents, clean up anything we need to and then | 414 // If we still have a TabContents, clean up anything we need to and then |
415 // destroy it. | 415 // destroy it. |
416 if (prerender_contents_.get()) | 416 if (prerender_contents_.get()) |
417 delete ReleasePrerenderContents(); | 417 delete ReleasePrerenderContents(); |
418 | |
419 // The following URLs are no longer rendering. | |
420 prerender_tracker_->RemovePrerenderURLsOnUIThread(alias_urls_); | |
421 } | 418 } |
422 | 419 |
423 void PrerenderContents::Observe(int type, | 420 void PrerenderContents::Observe(int type, |
424 const content::NotificationSource& source, | 421 const content::NotificationSource& source, |
425 const content::NotificationDetails& details) { | 422 const content::NotificationDetails& details) { |
426 switch (type) { | 423 switch (type) { |
427 case chrome::NOTIFICATION_PROFILE_DESTROYED: | 424 case chrome::NOTIFICATION_PROFILE_DESTROYED: |
428 Destroy(FINAL_STATUS_PROFILE_DESTROYED); | 425 Destroy(FINAL_STATUS_PROFILE_DESTROYED); |
429 return; | 426 return; |
430 | 427 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 Destroy(FINAL_STATUS_HTTPS); | 512 Destroy(FINAL_STATUS_HTTPS); |
516 return false; | 513 return false; |
517 } | 514 } |
518 if (prerender_manager_->HasRecentlyBeenNavigatedTo(url)) { | 515 if (prerender_manager_->HasRecentlyBeenNavigatedTo(url)) { |
519 Destroy(FINAL_STATUS_RECENTLY_VISITED); | 516 Destroy(FINAL_STATUS_RECENTLY_VISITED); |
520 return false; | 517 return false; |
521 } | 518 } |
522 | 519 |
523 alias_urls_.push_back(url); | 520 alias_urls_.push_back(url); |
524 InformRenderProcessAboutPrerender(url, true, creator_child_id_); | 521 InformRenderProcessAboutPrerender(url, true, creator_child_id_); |
525 prerender_tracker_->AddPrerenderURLOnUIThread(url); | |
526 return true; | 522 return true; |
527 } | 523 } |
528 | 524 |
529 void PrerenderContents::AddAliasURLsFromOtherPrerenderContents( | 525 void PrerenderContents::AddAliasURLsFromOtherPrerenderContents( |
530 PrerenderContents* other_pc) { | 526 PrerenderContents* other_pc) { |
531 for (std::vector<GURL>::const_iterator it = other_pc->alias_urls_.begin(); | 527 for (std::vector<GURL>::const_iterator it = other_pc->alias_urls_.begin(); |
532 it != other_pc->alias_urls_.end(); | 528 it != other_pc->alias_urls_.end(); |
533 ++it) { | 529 ++it) { |
534 alias_urls_.push_back(*it); | 530 alias_urls_.push_back(*it); |
535 prerender_tracker_->AddPrerenderURLOnUIThread(*it); | |
536 } | 531 } |
537 } | 532 } |
538 | 533 |
539 bool PrerenderContents::MatchesURL(const GURL& url, GURL* matching_url) const { | 534 bool PrerenderContents::MatchesURL(const GURL& url, GURL* matching_url) const { |
540 std::vector<GURL>::const_iterator matching_url_iterator = | 535 std::vector<GURL>::const_iterator matching_url_iterator = |
541 std::find_if(alias_urls_.begin(), | 536 std::find_if(alias_urls_.begin(), |
542 alias_urls_.end(), | 537 alias_urls_.end(), |
543 PrerenderURLPredicate(url)); | 538 PrerenderURLPredicate(url)); |
544 if (matching_url_iterator != alias_urls_.end()) { | 539 if (matching_url_iterator != alias_urls_.end()) { |
545 if (matching_url) | 540 if (matching_url) |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 bool PrerenderContents::IsCrossSiteNavigationPending() const { | 700 bool PrerenderContents::IsCrossSiteNavigationPending() const { |
706 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) | 701 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) |
707 return false; | 702 return false; |
708 const WebContents* web_contents = prerender_contents_->web_contents(); | 703 const WebContents* web_contents = prerender_contents_->web_contents(); |
709 return (web_contents->GetSiteInstance() != | 704 return (web_contents->GetSiteInstance() != |
710 web_contents->GetPendingSiteInstance()); | 705 web_contents->GetPendingSiteInstance()); |
711 } | 706 } |
712 | 707 |
713 | 708 |
714 } // namespace prerender | 709 } // namespace prerender |
OLD | NEW |