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 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 // a different process. This involves running the unload handler and | 1534 // a different process. This involves running the unload handler and |
1535 // clearing the page. We also allow this process to exit if there are no | 1535 // clearing the page. We also allow this process to exit if there are no |
1536 // other active RenderFrames in it. | 1536 // other active RenderFrames in it. |
1537 | 1537 |
1538 // Send an UpdateState message before we get deleted. | 1538 // Send an UpdateState message before we get deleted. |
1539 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 1539 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
1540 SendUpdateState(); | 1540 SendUpdateState(); |
1541 else | 1541 else |
1542 render_view_->SendUpdateState(); | 1542 render_view_->SendUpdateState(); |
1543 | 1543 |
1544 // If we need a proxy to replace this, create it now so its routing id is | 1544 // There should always be a proxy to replace this RenderFrame. Create it now |
1545 // registered for receiving IPC messages. | 1545 // so its routing id is registered for receiving IPC messages. |
1546 if (proxy_routing_id != MSG_ROUTING_NONE) { | 1546 CHECK_NE(proxy_routing_id, MSG_ROUTING_NONE); |
1547 proxy = RenderFrameProxy::CreateProxyToReplaceFrame( | 1547 proxy = RenderFrameProxy::CreateProxyToReplaceFrame( |
1548 this, proxy_routing_id, replicated_frame_state.scope); | 1548 this, proxy_routing_id, replicated_frame_state.scope); |
1549 } | |
1550 | 1549 |
1551 // Synchronously run the unload handler before sending the ACK. | 1550 // Synchronously run the unload handler before sending the ACK. |
1552 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support | 1551 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support |
1553 // unload on subframes as well. | 1552 // unload on subframes as well. |
1554 if (is_main_frame_) | 1553 if (is_main_frame_) |
1555 frame_->dispatchUnloadEvent(); | 1554 frame_->dispatchUnloadEvent(); |
1556 | 1555 |
1557 // Swap out and stop sending any IPC messages that are not ACKs. | 1556 // Swap out and stop sending any IPC messages that are not ACKs. |
1558 if (is_main_frame_) | 1557 if (is_main_frame_) |
1559 render_view_->SetSwappedOut(true); | 1558 render_view_->SetSwappedOut(true); |
1560 | 1559 |
1561 // Set the proxy here, since OnStop() below could cause an onload event | 1560 // Set the proxy here, since OnStop() below could cause an onload event |
1562 // handler to execute, which could trigger code such as | 1561 // handler to execute, which could trigger code such as |
1563 // willCheckAndDispatchMessageEvent() that needs the proxy. | 1562 // willCheckAndDispatchMessageEvent() that needs the proxy. |
1564 if (proxy) | 1563 set_render_frame_proxy(proxy); |
1565 set_render_frame_proxy(proxy); | |
1566 | 1564 |
1567 // Transfer settings such as initial drawing parameters to the remote frame, | 1565 // Transfer settings such as initial drawing parameters to the remote frame, |
1568 // if one is created, that will replace this frame. | 1566 // if one is created, that will replace this frame. |
1569 if (!is_main_frame_ && proxy) | 1567 if (!is_main_frame_) |
1570 proxy->web_frame()->initializeFromFrame(frame_); | 1568 proxy->web_frame()->initializeFromFrame(frame_); |
1571 | 1569 |
1572 // Let WebKit know that this view is hidden so it can drop resources and | 1570 // Let WebKit know that this view is hidden so it can drop resources and |
1573 // stop compositing. | 1571 // stop compositing. |
1574 // TODO(creis): Support this for subframes as well. | 1572 // TODO(creis): Support this for subframes as well. |
1575 if (is_main_frame_) { | 1573 if (is_main_frame_) { |
1576 render_view_->webview()->setVisibilityState( | 1574 render_view_->webview()->setVisibilityState( |
1577 blink::WebPageVisibilityStateHidden, false); | 1575 blink::WebPageVisibilityStateHidden, false); |
1578 } | 1576 } |
1579 | 1577 |
1580 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); | 1578 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); |
1581 | 1579 |
1582 RenderViewImpl* render_view = render_view_.get(); | 1580 RenderViewImpl* render_view = render_view_.get(); |
1583 bool is_main_frame = is_main_frame_; | 1581 bool is_main_frame = is_main_frame_; |
1584 int routing_id = GetRoutingID(); | 1582 int routing_id = GetRoutingID(); |
1585 | 1583 |
1586 // Now that all of the cleanup is complete and the browser side is notified, | 1584 // Now that all of the cleanup is complete and the browser side is notified, |
1587 // start using the RenderFrameProxy, if one is created. | 1585 // start using the RenderFrameProxy. |
1588 if (proxy) { | 1586 // |
1589 // The swap call deletes this RenderFrame via frameDetached. Do not access | 1587 // The swap call deletes this RenderFrame via frameDetached. Do not access |
1590 // any members after this call. | 1588 // any members after this call. |
1591 // TODO(creis): WebFrame::swap() can return false. Most of those cases | 1589 // |
1592 // should be due to the frame being detached during unload (in which case | 1590 // TODO(creis): WebFrame::swap() can return false. Most of those cases |
1593 // the necessary cleanup has happened anyway), but it might be possible for | 1591 // should be due to the frame being detached during unload (in which case |
1594 // it to return false without detaching. Catch those cases below to track | 1592 // the necessary cleanup has happened anyway), but it might be possible for |
1595 // down https://crbug.com/575245. | 1593 // it to return false without detaching. Catch those cases below to track |
1596 frame_->swap(proxy->web_frame()); | 1594 // down https://crbug.com/575245. |
| 1595 frame_->swap(proxy->web_frame()); |
1597 | 1596 |
1598 // For main frames, the swap should have cleared the RenderView's pointer to | 1597 // For main frames, the swap should have cleared the RenderView's pointer to |
1599 // this frame. | 1598 // this frame. |
1600 if (is_main_frame) { | 1599 if (is_main_frame) { |
1601 base::debug::SetCrashKeyValue("swapout_frame_id", | 1600 base::debug::SetCrashKeyValue("swapout_frame_id", |
1602 base::IntToString(routing_id)); | 1601 base::IntToString(routing_id)); |
1603 base::debug::SetCrashKeyValue("swapout_proxy_id", | 1602 base::debug::SetCrashKeyValue("swapout_proxy_id", |
1604 base::IntToString(proxy->routing_id())); | 1603 base::IntToString(proxy->routing_id())); |
1605 base::debug::SetCrashKeyValue( | 1604 base::debug::SetCrashKeyValue( |
1606 "swapout_view_id", base::IntToString(render_view->GetRoutingID())); | 1605 "swapout_view_id", base::IntToString(render_view->GetRoutingID())); |
1607 CHECK(!render_view->main_render_frame_); | 1606 CHECK(!render_view->main_render_frame_); |
1608 } | 1607 } |
1609 | 1608 |
1610 if (is_loading) | 1609 if (is_loading) |
1611 proxy->OnDidStartLoading(); | 1610 proxy->OnDidStartLoading(); |
1612 } | |
1613 | 1611 |
1614 // Initialize the WebRemoteFrame with the replication state passed by the | 1612 // Initialize the WebRemoteFrame with the replication state passed by the |
1615 // process that is now rendering the frame. | 1613 // process that is now rendering the frame. |
1616 if (proxy) | 1614 proxy->SetReplicatedState(replicated_frame_state); |
1617 proxy->SetReplicatedState(replicated_frame_state); | |
1618 | 1615 |
1619 // Safe to exit if no one else is using the process. | 1616 // Safe to exit if no one else is using the process. |
1620 // TODO(nasko): Remove the dependency on RenderViewImpl here and ref count | 1617 // TODO(nasko): Remove the dependency on RenderViewImpl here and ref count |
1621 // the process based on the lifetime of this RenderFrameImpl object. | 1618 // the process based on the lifetime of this RenderFrameImpl object. |
1622 if (is_main_frame) | 1619 if (is_main_frame) |
1623 render_view->WasSwappedOut(); | 1620 render_view->WasSwappedOut(); |
1624 } | 1621 } |
1625 | 1622 |
1626 void RenderFrameImpl::OnDeleteFrame() { | 1623 void RenderFrameImpl::OnDeleteFrame() { |
1627 // TODO(nasko): If this message is received right after a commit has | 1624 // TODO(nasko): If this message is received right after a commit has |
(...skipping 4412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6040 int match_count, | 6037 int match_count, |
6041 int ordinal, | 6038 int ordinal, |
6042 const WebRect& selection_rect, | 6039 const WebRect& selection_rect, |
6043 bool final_status_update) { | 6040 bool final_status_update) { |
6044 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6041 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
6045 selection_rect, ordinal, | 6042 selection_rect, ordinal, |
6046 final_status_update)); | 6043 final_status_update)); |
6047 } | 6044 } |
6048 | 6045 |
6049 } // namespace content | 6046 } // namespace content |
OLD | NEW |