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 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1712 // unload on subframes as well. | 1712 // unload on subframes as well. |
1713 if (is_main_frame_) | 1713 if (is_main_frame_) |
1714 frame_->dispatchUnloadEvent(); | 1714 frame_->dispatchUnloadEvent(); |
1715 | 1715 |
1716 // Swap out and stop sending any IPC messages that are not ACKs. | 1716 // Swap out and stop sending any IPC messages that are not ACKs. |
1717 if (is_main_frame_) | 1717 if (is_main_frame_) |
1718 render_view_->SetSwappedOut(true); | 1718 render_view_->SetSwappedOut(true); |
1719 | 1719 |
1720 RenderViewImpl* render_view = render_view_; | 1720 RenderViewImpl* render_view = render_view_; |
1721 bool is_main_frame = is_main_frame_; | 1721 bool is_main_frame = is_main_frame_; |
1722 int routing_id = GetRoutingID(); | |
1723 | 1722 |
1724 // Now that all of the cleanup is complete and the browser side is notified, | 1723 // Now that all of the cleanup is complete and the browser side is notified, |
1725 // start using the RenderFrameProxy. | 1724 // start using the RenderFrameProxy. |
1726 // | 1725 // |
1727 // The swap call deletes this RenderFrame via frameDetached. Do not access | 1726 // The swap call deletes this RenderFrame via frameDetached. Do not access |
1728 // any members after this call. | 1727 // any members after this call. |
1729 // | 1728 // |
1730 // TODO(creis): WebFrame::swap() can return false. Most of those cases | 1729 // TODO(creis): WebFrame::swap() can return false. Most of those cases |
1731 // should be due to the frame being detached during unload (in which case | 1730 // should be due to the frame being detached during unload (in which case |
1732 // the necessary cleanup has happened anyway), but it might be possible for | 1731 // the necessary cleanup has happened anyway), but it might be possible for |
1733 // it to return false without detaching. Catch any cases that the | 1732 // it to return false without detaching. Catch any cases that the |
1734 // RenderView's main_render_frame_ isn't cleared below (whether swap returns | 1733 // RenderView's main_render_frame_ isn't cleared below (whether swap returns |
1735 // false or not), to track down https://crbug.com/575245. | 1734 // false or not). |
1736 bool success = frame_->swap(proxy->web_frame()); | 1735 bool success = frame_->swap(proxy->web_frame()); |
1737 | 1736 |
1738 // For main frames, the swap should have cleared the RenderView's pointer to | 1737 // For main frames, the swap should have cleared the RenderView's pointer to |
1739 // this frame. | 1738 // this frame. |
1740 if (is_main_frame) { | 1739 if (is_main_frame) |
1741 base::debug::SetCrashKeyValue("swapout_frame_id", | |
1742 base::IntToString(routing_id)); | |
1743 base::debug::SetCrashKeyValue("swapout_proxy_id", | |
1744 base::IntToString(proxy->routing_id())); | |
1745 base::debug::SetCrashKeyValue( | |
1746 "swapout_view_id", base::IntToString(render_view->GetRoutingID())); | |
1747 CHECK(!render_view->main_render_frame_); | 1740 CHECK(!render_view->main_render_frame_); |
Charlie Reis
2016/12/13 00:07:57
I left this in place, since it seems like a useful
alexmos
2016/12/13 20:28:55
Acknowledged.
| |
1748 } | |
1749 | 1741 |
1750 if (!success) { | 1742 if (!success) { |
1751 // The swap can fail when the frame is detached during swap (this can | 1743 // The swap can fail when the frame is detached during swap (this can |
1752 // happen while running the unload handlers). When that happens, delete | 1744 // happen while running the unload handlers). When that happens, delete |
1753 // the proxy. | 1745 // the proxy. |
1754 proxy->frameDetached(blink::WebRemoteFrameClient::DetachType::Swap); | 1746 proxy->frameDetached(blink::WebRemoteFrameClient::DetachType::Swap); |
1755 return; | 1747 return; |
1756 } | 1748 } |
1757 | 1749 |
1758 if (is_loading) | 1750 if (is_loading) |
1759 proxy->OnDidStartLoading(); | 1751 proxy->OnDidStartLoading(); |
1760 | 1752 |
1761 // Initialize the WebRemoteFrame with the replication state passed by the | 1753 // Initialize the WebRemoteFrame with the replication state passed by the |
1762 // process that is now rendering the frame. | 1754 // process that is now rendering the frame. |
1763 proxy->SetReplicatedState(replicated_frame_state); | 1755 proxy->SetReplicatedState(replicated_frame_state); |
1764 | 1756 |
1765 // Safe to exit if no one else is using the process. | 1757 // Safe to exit if no one else is using the process. |
1766 // TODO(nasko): Remove the dependency on RenderViewImpl here and ref count | 1758 // TODO(nasko): Remove the dependency on RenderViewImpl here and ref count |
1767 // the process based on the lifetime of this RenderFrameImpl object. | 1759 // the process based on the lifetime of this RenderFrameImpl object. |
1768 if (is_main_frame) | 1760 if (is_main_frame) |
1769 render_view->WasSwappedOut(); | 1761 render_view->WasSwappedOut(); |
1770 | 1762 |
1771 // Notify the browser that this frame was swapped. Use the RenderThread | 1763 // Notify the browser that this frame was swapped. Use the RenderThread |
1772 // directly because |this| is deleted. | 1764 // directly because |this| is deleted. |
1773 RenderThread::Get()->Send(new FrameHostMsg_SwapOut_ACK(routing_id)); | 1765 RenderThread::Get()->Send(new FrameHostMsg_SwapOut_ACK(GetRoutingID())); |
1774 } | 1766 } |
1775 | 1767 |
1776 void RenderFrameImpl::OnDeleteFrame() { | 1768 void RenderFrameImpl::OnDeleteFrame() { |
1777 // TODO(nasko): If this message is received right after a commit has | 1769 // TODO(nasko): If this message is received right after a commit has |
1778 // swapped a RenderFrameProxy with this RenderFrame, the proxy needs to be | 1770 // swapped a RenderFrameProxy with this RenderFrame, the proxy needs to be |
1779 // recreated in addition to the RenderFrame being deleted. | 1771 // recreated in addition to the RenderFrame being deleted. |
1780 // See https://crbug.com/569683 for details. | 1772 // See https://crbug.com/569683 for details. |
1781 in_browser_initiated_detach_ = true; | 1773 in_browser_initiated_detach_ = true; |
1782 | 1774 |
1783 // This will result in a call to RendeFrameImpl::frameDetached, which | 1775 // This will result in a call to RendeFrameImpl::frameDetached, which |
(...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3549 | 3541 |
3550 // The proxy might have been detached while the provisional LocalFrame was | 3542 // The proxy might have been detached while the provisional LocalFrame was |
3551 // being navigated. In that case, don't swap the frame back in the tree | 3543 // being navigated. In that case, don't swap the frame back in the tree |
3552 // and return early (to avoid sending confusing IPCs to the browser | 3544 // and return early (to avoid sending confusing IPCs to the browser |
3553 // process). See https://crbug.com/526304 and https://crbug.com/568676. | 3545 // process). See https://crbug.com/526304 and https://crbug.com/568676. |
3554 // TODO(nasko, alexmos): Eventually, the browser process will send an IPC | 3546 // TODO(nasko, alexmos): Eventually, the browser process will send an IPC |
3555 // to clean this frame up after https://crbug.com/548275 is fixed. | 3547 // to clean this frame up after https://crbug.com/548275 is fixed. |
3556 if (!proxy) | 3548 if (!proxy) |
3557 return; | 3549 return; |
3558 | 3550 |
3559 int proxy_routing_id = proxy_routing_id_; | |
3560 if (!proxy->web_frame()->swap(frame_)) | 3551 if (!proxy->web_frame()->swap(frame_)) |
3561 return; | 3552 return; |
3562 proxy_routing_id_ = MSG_ROUTING_NONE; | 3553 proxy_routing_id_ = MSG_ROUTING_NONE; |
3563 in_frame_tree_ = true; | 3554 in_frame_tree_ = true; |
3564 | 3555 |
3565 // If this is the main frame going from a remote frame to a local frame, | 3556 // If this is the main frame going from a remote frame to a local frame, |
3566 // it needs to set RenderViewImpl's pointer for the main frame to itself | 3557 // it needs to set RenderViewImpl's pointer for the main frame to itself |
3567 // and ensure RenderWidget is no longer in swapped out mode. | 3558 // and ensure RenderWidget is no longer in swapped out mode. |
3568 if (is_main_frame_) { | 3559 if (is_main_frame_) { |
3569 // Debug cases of https://crbug.com/575245. | |
3570 base::debug::SetCrashKeyValue("commit_frame_id", | |
3571 base::IntToString(GetRoutingID())); | |
3572 base::debug::SetCrashKeyValue("commit_proxy_id", | |
3573 base::IntToString(proxy_routing_id)); | |
3574 base::debug::SetCrashKeyValue( | |
3575 "commit_view_id", base::IntToString(render_view_->GetRoutingID())); | |
3576 if (render_view_->main_render_frame_) { | |
3577 base::debug::SetCrashKeyValue( | |
3578 "commit_main_render_frame_id", | |
3579 base::IntToString( | |
3580 render_view_->main_render_frame_->GetRoutingID())); | |
3581 } | |
3582 CHECK(!render_view_->main_render_frame_); | 3560 CHECK(!render_view_->main_render_frame_); |
3583 render_view_->main_render_frame_ = this; | 3561 render_view_->main_render_frame_ = this; |
3584 if (render_view_->is_swapped_out()) | 3562 if (render_view_->is_swapped_out()) |
3585 render_view_->SetSwappedOut(false); | 3563 render_view_->SetSwappedOut(false); |
3586 } | 3564 } |
3587 } | 3565 } |
3588 | 3566 |
3589 // For new page navigations, the browser process needs to be notified of the | 3567 // For new page navigations, the browser process needs to be notified of the |
3590 // first paint of that page, so it can cancel the timer that waits for it. | 3568 // first paint of that page, so it can cancel the timer that waits for it. |
3591 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { | 3569 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { |
(...skipping 3089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6681 // event target. Potentially a Pepper plugin will receive the event. | 6659 // event target. Potentially a Pepper plugin will receive the event. |
6682 // In order to tell whether a plugin gets the last mouse event and which it | 6660 // In order to tell whether a plugin gets the last mouse event and which it |
6683 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6661 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6684 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6662 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6685 // |pepper_last_mouse_event_target_|. | 6663 // |pepper_last_mouse_event_target_|. |
6686 pepper_last_mouse_event_target_ = nullptr; | 6664 pepper_last_mouse_event_target_ = nullptr; |
6687 #endif | 6665 #endif |
6688 } | 6666 } |
6689 | 6667 |
6690 } // namespace content | 6668 } // namespace content |
OLD | NEW |