Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 1199313006: Disable support for swapped out RenderFrame(Host) on desktop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 unload_ack_is_for_navigation_(false), 160 unload_ack_is_for_navigation_(false),
161 is_loading_(false), 161 is_loading_(false),
162 pending_commit_(false), 162 pending_commit_(false),
163 accessibility_reset_token_(0), 163 accessibility_reset_token_(0),
164 accessibility_reset_count_(0), 164 accessibility_reset_count_(0),
165 no_create_browser_accessibility_manager_for_testing_(false), 165 no_create_browser_accessibility_manager_for_testing_(false),
166 weak_ptr_factory_(this) { 166 weak_ptr_factory_(this) {
167 bool is_swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); 167 bool is_swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT);
168 bool hidden = !!(flags & CREATE_RF_HIDDEN); 168 bool hidden = !!(flags & CREATE_RF_HIDDEN);
169 frame_tree_->AddRenderViewHostRef(render_view_host_); 169 frame_tree_->AddRenderViewHostRef(render_view_host_);
170
171 LOG(ERROR) << "RFH[" << this << "]::RFH: "
172 << " routing_id:" << routing_id
173 << " swapped:" << is_swapped_out
174 << " hidden:" << hidden
175 << " site:" << site_instance_->GetSiteURL();
176
170 GetProcess()->AddRoute(routing_id_, this); 177 GetProcess()->AddRoute(routing_id_, this);
171 g_routing_id_frame_map.Get().insert(std::make_pair( 178 g_routing_id_frame_map.Get().insert(std::make_pair(
172 RenderFrameHostID(GetProcess()->GetID(), routing_id_), 179 RenderFrameHostID(GetProcess()->GetID(), routing_id_),
173 this)); 180 this));
174 181
175 if (is_swapped_out) { 182 if (is_swapped_out) {
176 rfh_state_ = STATE_SWAPPED_OUT; 183 rfh_state_ = STATE_SWAPPED_OUT;
177 } else { 184 } else {
178 rfh_state_ = STATE_DEFAULT; 185 rfh_state_ = STATE_DEFAULT;
179 GetSiteInstance()->increment_active_frame_count(); 186 GetSiteInstance()->increment_active_frame_count();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 swapout_event_monitor_timeout_.reset(); 221 swapout_event_monitor_timeout_.reset();
215 222
216 for (const auto& iter: visual_state_callbacks_) { 223 for (const auto& iter: visual_state_callbacks_) {
217 iter.second.Run(false); 224 iter.second.Run(false);
218 } 225 }
219 226
220 if (render_widget_host_) { 227 if (render_widget_host_) {
221 // Shutdown causes the RenderWidgetHost to delete itself. 228 // Shutdown causes the RenderWidgetHost to delete itself.
222 render_widget_host_->Shutdown(); 229 render_widget_host_->Shutdown();
223 } 230 }
231 LOG(ERROR) << "RFH[" << this << "]::~RFH";
224 } 232 }
225 233
226 int RenderFrameHostImpl::GetRoutingID() { 234 int RenderFrameHostImpl::GetRoutingID() {
227 return routing_id_; 235 return routing_id_;
228 } 236 }
229 237
230 SiteInstanceImpl* RenderFrameHostImpl::GetSiteInstance() { 238 SiteInstanceImpl* RenderFrameHostImpl::GetSiteInstance() {
231 return site_instance_.get(); 239 return site_instance_.get();
232 } 240 }
233 241
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 603
596 return manager->GetFromID(parent_node_id); 604 return manager->GetFromID(parent_node_id);
597 } 605 }
598 606
599 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id, 607 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id,
600 int previous_sibling_routing_id, 608 int previous_sibling_routing_id,
601 int proxy_routing_id) { 609 int proxy_routing_id) {
602 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); 610 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame");
603 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; 611 DCHECK(!IsRenderFrameLive()) << "Creating frame twice";
604 612
613 LOG(ERROR) << "RFH[" << this << "]::CreateRenderFrame:"
614 << " routing_id:" << routing_id_
615 << " parent:" << parent_routing_id
616 << " previous_sibling_routing_id:" << previous_sibling_routing_id
617 << " proxy:" << proxy_routing_id;
618
605 // The process may (if we're sharing a process with another host that already 619 // The process may (if we're sharing a process with another host that already
606 // initialized it) or may not (we have our own process or the old process 620 // initialized it) or may not (we have our own process or the old process
607 // crashed) have been initialized. Calling Init multiple times will be 621 // crashed) have been initialized. Calling Init multiple times will be
608 // ignored, so this is safe. 622 // ignored, so this is safe.
609 if (!GetProcess()->Init()) 623 if (!GetProcess()->Init())
610 return false; 624 return false;
611 625
612 DCHECK(GetProcess()->HasConnection()); 626 DCHECK(GetProcess()->HasConnection());
613 627
614 FrameMsg_NewFrame_Params params; 628 FrameMsg_NewFrame_Params params;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 // The renderer now has a RenderFrame for this RenderFrameHost. Note that 665 // The renderer now has a RenderFrame for this RenderFrameHost. Note that
652 // this path is only used for out-of-process iframes. Main frame RenderFrames 666 // this path is only used for out-of-process iframes. Main frame RenderFrames
653 // are created with their RenderView, and same-site iframes are created at the 667 // are created with their RenderView, and same-site iframes are created at the
654 // time of OnCreateChildFrame. 668 // time of OnCreateChildFrame.
655 SetRenderFrameCreated(true); 669 SetRenderFrameCreated(true);
656 670
657 return true; 671 return true;
658 } 672 }
659 673
660 void RenderFrameHostImpl::SetRenderFrameCreated(bool created) { 674 void RenderFrameHostImpl::SetRenderFrameCreated(bool created) {
675 LOG(ERROR) << "RFH[" << this << "]::SetRFCreated: "
676 << created;
661 bool was_created = render_frame_created_; 677 bool was_created = render_frame_created_;
662 render_frame_created_ = created; 678 render_frame_created_ = created;
663 679
664 // If the current status is different than the new status, the delegate 680 // If the current status is different than the new status, the delegate
665 // needs to be notified. 681 // needs to be notified.
666 if (delegate_ && (created != was_created)) { 682 if (delegate_ && (created != was_created)) {
667 if (created) 683 if (created)
668 delegate_->RenderFrameCreated(this); 684 delegate_->RenderFrameCreated(this);
669 else 685 else
670 delegate_->RenderFrameDeleted(this); 686 delegate_->RenderFrameDeleted(this);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 base::TimeTicks::Now() - ui_timestamp, 768 base::TimeTicks::Now() - ui_timestamp,
753 base::TimeDelta::FromMilliseconds(10), 769 base::TimeDelta::FromMilliseconds(10),
754 base::TimeDelta::FromMinutes(10), 100); 770 base::TimeDelta::FromMinutes(10), 100);
755 } 771 }
756 // This message is only sent for top-level frames. TODO(avi): when frame tree 772 // This message is only sent for top-level frames. TODO(avi): when frame tree
757 // mirroring works correctly, add a check here to enforce it. 773 // mirroring works correctly, add a check here to enforce it.
758 delegate_->DocumentOnLoadCompleted(this); 774 delegate_->DocumentOnLoadCompleted(this);
759 } 775 }
760 776
761 void RenderFrameHostImpl::OnDidStartProvisionalLoadForFrame(const GURL& url) { 777 void RenderFrameHostImpl::OnDidStartProvisionalLoadForFrame(const GURL& url) {
778 LOG(ERROR) << "RFH[" << this << "]::DidStartProvLoad:"
779 << " url:" << url;
762 frame_tree_node_->navigator()->DidStartProvisionalLoad( 780 frame_tree_node_->navigator()->DidStartProvisionalLoad(
763 this, url); 781 this, url);
764 } 782 }
765 783
766 void RenderFrameHostImpl::OnDidFailProvisionalLoadWithError( 784 void RenderFrameHostImpl::OnDidFailProvisionalLoadWithError(
767 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { 785 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {
768 frame_tree_node_->navigator()->DidFailProvisionalLoadWithError(this, params); 786 frame_tree_node_->navigator()->DidFailProvisionalLoadWithError(this, params);
769 } 787 }
770 788
771 void RenderFrameHostImpl::OnDidFailLoadWithError( 789 void RenderFrameHostImpl::OnDidFailLoadWithError(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 // navigating already and sent it before hearing the FrameMsg_Stop message. 830 // navigating already and sent it before hearing the FrameMsg_Stop message.
813 // Treat this as an implicit beforeunload ack to allow the pending navigation 831 // Treat this as an implicit beforeunload ack to allow the pending navigation
814 // to continue. 832 // to continue.
815 if (is_waiting_for_beforeunload_ack_ && 833 if (is_waiting_for_beforeunload_ack_ &&
816 unload_ack_is_for_navigation_ && 834 unload_ack_is_for_navigation_ &&
817 !GetParent()) { 835 !GetParent()) {
818 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; 836 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_;
819 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); 837 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now());
820 } 838 }
821 839
840 LOG(ERROR) << "RFH[" << this << "]::DidCommitProvLoad:"
841 << " url:" << validated_params.url;
842
822 // If we're waiting for an unload ack from this renderer and we receive a 843 // If we're waiting for an unload ack from this renderer and we receive a
823 // Navigate message, then the renderer was navigating before it received the 844 // Navigate message, then the renderer was navigating before it received the
824 // unload request. It will either respond to the unload request soon or our 845 // unload request. It will either respond to the unload request soon or our
825 // timer will expire. Either way, we should ignore this message, because we 846 // timer will expire. Either way, we should ignore this message, because we
826 // have already committed to closing this renderer. 847 // have already committed to closing this renderer.
827 if (IsWaitingForUnloadACK()) 848 if (IsWaitingForUnloadACK())
828 return; 849 return;
829 850
830 if (validated_params.report_type == 851 if (validated_params.report_type ==
831 FrameMsg_UILoadMetricsReportType::REPORT_LINK) { 852 FrameMsg_UILoadMetricsReportType::REPORT_LINK) {
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); 1480 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin());
1460 else 1481 else
1461 delegate_->ExitFullscreenMode(); 1482 delegate_->ExitFullscreenMode();
1462 1483
1463 // The previous call might change the fullscreen state. We need to make sure 1484 // The previous call might change the fullscreen state. We need to make sure
1464 // the renderer is aware of that, which is done via the resize message. 1485 // the renderer is aware of that, which is done via the resize message.
1465 render_view_host_->WasResized(); 1486 render_view_host_->WasResized();
1466 } 1487 }
1467 1488
1468 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { 1489 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) {
1490 LOG(ERROR) << "RFH[" << this << "]::OnDidStartLoading";
1469 // Any main frame load to a new document should reset the load since it will 1491 // Any main frame load to a new document should reset the load since it will
1470 // replace the current page and any frames. 1492 // replace the current page and any frames.
1471 if (to_different_document && !GetParent()) 1493 if (to_different_document && !GetParent())
1472 is_loading_ = false; 1494 is_loading_ = false;
1473 1495
1474 // This method should never be called when the frame is loading. 1496 // This method should never be called when the frame is loading.
1475 // Unfortunately, it can happen if a history navigation happens during a 1497 // Unfortunately, it can happen if a history navigation happens during a
1476 // BeforeUnload or Unload event. 1498 // BeforeUnload or Unload event.
1477 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been 1499 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been
1478 // refactored in Blink. See crbug.com/466089 1500 // refactored in Blink. See crbug.com/466089
1479 if (is_loading_) { 1501 if (is_loading_) {
1480 LOG(WARNING) << "OnDidStartLoading was called twice."; 1502 LOG(WARNING) << "OnDidStartLoading was called twice.";
1481 return; 1503 return;
1482 } 1504 }
1483 1505
1484 frame_tree_node_->DidStartLoading(to_different_document); 1506 frame_tree_node_->DidStartLoading(to_different_document);
1485 is_loading_ = true; 1507 is_loading_ = true;
1486 } 1508 }
1487 1509
1488 void RenderFrameHostImpl::OnDidStopLoading() { 1510 void RenderFrameHostImpl::OnDidStopLoading() {
1511 LOG(ERROR) << "RFH[" << this << "]::OnDidStopLoading";
1489 // This method should never be called when the frame is not loading. 1512 // This method should never be called when the frame is not loading.
1490 // Unfortunately, it can happen if a history navigation happens during a 1513 // Unfortunately, it can happen if a history navigation happens during a
1491 // BeforeUnload or Unload event. 1514 // BeforeUnload or Unload event.
1492 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been 1515 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been
1493 // refactored in Blink. See crbug.com/466089 1516 // refactored in Blink. See crbug.com/466089
1494 if (!is_loading_) { 1517 if (!is_loading_) {
1495 LOG(WARNING) << "OnDidStopLoading was called twice."; 1518 LOG(ERROR) << "!!!---!!! OnDidStopLoading was called twice.";
1496 return; 1519 return;
1497 } 1520 }
1498 1521
1499 is_loading_ = false; 1522 is_loading_ = false;
1500 frame_tree_node_->DidStopLoading(); 1523 frame_tree_node_->DidStopLoading();
1501 } 1524 }
1502 1525
1503 void RenderFrameHostImpl::OnDidChangeLoadProgress(double load_progress) { 1526 void RenderFrameHostImpl::OnDidChangeLoadProgress(double load_progress) {
1504 frame_tree_node_->DidChangeLoadProgress(load_progress); 1527 frame_tree_node_->DidChangeLoadProgress(load_progress);
1505 } 1528 }
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 1986
1964 void RenderFrameHostImpl::InsertVisualStateCallback( 1987 void RenderFrameHostImpl::InsertVisualStateCallback(
1965 const VisualStateCallback& callback) { 1988 const VisualStateCallback& callback) {
1966 static uint64 next_id = 1; 1989 static uint64 next_id = 1;
1967 uint64 key = next_id++; 1990 uint64 key = next_id++;
1968 Send(new FrameMsg_VisualStateRequest(routing_id_, key)); 1991 Send(new FrameMsg_VisualStateRequest(routing_id_, key));
1969 visual_state_callbacks_.insert(std::make_pair(key, callback)); 1992 visual_state_callbacks_.insert(std::make_pair(key, callback));
1970 } 1993 }
1971 1994
1972 bool RenderFrameHostImpl::IsRenderFrameLive() { 1995 bool RenderFrameHostImpl::IsRenderFrameLive() {
1996 LOG(ERROR) << "RFH[" << this << "]::IsRenderFrameLive:"
1997 << " render_frame_created_:" << render_frame_created_
1998 << " process has connection:" << GetProcess()->HasConnection();
1973 bool is_live = GetProcess()->HasConnection() && render_frame_created_; 1999 bool is_live = GetProcess()->HasConnection() && render_frame_created_;
1974 2000
1975 // Sanity check: the RenderView should always be live if the RenderFrame is. 2001 // Sanity check: the RenderView should always be live if the RenderFrame is.
1976 DCHECK_IMPLIES(is_live, render_view_host_->IsRenderViewLive()); 2002 DCHECK_IMPLIES(is_live, render_view_host_->IsRenderViewLive());
1977 2003
1978 return is_live; 2004 return is_live;
1979 } 2005 }
1980 2006
1981 #if defined(OS_WIN) 2007 #if defined(OS_WIN)
1982 2008
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 // We may be returning to an existing NavigationEntry that had been granted 2118 // We may be returning to an existing NavigationEntry that had been granted
2093 // file access. If this is a different process, we will need to grant the 2119 // file access. If this is a different process, we will need to grant the
2094 // access again. The files listed in the page state are validated when they 2120 // access again. The files listed in the page state are validated when they
2095 // are received from the renderer to prevent abuse. 2121 // are received from the renderer to prevent abuse.
2096 if (request_params.page_state.IsValid()) { 2122 if (request_params.page_state.IsValid()) {
2097 render_view_host_->GrantFileAccessFromPageState(request_params.page_state); 2123 render_view_host_->GrantFileAccessFromPageState(request_params.page_state);
2098 } 2124 }
2099 } 2125 }
2100 2126
2101 } // namespace content 2127 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698