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 <functional> | 8 #include <functional> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 134 } |
135 | 135 |
136 private: | 136 private: |
137 PrerenderContents* prerender_contents_; | 137 PrerenderContents* prerender_contents_; |
138 }; | 138 }; |
139 | 139 |
140 void PrerenderContents::Observer::OnPrerenderStopLoading( | 140 void PrerenderContents::Observer::OnPrerenderStopLoading( |
141 PrerenderContents* contents) { | 141 PrerenderContents* contents) { |
142 } | 142 } |
143 | 143 |
144 void PrerenderContents::Observer::OnPrerenderAddAlias( | |
145 PrerenderContents* contents, | |
146 const GURL& alias_url) { | |
147 } | |
148 | |
149 void PrerenderContents::Observer::OnPrerenderCreatedMatchCompleteReplacement( | 144 void PrerenderContents::Observer::OnPrerenderCreatedMatchCompleteReplacement( |
150 PrerenderContents* contents, PrerenderContents* replacement) { | 145 PrerenderContents* contents, PrerenderContents* replacement) { |
151 } | 146 } |
152 | 147 |
153 PrerenderContents::Observer::Observer() { | 148 PrerenderContents::Observer::Observer() { |
154 } | 149 } |
155 | 150 |
156 PrerenderContents::Observer::~Observer() { | 151 PrerenderContents::Observer::~Observer() { |
157 } | 152 } |
158 | 153 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 358 |
364 PrerenderContents::~PrerenderContents() { | 359 PrerenderContents::~PrerenderContents() { |
365 DCHECK_NE(FINAL_STATUS_MAX, final_status()); | 360 DCHECK_NE(FINAL_STATUS_MAX, final_status()); |
366 DCHECK( | 361 DCHECK( |
367 prerendering_has_been_cancelled() || final_status() == FINAL_STATUS_USED); | 362 prerendering_has_been_cancelled() || final_status() == FINAL_STATUS_USED); |
368 DCHECK_NE(ORIGIN_MAX, origin()); | 363 DCHECK_NE(ORIGIN_MAX, origin()); |
369 | 364 |
370 prerender_manager_->RecordFinalStatusWithMatchCompleteStatus( | 365 prerender_manager_->RecordFinalStatusWithMatchCompleteStatus( |
371 origin(), experiment_id(), match_complete_status(), final_status()); | 366 origin(), experiment_id(), match_complete_status(), final_status()); |
372 | 367 |
| 368 // Broadcast the removal of aliases. |
| 369 for (content::RenderProcessHost::iterator host_iterator = |
| 370 content::RenderProcessHost::AllHostsIterator(); |
| 371 !host_iterator.IsAtEnd(); |
| 372 host_iterator.Advance()) { |
| 373 content::RenderProcessHost* host = host_iterator.GetCurrentValue(); |
| 374 host->Send(new PrerenderMsg_OnPrerenderRemoveAliases(alias_urls_)); |
| 375 } |
| 376 |
373 // If we still have a WebContents, clean up anything we need to and then | 377 // If we still have a WebContents, clean up anything we need to and then |
374 // destroy it. | 378 // destroy it. |
375 if (prerender_contents_.get()) | 379 if (prerender_contents_.get()) |
376 delete ReleasePrerenderContents(); | 380 delete ReleasePrerenderContents(); |
377 } | 381 } |
378 | 382 |
379 void PrerenderContents::AddObserver(Observer* observer) { | 383 void PrerenderContents::AddObserver(Observer* observer) { |
380 DCHECK_EQ(FINAL_STATUS_MAX, final_status_); | 384 DCHECK_EQ(FINAL_STATUS_MAX, final_status_); |
381 observer_list_.AddObserver(observer); | 385 observer_list_.AddObserver(observer); |
382 } | 386 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 void PrerenderContents::NotifyPrerenderStopLoading() { | 482 void PrerenderContents::NotifyPrerenderStopLoading() { |
479 FOR_EACH_OBSERVER(Observer, observer_list_, OnPrerenderStopLoading(this)); | 483 FOR_EACH_OBSERVER(Observer, observer_list_, OnPrerenderStopLoading(this)); |
480 } | 484 } |
481 | 485 |
482 void PrerenderContents::NotifyPrerenderStop() { | 486 void PrerenderContents::NotifyPrerenderStop() { |
483 DCHECK_NE(FINAL_STATUS_MAX, final_status_); | 487 DCHECK_NE(FINAL_STATUS_MAX, final_status_); |
484 FOR_EACH_OBSERVER(Observer, observer_list_, OnPrerenderStop(this)); | 488 FOR_EACH_OBSERVER(Observer, observer_list_, OnPrerenderStop(this)); |
485 observer_list_.Clear(); | 489 observer_list_.Clear(); |
486 } | 490 } |
487 | 491 |
488 void PrerenderContents::NotifyPrerenderAddAlias(const GURL& alias_url) { | |
489 FOR_EACH_OBSERVER(Observer, observer_list_, OnPrerenderAddAlias(this, | |
490 alias_url)); | |
491 } | |
492 | |
493 void PrerenderContents::NotifyPrerenderCreatedMatchCompleteReplacement( | 492 void PrerenderContents::NotifyPrerenderCreatedMatchCompleteReplacement( |
494 PrerenderContents* replacement) { | 493 PrerenderContents* replacement) { |
495 FOR_EACH_OBSERVER(Observer, observer_list_, | 494 FOR_EACH_OBSERVER(Observer, observer_list_, |
496 OnPrerenderCreatedMatchCompleteReplacement(this, | 495 OnPrerenderCreatedMatchCompleteReplacement(this, |
497 replacement)); | 496 replacement)); |
498 } | 497 } |
499 | 498 |
500 void PrerenderContents::DidUpdateFaviconURL( | 499 void PrerenderContents::DidUpdateFaviconURL( |
501 int32 page_id, | 500 int32 page_id, |
502 const std::vector<content::FaviconURL>& urls) { | 501 const std::vector<content::FaviconURL>& urls) { |
(...skipping 21 matching lines...) Expand all Loading... |
524 Destroy(FINAL_STATUS_HTTPS); | 523 Destroy(FINAL_STATUS_HTTPS); |
525 return false; | 524 return false; |
526 } | 525 } |
527 if (match_complete_status_ != MATCH_COMPLETE_REPLACEMENT_PENDING && | 526 if (match_complete_status_ != MATCH_COMPLETE_REPLACEMENT_PENDING && |
528 prerender_manager_->HasRecentlyBeenNavigatedTo(origin(), url)) { | 527 prerender_manager_->HasRecentlyBeenNavigatedTo(origin(), url)) { |
529 Destroy(FINAL_STATUS_RECENTLY_VISITED); | 528 Destroy(FINAL_STATUS_RECENTLY_VISITED); |
530 return false; | 529 return false; |
531 } | 530 } |
532 | 531 |
533 alias_urls_.push_back(url); | 532 alias_urls_.push_back(url); |
534 NotifyPrerenderAddAlias(url); | 533 |
| 534 for (content::RenderProcessHost::iterator host_iterator = |
| 535 content::RenderProcessHost::AllHostsIterator(); |
| 536 !host_iterator.IsAtEnd(); |
| 537 host_iterator.Advance()) { |
| 538 content::RenderProcessHost* host = host_iterator.GetCurrentValue(); |
| 539 host->Send(new PrerenderMsg_OnPrerenderAddAlias(url)); |
| 540 } |
| 541 |
535 return true; | 542 return true; |
536 } | 543 } |
537 | 544 |
538 bool PrerenderContents::Matches( | 545 bool PrerenderContents::Matches( |
539 const GURL& url, | 546 const GURL& url, |
540 const SessionStorageNamespace* session_storage_namespace) const { | 547 const SessionStorageNamespace* session_storage_namespace) const { |
541 DCHECK(child_id_ == -1 || session_storage_namespace); | 548 DCHECK(child_id_ == -1 || session_storage_namespace); |
542 if (session_storage_namespace && | 549 if (session_storage_namespace && |
543 session_storage_namespace_id_ != session_storage_namespace->id()) { | 550 session_storage_namespace_id_ != session_storage_namespace->id()) { |
544 return false; | 551 return false; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 708 |
702 bool PrerenderContents::IsCrossSiteNavigationPending() const { | 709 bool PrerenderContents::IsCrossSiteNavigationPending() const { |
703 if (!prerender_contents_) | 710 if (!prerender_contents_) |
704 return false; | 711 return false; |
705 return (prerender_contents_->GetSiteInstance() != | 712 return (prerender_contents_->GetSiteInstance() != |
706 prerender_contents_->GetPendingSiteInstance()); | 713 prerender_contents_->GetPendingSiteInstance()); |
707 } | 714 } |
708 | 715 |
709 | 716 |
710 } // namespace prerender | 717 } // namespace prerender |
OLD | NEW |