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 "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" | 106 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" |
107 #endif | 107 #endif |
108 | 108 |
109 // Cross-Site Navigations | 109 // Cross-Site Navigations |
110 // | 110 // |
111 // If a WebContentsImpl is told to navigate to a different web site (as | 111 // If a WebContentsImpl is told to navigate to a different web site (as |
112 // determined by SiteInstance), it will replace its current RenderViewHost with | 112 // determined by SiteInstance), it will replace its current RenderViewHost with |
113 // a new RenderViewHost dedicated to the new SiteInstance. This works as | 113 // a new RenderViewHost dedicated to the new SiteInstance. This works as |
114 // follows: | 114 // follows: |
115 // | 115 // |
116 // - Navigate determines whether the destination is cross-site, and if so, | 116 // - RVHM::Navigate determines whether the destination is cross-site, and if so, |
117 // it creates a pending_render_view_host_. | 117 // it creates a pending_render_view_host_. |
118 // - The pending RVH is "suspended," so that no navigation messages are sent to | 118 // - The pending RVH is "suspended," so that no navigation messages are sent to |
119 // its renderer until the onbeforeunload JavaScript handler has a chance to | 119 // its renderer until the beforeunload JavaScript handler has a chance to |
120 // run in the current RVH. | 120 // run in the current RVH. |
121 // - The pending RVH tells CrossSiteRequestManager (a thread-safe singleton) | 121 // - The pending RVH tells CrossSiteRequestManager (a thread-safe singleton) |
122 // that it has a pending cross-site request. ResourceDispatcherHost will | 122 // that it has a pending cross-site request. We will check this on the IO |
123 // check for this when the response arrives. | 123 // thread when deciding how to handle the response. |
124 // - The current RVH runs its onbeforeunload handler. If it returns false, we | 124 // - The current RVH runs its beforeunload handler. If it returns false, we |
125 // cancel all the pending logic. Otherwise we allow the pending RVH to send | 125 // cancel all the pending logic. Otherwise we allow the pending RVH to send |
126 // the navigation request to its renderer. | 126 // the navigation request to its renderer. |
127 // - ResourceDispatcherHost receives a ResourceRequest on the IO thread for the | 127 // - ResourceDispatcherHost receives a ResourceRequest on the IO thread for the |
128 // main resource load on the pending RVH. It checks CrossSiteRequestManager | 128 // main resource load on the pending RVH. It creates a |
129 // to see that it is a cross-site request, and installs a | 129 // CrossSiteResourceHandler to check whether a process swap is needed when |
130 // CrossSiteResourceHandler. | 130 // the request is ready to commit. |
131 // - When RDH receives a response, the BufferedResourceHandler determines | 131 // - When RDH receives a response, the BufferedResourceHandler determines |
132 // whether it is a download. If so, it sends a message to the new renderer | 132 // whether it is a download. If so, it sends a message to the new renderer |
133 // causing it to cancel the request, and the download proceeds. For now, the | 133 // causing it to cancel the request, and the download proceeds. For now, the |
134 // pending RVH remains until the next DidNavigate event for this | 134 // pending RVH remains until the next DidNavigate event for this |
135 // WebContentsImpl. This isn't ideal, but it doesn't affect any functionality. | 135 // WebContentsImpl. This isn't ideal, but it doesn't affect any functionality. |
136 // - After RDH receives a response and determines that it is safe and not a | 136 // - After RDH receives a response and determines that it is safe and not a |
137 // download, it pauses the response to first run the old page's onunload | 137 // download, the CrossSiteResourceHandler checks whether a process swap is |
138 // handler. It does this by asynchronously calling the OnCrossSiteResponse | 138 // needed (either because CrossSiteRequestManager has state for it or because |
139 // method of WebContentsImpl on the UI thread, which sends a SwapOut message | 139 // a transfer was needed for a redirect). |
140 // to the current RVH. | 140 // - If so, CrossSiteResourceHandler pauses the response to first run the old |
141 // - Once the onunload handler is finished, a SwapOut_ACK message is sent to | 141 // page's unload handler. It does this by asynchronously calling the |
142 // the ResourceDispatcherHost, who unpauses the response. Data is then sent | 142 // OnCrossSiteResponse method of RenderViewHostManager on the UI thread, which |
143 // to the pending RVH. | 143 // sends a SwapOut message to the current RVH. |
| 144 // - Once the unload handler is finished, RVHM::SwappedOut checks if a transfer |
| 145 // to a new process is needed, based on the stored pending_nav_params_. (This |
| 146 // is independent of whether we started out with a cross-process navigation.) |
| 147 // - If not, it just tells the ResourceDispatcherHost to resume the response |
| 148 // to its current RenderViewHost. |
| 149 // - If so, it cancels the current pending RenderViewHost and sets up a new |
| 150 // navigation using RequestTransferURL. When the transferred request |
| 151 // arrives in the ResourceDispatcherHost, we transfer the response and |
| 152 // resume it. |
144 // - The pending renderer sends a FrameNavigate message that invokes the | 153 // - The pending renderer sends a FrameNavigate message that invokes the |
145 // DidNavigate method. This replaces the current RVH with the | 154 // DidNavigate method. This replaces the current RVH with the |
146 // pending RVH. | 155 // pending RVH. |
147 // - The previous renderer is kept swapped out in RenderViewHostManager in case | 156 // - The previous renderer is kept swapped out in RenderViewHostManager in case |
148 // the user goes back. The process only stays live if another tab is using | 157 // the user goes back. The process only stays live if another tab is using |
149 // it, but if so, the existing frame relationships will be maintained. | 158 // it, but if so, the existing frame relationships will be maintained. |
150 | 159 |
151 namespace content { | 160 namespace content { |
152 namespace { | 161 namespace { |
153 | 162 |
(...skipping 3705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3859 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { | 3868 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { |
3860 gfx::Size size; | 3869 gfx::Size size; |
3861 if (delegate_) | 3870 if (delegate_) |
3862 size = delegate_->GetSizeForNewRenderView(this); | 3871 size = delegate_->GetSizeForNewRenderView(this); |
3863 if (size.IsEmpty()) | 3872 if (size.IsEmpty()) |
3864 size = view_->GetContainerSize(); | 3873 size = view_->GetContainerSize(); |
3865 return size; | 3874 return size; |
3866 } | 3875 } |
3867 | 3876 |
3868 } // namespace content | 3877 } // namespace content |
OLD | NEW |