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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 has_stopped_loading_(false), | 233 has_stopped_loading_(false), |
234 has_finished_loading_(false), | 234 has_finished_loading_(false), |
235 final_status_(FINAL_STATUS_MAX), | 235 final_status_(FINAL_STATUS_MAX), |
236 match_complete_status_(MATCH_COMPLETE_DEFAULT), | 236 match_complete_status_(MATCH_COMPLETE_DEFAULT), |
237 prerendering_has_been_cancelled_(false), | 237 prerendering_has_been_cancelled_(false), |
238 child_id_(-1), | 238 child_id_(-1), |
239 route_id_(-1), | 239 route_id_(-1), |
240 origin_(origin), | 240 origin_(origin), |
241 experiment_id_(experiment_id), | 241 experiment_id_(experiment_id), |
242 creator_child_id_(-1), | 242 creator_child_id_(-1), |
243 main_frame_id_(0), | |
244 cookie_status_(0), | 243 cookie_status_(0), |
245 cookie_send_type_(COOKIE_SEND_TYPE_NONE), | 244 cookie_send_type_(COOKIE_SEND_TYPE_NONE), |
246 network_bytes_(0) { | 245 network_bytes_(0) { |
247 DCHECK(prerender_manager != NULL); | 246 DCHECK(prerender_manager != NULL); |
248 } | 247 } |
249 | 248 |
250 PrerenderContents* PrerenderContents::CreateMatchCompleteReplacement() { | 249 PrerenderContents* PrerenderContents::CreateMatchCompleteReplacement() { |
251 PrerenderContents* new_contents = prerender_manager_->CreatePrerenderContents( | 250 PrerenderContents* new_contents = prerender_manager_->CreatePrerenderContents( |
252 prerender_url(), referrer(), origin(), experiment_id()); | 251 prerender_url(), referrer(), origin(), experiment_id()); |
253 | 252 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 render_frame_host->GetRoutingID(), true)); | 612 render_frame_host->GetRoutingID(), true)); |
614 } | 613 } |
615 | 614 |
616 void PrerenderContents::DidStopLoading( | 615 void PrerenderContents::DidStopLoading( |
617 content::RenderViewHost* render_view_host) { | 616 content::RenderViewHost* render_view_host) { |
618 has_stopped_loading_ = true; | 617 has_stopped_loading_ = true; |
619 NotifyPrerenderStopLoading(); | 618 NotifyPrerenderStopLoading(); |
620 } | 619 } |
621 | 620 |
622 void PrerenderContents::DocumentLoadedInFrame( | 621 void PrerenderContents::DocumentLoadedInFrame( |
623 int64 frame_id, | 622 content::RenderFrameHost* render_frame_host) { |
624 RenderViewHost* render_view_host) { | 623 if (!render_frame_host->GetParent()) |
625 if (frame_id == main_frame_id_) | |
626 NotifyPrerenderDomContentLoaded(); | 624 NotifyPrerenderDomContentLoaded(); |
627 } | 625 } |
628 | 626 |
629 void PrerenderContents::DidStartProvisionalLoadForFrame( | 627 void PrerenderContents::DidStartProvisionalLoadForFrame( |
630 content::RenderFrameHost* render_frame_host, | 628 content::RenderFrameHost* render_frame_host, |
631 const GURL& validated_url, | 629 const GURL& validated_url, |
632 bool is_error_page, | 630 bool is_error_page, |
633 bool is_iframe_srcdoc) { | 631 bool is_iframe_srcdoc) { |
634 if (!render_frame_host->GetParent()) { | 632 if (!render_frame_host->GetParent()) { |
635 if (!CheckURL(validated_url)) | 633 if (!CheckURL(validated_url)) |
636 return; | 634 return; |
637 | 635 |
638 // Usually, this event fires if the user clicks or enters a new URL. | 636 // Usually, this event fires if the user clicks or enters a new URL. |
639 // Neither of these can happen in the case of an invisible prerender. | 637 // Neither of these can happen in the case of an invisible prerender. |
640 // So the cause is: Some JavaScript caused a new URL to be loaded. In that | 638 // So the cause is: Some JavaScript caused a new URL to be loaded. In that |
641 // case, the spinner would start again in the browser, so we must reset | 639 // case, the spinner would start again in the browser, so we must reset |
642 // has_stopped_loading_ so that the spinner won't be stopped. | 640 // has_stopped_loading_ so that the spinner won't be stopped. |
643 has_stopped_loading_ = false; | 641 has_stopped_loading_ = false; |
644 has_finished_loading_ = false; | 642 has_finished_loading_ = false; |
645 } | 643 } |
646 } | 644 } |
647 | 645 |
648 void PrerenderContents::DidCommitProvisionalLoadForFrame( | 646 void PrerenderContents::DidFinishLoad( |
649 content::RenderFrameHost* render_frame_host, | 647 content::RenderFrameHost* render_frame_host, |
650 const GURL& url, | 648 const GURL& validated_url) { |
651 content::PageTransition transition_type) { | 649 if (!render_frame_host->GetParent()) |
652 if (!render_frame_host->GetParent()) { | |
653 main_frame_id_ = render_frame_host->GetRoutingID(); | |
654 } | |
655 } | |
656 | |
657 void PrerenderContents::DidFinishLoad(int64 frame_id, | |
658 const GURL& validated_url, | |
659 bool is_main_frame, | |
660 RenderViewHost* render_view_host) { | |
661 if (is_main_frame) | |
662 has_finished_loading_ = true; | 650 has_finished_loading_ = true; |
663 } | 651 } |
664 | 652 |
665 void PrerenderContents::DidNavigateMainFrame( | 653 void PrerenderContents::DidNavigateMainFrame( |
666 const content::LoadCommittedDetails& details, | 654 const content::LoadCommittedDetails& details, |
667 const content::FrameNavigateParams& params) { | 655 const content::FrameNavigateParams& params) { |
668 // If the prerender made a second navigation entry, abort the prerender. This | 656 // If the prerender made a second navigation entry, abort the prerender. This |
669 // avoids having to correctly implement a complex history merging case (this | 657 // avoids having to correctly implement a complex history merging case (this |
670 // interacts with location.replace) and correctly synchronize with the | 658 // interacts with location.replace) and correctly synchronize with the |
671 // renderer. The final status may be monitored to see we need to revisit this | 659 // renderer. The final status may be monitored to see we need to revisit this |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 void PrerenderContents::AddResourceThrottle( | 886 void PrerenderContents::AddResourceThrottle( |
899 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { | 887 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { |
900 resource_throttles_.push_back(throttle); | 888 resource_throttles_.push_back(throttle); |
901 } | 889 } |
902 | 890 |
903 void PrerenderContents::AddNetworkBytes(int64 bytes) { | 891 void PrerenderContents::AddNetworkBytes(int64 bytes) { |
904 network_bytes_ += bytes; | 892 network_bytes_ += bytes; |
905 } | 893 } |
906 | 894 |
907 } // namespace prerender | 895 } // namespace prerender |
OLD | NEW |