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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 has_stopped_loading_(false), | 205 has_stopped_loading_(false), |
206 has_finished_loading_(false), | 206 has_finished_loading_(false), |
207 final_status_(FINAL_STATUS_MAX), | 207 final_status_(FINAL_STATUS_MAX), |
208 match_complete_status_(MATCH_COMPLETE_DEFAULT), | 208 match_complete_status_(MATCH_COMPLETE_DEFAULT), |
209 prerendering_has_been_cancelled_(false), | 209 prerendering_has_been_cancelled_(false), |
210 child_id_(-1), | 210 child_id_(-1), |
211 route_id_(-1), | 211 route_id_(-1), |
212 origin_(origin), | 212 origin_(origin), |
213 experiment_id_(experiment_id), | 213 experiment_id_(experiment_id), |
214 creator_child_id_(-1) { | 214 creator_child_id_(-1) { |
215 DCHECK(prerender_manager != NULL); | 215 DCHECK_NE(static_cast<PrerenderManager*>(NULL), prerender_manager); |
216 } | 216 } |
217 | 217 |
218 PrerenderContents* PrerenderContents::CreateMatchCompleteReplacement() { | 218 PrerenderContents* PrerenderContents::CreateMatchCompleteReplacement() { |
219 PrerenderContents* new_contents = prerender_manager_->CreatePrerenderContents( | 219 PrerenderContents* new_contents = prerender_manager_->CreatePrerenderContents( |
220 prerender_url(), referrer(), origin(), experiment_id()); | 220 prerender_url(), referrer(), origin(), experiment_id()); |
221 | 221 |
222 new_contents->load_start_time_ = load_start_time_; | 222 new_contents->load_start_time_ = load_start_time_; |
223 new_contents->session_storage_namespace_id_ = session_storage_namespace_id_; | 223 new_contents->session_storage_namespace_id_ = session_storage_namespace_id_; |
224 new_contents->set_match_complete_status( | 224 new_contents->set_match_complete_status( |
225 PrerenderContents::MATCH_COMPLETE_REPLACEMENT_PENDING); | 225 PrerenderContents::MATCH_COMPLETE_REPLACEMENT_PENDING); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 GetFinalStatus(child_id_, route_id_, &final_status)) { | 592 GetFinalStatus(child_id_, route_id_, &final_status)) { |
593 NOTREACHED(); | 593 NOTREACHED(); |
594 } | 594 } |
595 } | 595 } |
596 SetFinalStatus(final_status); | 596 SetFinalStatus(final_status); |
597 | 597 |
598 prerendering_has_been_cancelled_ = true; | 598 prerendering_has_been_cancelled_ = true; |
599 prerender_manager_->AddToHistory(this); | 599 prerender_manager_->AddToHistory(this); |
600 prerender_manager_->MoveEntryToPendingDelete(this, final_status); | 600 prerender_manager_->MoveEntryToPendingDelete(this, final_status); |
601 | 601 |
602 // We may destroy the PrerenderContents before we have initialized the | |
603 // RenderViewHost. Otherwise set the Observer's PrerenderContents to NULL to | |
604 // avoid any more messages being sent. | |
605 if (render_view_host_observer_) | |
606 render_view_host_observer_->set_prerender_contents(NULL); | |
mmenke
2012/12/17 20:02:23
Why does this need to be moved?
gavinp
2012/12/18 00:44:14
It doesn't. I just moved it while I was debugging
| |
607 | |
602 if (!prerender_manager_->IsControlGroup(experiment_id()) && | 608 if (!prerender_manager_->IsControlGroup(experiment_id()) && |
603 (prerendering_has_started() || | 609 (prerendering_has_started() || |
604 match_complete_status() == MATCH_COMPLETE_REPLACEMENT)) { | 610 match_complete_status() == MATCH_COMPLETE_REPLACEMENT)) { |
605 NotifyPrerenderStop(); | 611 NotifyPrerenderStop(); |
606 } | 612 } |
607 | |
608 // We may destroy the PrerenderContents before we have initialized the | |
609 // RenderViewHost. Otherwise set the Observer's PrerenderContents to NULL to | |
610 // avoid any more messages being sent. | |
611 if (render_view_host_observer_) | |
612 render_view_host_observer_->set_prerender_contents(NULL); | |
613 } | 613 } |
614 | 614 |
615 base::ProcessMetrics* PrerenderContents::MaybeGetProcessMetrics() { | 615 base::ProcessMetrics* PrerenderContents::MaybeGetProcessMetrics() { |
616 if (process_metrics_.get() == NULL) { | 616 if (process_metrics_.get() == NULL) { |
617 // If a PrenderContents hasn't started prerending, don't be fully formed. | 617 // If a PrenderContents hasn't started prerending, don't be fully formed. |
618 if (!GetRenderViewHost() || !GetRenderViewHost()->GetProcess()) | 618 if (!GetRenderViewHost() || !GetRenderViewHost()->GetProcess()) |
619 return NULL; | 619 return NULL; |
620 base::ProcessHandle handle = GetRenderViewHost()->GetProcess()->GetHandle(); | 620 base::ProcessHandle handle = GetRenderViewHost()->GetProcess()->GetHandle(); |
621 if (handle == base::kNullProcessHandle) | 621 if (handle == base::kNullProcessHandle) |
622 return NULL; | 622 return NULL; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 | 685 |
686 bool PrerenderContents::IsCrossSiteNavigationPending() const { | 686 bool PrerenderContents::IsCrossSiteNavigationPending() const { |
687 if (!prerender_contents_) | 687 if (!prerender_contents_) |
688 return false; | 688 return false; |
689 return (prerender_contents_->GetSiteInstance() != | 689 return (prerender_contents_->GetSiteInstance() != |
690 prerender_contents_->GetPendingSiteInstance()); | 690 prerender_contents_->GetPendingSiteInstance()); |
691 } | 691 } |
692 | 692 |
693 | 693 |
694 } // namespace prerender | 694 } // namespace prerender |
OLD | NEW |