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