Chromium Code Reviews| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h" | 102 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h" |
| 103 #endif | 103 #endif |
| 104 | 104 |
| 105 // Cross-Site Navigations | 105 // Cross-Site Navigations |
| 106 // | 106 // |
| 107 // If a WebContentsImpl is told to navigate to a different web site (as | 107 // If a WebContentsImpl is told to navigate to a different web site (as |
| 108 // determined by SiteInstance), it will replace its current RenderViewHost with | 108 // determined by SiteInstance), it will replace its current RenderViewHost with |
| 109 // a new RenderViewHost dedicated to the new SiteInstance. This works as | 109 // a new RenderViewHost dedicated to the new SiteInstance. This works as |
| 110 // follows: | 110 // follows: |
| 111 // | 111 // |
| 112 // - Navigate determines whether the destination is cross-site, and if so, | 112 // - RVHM::Navigate determines whether the destination is cross-site, and if so, |
| 113 // it creates a pending_render_view_host_. | 113 // it creates a pending_render_view_host_. |
| 114 // - The pending RVH is "suspended," so that no navigation messages are sent to | 114 // - The pending RVH is "suspended," so that no navigation messages are sent to |
| 115 // its renderer until the onbeforeunload JavaScript handler has a chance to | 115 // its renderer until the beforeunload JavaScript handler has a chance to |
| 116 // run in the current RVH. | 116 // run in the current RVH. |
| 117 // - The pending RVH tells CrossSiteRequestManager (a thread-safe singleton) | 117 // - The pending RVH tells CrossSiteRequestManager (a thread-safe singleton) |
| 118 // that it has a pending cross-site request. ResourceDispatcherHost will | 118 // that it has a pending cross-site request. We will check this on the IO |
| 119 // check for this when the response arrives. | 119 // thread when deciding how to handle the response. |
| 120 // - The current RVH runs its onbeforeunload handler. If it returns false, we | 120 // - The current RVH runs its beforeunload handler. If it returns false, we |
| 121 // cancel all the pending logic. Otherwise we allow the pending RVH to send | 121 // cancel all the pending logic. Otherwise we allow the pending RVH to send |
| 122 // the navigation request to its renderer. | 122 // the navigation request to its renderer. |
| 123 // - ResourceDispatcherHost receives a ResourceRequest on the IO thread for the | 123 // - ResourceDispatcherHost receives a ResourceRequest on the IO thread for the |
| 124 // main resource load on the pending RVH. It checks CrossSiteRequestManager | 124 // main resource load on the pending RVH. It creates a |
| 125 // to see that it is a cross-site request, and installs a | 125 // CrossSiteResourceHandler to check whether a process swap is needed when |
| 126 // CrossSiteResourceHandler. | 126 // the request is ready to commit. |
| 127 // - When RDH receives a response, the BufferedResourceHandler determines | 127 // - When RDH receives a response, the BufferedResourceHandler determines |
| 128 // whether it is a download. If so, it sends a message to the new renderer | 128 // whether it is a download. If so, it sends a message to the new renderer |
| 129 // causing it to cancel the request, and the download proceeds. For now, the | 129 // causing it to cancel the request, and the download proceeds. For now, the |
| 130 // pending RVH remains until the next DidNavigate event for this | 130 // pending RVH remains until the next DidNavigate event for this |
| 131 // WebContentsImpl. This isn't ideal, but it doesn't affect any functionality. | 131 // WebContentsImpl. This isn't ideal, but it doesn't affect any functionality. |
| 132 // - After RDH receives a response and determines that it is safe and not a | 132 // - After RDH receives a response and determines that it is safe and not a |
| 133 // download, it pauses the response to first run the old page's onunload | 133 // download, the CrossSiteResourceHandler checks whether a process swap is |
| 134 // handler. It does this by asynchronously calling the OnCrossSiteResponse | 134 // needed (either because CrossSiteRequestManager has state for it or because |
| 135 // method of WebContentsImpl on the UI thread, which sends a SwapOut message | 135 // a transfer was needed for a redirect). |
| 136 // to the current RVH. | 136 // - If a swap is needed, CrossSiteResourceHandler pauses the response to first |
| 137 // - Once the onunload handler is finished, a SwapOut_ACK message is sent to | 137 // run the old page's unload handler. It does this by asynchronously calling |
| 138 // the ResourceDispatcherHost, who unpauses the response. Data is then sent | 138 // the OnCrossSiteResponse method of RenderViewHostManager on the UI thread, |
| 139 // to the pending RVH. | 139 // which sends a SwapOut message to the current RVH. |
| 140 // - Once the unload handler is finished, RVHM::SwappedOut checks if a transfer | |
| 141 // to a new process is needed, based on the stored pending_nav_params_. | |
|
Matt Perry
2013/06/18 22:58:51
This comment confuses me. In the previous bullet p
Charlie Reis
2013/06/19 00:17:01
Ah. A swap is needed if either we're doing a tran
| |
| 142 // - If not, it just tells the ResourceDispatcherHost to resume the response | |
| 143 // to its current RenderViewHost. | |
| 144 // - If so, it cancels the current pending RenderViewHost and sets up a new | |
| 145 // navigation using RequestTransferURL. When the transferred request | |
| 146 // arrives in the ResourceDispatcherHost, we transfer the response and | |
| 147 // resume it. | |
| 140 // - The pending renderer sends a FrameNavigate message that invokes the | 148 // - The pending renderer sends a FrameNavigate message that invokes the |
| 141 // DidNavigate method. This replaces the current RVH with the | 149 // DidNavigate method. This replaces the current RVH with the |
| 142 // pending RVH. | 150 // pending RVH. |
| 143 // - The previous renderer is kept swapped out in RenderViewHostManager in case | 151 // - The previous renderer is kept swapped out in RenderViewHostManager in case |
| 144 // the user goes back. The process only stays live if another tab is using | 152 // the user goes back. The process only stays live if another tab is using |
| 145 // it, but if so, the existing frame relationships will be maintained. | 153 // it, but if so, the existing frame relationships will be maintained. |
| 146 | 154 |
| 147 namespace content { | 155 namespace content { |
| 148 namespace { | 156 namespace { |
| 149 | 157 |
| (...skipping 3548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3698 } | 3706 } |
| 3699 | 3707 |
| 3700 BrowserPluginGuestManager* | 3708 BrowserPluginGuestManager* |
| 3701 WebContentsImpl::GetBrowserPluginGuestManager() const { | 3709 WebContentsImpl::GetBrowserPluginGuestManager() const { |
| 3702 return static_cast<BrowserPluginGuestManager*>( | 3710 return static_cast<BrowserPluginGuestManager*>( |
| 3703 GetBrowserContext()->GetUserData( | 3711 GetBrowserContext()->GetUserData( |
| 3704 browser_plugin::kBrowserPluginGuestManagerKeyName)); | 3712 browser_plugin::kBrowserPluginGuestManagerKeyName)); |
| 3705 } | 3713 } |
| 3706 | 3714 |
| 3707 } // namespace content | 3715 } // namespace content |
| OLD | NEW |