OLD | NEW |
---|---|
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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
501 return media::Context3D(provider->ContextGL(), provider->GrContext()); | 501 return media::Context3D(provider->ContextGL(), provider->GrContext()); |
502 } | 502 } |
503 #endif | 503 #endif |
504 | 504 |
505 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) { | 505 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) { |
506 return navigation_type == FrameMsg_Navigate_Type::RELOAD || | 506 return navigation_type == FrameMsg_Navigate_Type::RELOAD || |
507 navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE || | 507 navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE || |
508 navigation_type == FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; | 508 navigation_type == FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; |
509 } | 509 } |
510 | 510 |
511 bool IsSwappedOutStateForbidden() { | |
ncarter (slow)
2015/06/26 20:27:17
I don't like having IsSwappedOutStateForbidden on
nasko
2015/06/29 08:06:20
Acknowledged.
| |
512 return base::CommandLine::ForCurrentProcess()->HasSwitch( | |
513 switches::kSitePerProcess); | |
514 } | |
515 | |
511 RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl = | 516 RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl = |
512 nullptr; | 517 nullptr; |
513 | 518 |
514 } // namespace | 519 } // namespace |
515 | 520 |
516 // static | 521 // static |
517 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, | 522 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, |
518 int32 routing_id) { | 523 int32 routing_id) { |
519 DCHECK(routing_id != MSG_ROUTING_NONE); | 524 DCHECK(routing_id != MSG_ROUTING_NONE); |
520 | 525 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
681 RenderFrameImpl::~RenderFrameImpl() { | 686 RenderFrameImpl::~RenderFrameImpl() { |
682 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, RenderFrameGone()); | 687 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, RenderFrameGone()); |
683 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnDestruct()); | 688 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnDestruct()); |
684 | 689 |
685 #if defined(VIDEO_HOLE) | 690 #if defined(VIDEO_HOLE) |
686 if (contains_media_player_) | 691 if (contains_media_player_) |
687 render_view_->UnregisterVideoHoleFrame(this); | 692 render_view_->UnregisterVideoHoleFrame(this); |
688 #endif | 693 #endif |
689 | 694 |
690 if (!is_subframe_) { | 695 if (!is_subframe_) { |
691 // When not using --site-per-process, RenderFrameProxy is "owned" by | 696 if (!IsSwappedOutStateForbidden()) { |
692 // RenderFrameImpl in the case it is the main frame. Ensure it is deleted | 697 // When using swapped out frames, RenderFrameProxy is "owned" by |
693 // along with this object. | 698 // RenderFrameImpl in the case it is the main frame. Ensure it is deleted |
694 if (render_frame_proxy_ && | 699 // along with this object. |
695 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 700 if (render_frame_proxy_ && |
696 switches::kSitePerProcess)) { | 701 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
697 // The following method calls back into this object and clears | 702 switches::kSitePerProcess)) { |
ncarter (slow)
2015/06/26 20:27:17
I think you meant to remove this command line chec
nasko
2015/06/29 08:06:20
D'oh!
| |
698 // |render_frame_proxy_|. | 703 // The following method calls back into this object and clears |
699 render_frame_proxy_->frameDetached( | 704 // |render_frame_proxy_|. |
700 blink::WebRemoteFrameClient::DetachType::Remove); | 705 render_frame_proxy_->frameDetached( |
706 blink::WebRemoteFrameClient::DetachType::Remove); | |
707 } | |
701 } | 708 } |
702 | 709 |
703 // Ensure the RenderView doesn't point to this object, once it is destroyed. | 710 // Ensure the RenderView doesn't point to this object, once it is destroyed. |
704 // TODO(nasko): Add a check that the |main_render_frame_| of |render_view_| | 711 // TODO(nasko): Add a check that the |main_render_frame_| of |render_view_| |
705 // is |this|, once the object is no longer leaked. | 712 // is |this|, once the object is no longer leaked. |
706 // See https://crbug.com/464764. | 713 // See https://crbug.com/464764. |
707 render_view_->main_render_frame_ = nullptr; | 714 render_view_->main_render_frame_ = nullptr; |
708 } | 715 } |
709 | 716 |
710 render_view_->UnregisterRenderFrame(this); | 717 render_view_->UnregisterRenderFrame(this); |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1108 void RenderFrameImpl::OnSwapOut( | 1115 void RenderFrameImpl::OnSwapOut( |
1109 int proxy_routing_id, | 1116 int proxy_routing_id, |
1110 bool is_loading, | 1117 bool is_loading, |
1111 const FrameReplicationState& replicated_frame_state) { | 1118 const FrameReplicationState& replicated_frame_state) { |
1112 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); | 1119 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); |
1113 RenderFrameProxy* proxy = NULL; | 1120 RenderFrameProxy* proxy = NULL; |
1114 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( | 1121 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( |
1115 switches::kSitePerProcess); | 1122 switches::kSitePerProcess); |
1116 bool is_main_frame = !frame_->parent(); | 1123 bool is_main_frame = !frame_->parent(); |
1117 | 1124 |
1125 // This codepath should only be hit for subframes when in --site-per-process. | |
1126 CHECK_IMPLIES(!is_main_frame, is_site_per_process); | |
1127 | |
1118 // Only run unload if we're not swapped out yet, but send the ack either way. | 1128 // Only run unload if we're not swapped out yet, but send the ack either way. |
1119 if (!is_swapped_out_) { | 1129 if (!is_swapped_out_) { |
1120 // Swap this RenderFrame out so the frame can navigate to a page rendered by | 1130 // Swap this RenderFrame out so the frame can navigate to a page rendered by |
1121 // a different process. This involves running the unload handler and | 1131 // a different process. This involves running the unload handler and |
1122 // clearing the page. We also allow this process to exit if there are no | 1132 // clearing the page. We also allow this process to exit if there are no |
1123 // other active RenderFrames in it. | 1133 // other active RenderFrames in it. |
1124 | 1134 |
1125 // Send an UpdateState message before we get swapped out. | 1135 // Send an UpdateState message before we get swapped out. |
1126 render_view_->SyncNavigationState(); | 1136 render_view_->SyncNavigationState(); |
1127 | 1137 |
(...skipping 20 matching lines...) Expand all Loading... | |
1148 // willCheckAndDispatchMessageEvent() that needs the proxy. | 1158 // willCheckAndDispatchMessageEvent() that needs the proxy. |
1149 if (proxy) | 1159 if (proxy) |
1150 set_render_frame_proxy(proxy); | 1160 set_render_frame_proxy(proxy); |
1151 | 1161 |
1152 // Now that we're swapped out and filtering IPC messages, stop loading to | 1162 // Now that we're swapped out and filtering IPC messages, stop loading to |
1153 // ensure that no other in-progress navigation continues. We do this here | 1163 // ensure that no other in-progress navigation continues. We do this here |
1154 // to avoid sending a DidStopLoading message to the browser process. | 1164 // to avoid sending a DidStopLoading message to the browser process. |
1155 // TODO(creis): Should we be stopping all frames here and using | 1165 // TODO(creis): Should we be stopping all frames here and using |
1156 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this | 1166 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this |
1157 // frame? | 1167 // frame? |
1158 if (!is_site_per_process) | 1168 if (!IsSwappedOutStateForbidden()) |
1159 OnStop(); | 1169 OnStop(); |
1160 | 1170 |
1161 // Transfer settings such as initial drawing parameters to the remote frame, | 1171 // Transfer settings such as initial drawing parameters to the remote frame, |
1162 // if one is created, that will replace this frame. | 1172 // if one is created, that will replace this frame. |
1163 if (!is_main_frame && proxy) | 1173 if (!is_main_frame && proxy) |
1164 proxy->web_frame()->initializeFromFrame(frame_); | 1174 proxy->web_frame()->initializeFromFrame(frame_); |
1165 | 1175 |
1166 // Replace the page with a blank dummy URL. The unload handler will not be | 1176 // Replace the page with a blank dummy URL. The unload handler will not be |
1167 // run a second time, thanks to a check in FrameLoader::stopLoading. | 1177 // run a second time, thanks to a check in FrameLoader::stopLoading. |
1168 // TODO(creis): Need to add a better way to do this that avoids running the | 1178 // TODO(creis): Need to add a better way to do this that avoids running the |
1169 // beforeunload handler. For now, we just run it a second time silently. | 1179 // beforeunload handler. For now, we just run it a second time silently. |
1170 if (!is_site_per_process) | 1180 if (!IsSwappedOutStateForbidden()) |
1171 NavigateToSwappedOutURL(); | 1181 NavigateToSwappedOutURL(); |
1172 | 1182 |
1173 // Let WebKit know that this view is hidden so it can drop resources and | 1183 // Let WebKit know that this view is hidden so it can drop resources and |
1174 // stop compositing. | 1184 // stop compositing. |
1175 // TODO(creis): Support this for subframes as well. | 1185 // TODO(creis): Support this for subframes as well. |
1176 if (is_main_frame) { | 1186 if (is_main_frame) { |
1177 render_view_->webview()->setVisibilityState( | 1187 render_view_->webview()->setVisibilityState( |
1178 blink::WebPageVisibilityStateHidden, false); | 1188 blink::WebPageVisibilityStateHidden, false); |
1179 } | 1189 } |
1180 } | 1190 } |
1181 | 1191 |
1182 // It is now safe to show modal dialogs again. | 1192 // It is now safe to show modal dialogs again. |
1183 // TODO(creis): Deal with modal dialogs from subframes. | 1193 // TODO(creis): Deal with modal dialogs from subframes. |
1184 if (is_main_frame) | 1194 if (is_main_frame) |
1185 render_view_->suppress_dialogs_until_swap_out_ = false; | 1195 render_view_->suppress_dialogs_until_swap_out_ = false; |
1186 | 1196 |
1187 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); | 1197 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); |
1188 | 1198 |
1189 RenderViewImpl* render_view = render_view_.get(); | 1199 RenderViewImpl* render_view = render_view_.get(); |
1190 | 1200 |
1191 // Now that all of the cleanup is complete and the browser side is notified, | 1201 // Now that all of the cleanup is complete and the browser side is notified, |
1192 // start using the RenderFrameProxy, if one is created. | 1202 // start using the RenderFrameProxy, if one is created. |
1193 if (proxy) { | 1203 if (proxy && IsSwappedOutStateForbidden()) { |
1194 if (is_site_per_process || !is_main_frame) { | 1204 frame_->swap(proxy->web_frame()); |
1195 frame_->swap(proxy->web_frame()); | |
1196 | 1205 |
1197 if (is_loading) | 1206 if (is_loading) |
1198 proxy->OnDidStartLoading(); | 1207 proxy->OnDidStartLoading(); |
1199 } | |
1200 } | 1208 } |
1201 | 1209 |
1202 // In --site-per-process, initialize the WebRemoteFrame with the replication | 1210 // In --site-per-process, initialize the WebRemoteFrame with the replication |
1203 // state passed by the process that is now rendering the frame. | 1211 // state passed by the process that is now rendering the frame. |
1204 // TODO(alexmos): We cannot yet do this for swapped-out main frames, because | 1212 // TODO(alexmos): We cannot yet do this for swapped-out main frames, because |
1205 // in that case we leave the LocalFrame as the main frame visible to Blink | 1213 // in that case we leave the LocalFrame as the main frame visible to Blink |
1206 // and don't call swap() above. Because swap() is what creates a RemoteFrame | 1214 // and don't call swap() above. Because swap() is what creates a RemoteFrame |
1207 // in proxy->web_frame(), the RemoteFrame will not exist for main frames. | 1215 // in proxy->web_frame(), the RemoteFrame will not exist for main frames. |
1208 // When we do an unconditional swap for all frames, we can remove | 1216 // When we do an unconditional swap for all frames, we can remove |
1209 // !is_main_frame below. | 1217 // !is_main_frame below. |
1210 if (is_site_per_process && proxy) | 1218 if (proxy && IsSwappedOutStateForbidden()) |
1211 proxy->SetReplicatedState(replicated_frame_state); | 1219 proxy->SetReplicatedState(replicated_frame_state); |
1212 | 1220 |
1213 // Safe to exit if no one else is using the process. | 1221 // Safe to exit if no one else is using the process. |
1214 // TODO(nasko): Remove the dependency on RenderViewImpl here and ref count | 1222 // TODO(nasko): Remove the dependency on RenderViewImpl here and ref count |
1215 // the process based on the lifetime of this RenderFrameImpl object. | 1223 // the process based on the lifetime of this RenderFrameImpl object. |
1216 if (is_main_frame) { | 1224 if (is_main_frame) { |
1217 render_view->WasSwappedOut(); | 1225 render_view->WasSwappedOut(); |
1218 } | 1226 } |
1219 } | 1227 } |
1220 | 1228 |
(...skipping 3749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4970 #elif defined(ENABLE_BROWSER_CDMS) | 4978 #elif defined(ENABLE_BROWSER_CDMS) |
4971 cdm_manager_, | 4979 cdm_manager_, |
4972 #endif | 4980 #endif |
4973 this); | 4981 this); |
4974 } | 4982 } |
4975 | 4983 |
4976 return cdm_factory_; | 4984 return cdm_factory_; |
4977 } | 4985 } |
4978 | 4986 |
4979 } // namespace content | 4987 } // namespace content |
OLD | NEW |