Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(729)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 15476003: Move TransferNavigationResourceThrottle into CrossSiteResourceHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Get tests to pass Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h" 101 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h"
102 #endif 102 #endif
103 103
104 // Cross-Site Navigations 104 // Cross-Site Navigations
105 // 105 //
106 // If a WebContentsImpl is told to navigate to a different web site (as 106 // If a WebContentsImpl is told to navigate to a different web site (as
107 // determined by SiteInstance), it will replace its current RenderViewHost with 107 // determined by SiteInstance), it will replace its current RenderViewHost with
108 // a new RenderViewHost dedicated to the new SiteInstance. This works as 108 // a new RenderViewHost dedicated to the new SiteInstance. This works as
109 // follows: 109 // follows:
110 // 110 //
111 // - Navigate determines whether the destination is cross-site, and if so, 111 // - RVHM::Navigate determines whether the destination is cross-site, and if so,
112 // it creates a pending_render_view_host_. 112 // it creates a pending_render_view_host_.
113 // - The pending RVH is "suspended," so that no navigation messages are sent to 113 // - The pending RVH is "suspended," so that no navigation messages are sent to
114 // its renderer until the onbeforeunload JavaScript handler has a chance to 114 // its renderer until the beforeunload JavaScript handler has a chance to
115 // run in the current RVH. 115 // run in the current RVH.
116 // - The pending RVH tells CrossSiteRequestManager (a thread-safe singleton) 116 // - The pending RVH tells CrossSiteRequestManager (a thread-safe singleton)
117 // that it has a pending cross-site request. ResourceDispatcherHost will 117 // that it has a pending cross-site request. We will check this on the IO
118 // check for this when the response arrives. 118 // thread when deciding how to handle the response.
119 // - The current RVH runs its onbeforeunload handler. If it returns false, we 119 // - The current RVH runs its beforeunload handler. If it returns false, we
120 // cancel all the pending logic. Otherwise we allow the pending RVH to send 120 // cancel all the pending logic. Otherwise we allow the pending RVH to send
121 // the navigation request to its renderer. 121 // the navigation request to its renderer.
122 // - ResourceDispatcherHost receives a ResourceRequest on the IO thread for the 122 // - ResourceDispatcherHost receives a ResourceRequest on the IO thread for the
123 // main resource load on the pending RVH. It checks CrossSiteRequestManager 123 // main resource load on the pending RVH. It creates a
124 // to see that it is a cross-site request, and installs a 124 // CrossSiteResourceHandler to check whether a process swap is needed when
125 // CrossSiteResourceHandler. 125 // the request is ready to commit.
126 // - When RDH receives a response, the BufferedResourceHandler determines 126 // - When RDH receives a response, the BufferedResourceHandler determines
127 // whether it is a download. If so, it sends a message to the new renderer 127 // whether it is a download. If so, it sends a message to the new renderer
128 // causing it to cancel the request, and the download proceeds. For now, the 128 // causing it to cancel the request, and the download proceeds. For now, the
129 // pending RVH remains until the next DidNavigate event for this 129 // pending RVH remains until the next DidNavigate event for this
130 // WebContentsImpl. This isn't ideal, but it doesn't affect any functionality. 130 // WebContentsImpl. This isn't ideal, but it doesn't affect any functionality.
131 // - After RDH receives a response and determines that it is safe and not a 131 // - After RDH receives a response and determines that it is safe and not a
132 // download, it pauses the response to first run the old page's onunload 132 // download, the CrossSiteResourceHandler checks whether a process swap is
133 // handler. It does this by asynchronously calling the OnCrossSiteResponse 133 // needed (either because CrossSiteRequestManager has state for it or because
134 // method of WebContentsImpl on the UI thread, which sends a SwapOut message 134 // a transfer was needed for a redirect).
135 // to the current RVH. 135 // - If so, CrossSiteResourceHandler pauses the response to first run the old
136 // - Once the onunload handler is finished, a SwapOut_ACK message is sent to 136 // page's unload handler. It does this by asynchronously calling the
137 // the ResourceDispatcherHost, who unpauses the response. Data is then sent 137 // OnCrossSiteResponse method of RenderViewHostManager on the UI thread, which
138 // to the pending RVH. 138 // sends a SwapOut message to the current RVH.
139 // - Once the unload handler is finished, RVHM::SwappedOut checks if a transfer
140 // to a new process is needed, based on the stored pending_nav_params_. (This
141 // is independent of whether we started out with a cross-process navigation.)
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.
139 // - The pending renderer sends a FrameNavigate message that invokes the 148 // - The pending renderer sends a FrameNavigate message that invokes the
140 // DidNavigate method. This replaces the current RVH with the 149 // DidNavigate method. This replaces the current RVH with the
141 // pending RVH. 150 // pending RVH.
142 // - The previous renderer is kept swapped out in RenderViewHostManager in case 151 // - The previous renderer is kept swapped out in RenderViewHostManager in case
143 // 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
144 // it, but if so, the existing frame relationships will be maintained. 153 // it, but if so, the existing frame relationships will be maintained.
145 154
146 namespace content { 155 namespace content {
147 namespace { 156 namespace {
148 157
(...skipping 3535 matching lines...) Expand 10 before | Expand all | Expand 10 after
3684 } 3693 }
3685 3694
3686 BrowserPluginGuestManager* 3695 BrowserPluginGuestManager*
3687 WebContentsImpl::GetBrowserPluginGuestManager() const { 3696 WebContentsImpl::GetBrowserPluginGuestManager() const {
3688 return static_cast<BrowserPluginGuestManager*>( 3697 return static_cast<BrowserPluginGuestManager*>(
3689 GetBrowserContext()->GetUserData( 3698 GetBrowserContext()->GetUserData(
3690 browser_plugin::kBrowserPluginGuestManagerKeyName)); 3699 browser_plugin::kBrowserPluginGuestManagerKeyName));
3691 } 3700 }
3692 3701
3693 } // namespace content 3702 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698