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

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

Issue 648563002: Revitalize (and move) a block comment about how cross-process navigation works. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@is_rfh_swapped
Patch Set: Created 6 years, 2 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
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 #include "content/browser/android/date_time_chooser_android.h" 108 #include "content/browser/android/date_time_chooser_android.h"
109 #include "content/browser/media/android/browser_media_player_manager.h" 109 #include "content/browser/media/android/browser_media_player_manager.h"
110 #include "content/browser/web_contents/web_contents_android.h" 110 #include "content/browser/web_contents/web_contents_android.h"
111 #include "content/public/browser/android/content_view_core.h" 111 #include "content/public/browser/android/content_view_core.h"
112 #endif 112 #endif
113 113
114 #if defined(OS_MACOSX) 114 #if defined(OS_MACOSX)
115 #include "base/mac/foundation_util.h" 115 #include "base/mac/foundation_util.h"
116 #endif 116 #endif
117 117
118 // Cross-Site Navigations
119 //
120 // If a WebContentsImpl is told to navigate to a different web site (as
121 // determined by SiteInstance), it will replace its current RenderViewHost with
122 // a new RenderViewHost dedicated to the new SiteInstance. This works as
123 // follows:
124 //
125 // - RVHM::Navigate determines whether the destination is cross-site, and if so,
126 // it creates a pending_render_view_host_.
127 // - The pending RVH is "suspended," so that no navigation messages are sent to
128 // its renderer until the beforeunload JavaScript handler has a chance to
129 // run in the current RVH.
130 // - The pending RVH tells CrossSiteRequestManager (a thread-safe singleton)
131 // that it has a pending cross-site request. We will check this on the IO
132 // thread when deciding how to handle the response.
133 // - The current RVH runs its beforeunload handler. If it returns false, we
134 // cancel all the pending logic. Otherwise we allow the pending RVH to send
135 // the navigation request to its renderer.
136 // - ResourceDispatcherHost receives a ResourceRequest on the IO thread for the
137 // main resource load on the pending RVH. It creates a
138 // CrossSiteResourceHandler to check whether a process swap is needed when
139 // the request is ready to commit.
140 // - When RDH receives a response, the BufferedResourceHandler determines
141 // whether it is a download. If so, it sends a message to the new renderer
142 // causing it to cancel the request, and the download proceeds. For now, the
143 // pending RVH remains until the next DidNavigate event for this
144 // WebContentsImpl. This isn't ideal, but it doesn't affect any functionality.
145 // - After RDH receives a response and determines that it is safe and not a
146 // download, the CrossSiteResourceHandler checks whether a process swap is
147 // needed (either because CrossSiteRequestManager has state for it or because
148 // a transfer was needed for a redirect).
149 // - If so, CrossSiteResourceHandler pauses the response to first run the old
150 // page's unload handler. It does this by asynchronously calling the
151 // OnCrossSiteResponse method of RenderFrameHostManager on the UI thread,
152 // which sends a SwapOut message to the current RVH.
153 // - Once the unload handler is finished, RVHM::SwappedOut checks if a transfer
154 // to a new process is needed, based on the stored pending_nav_params_. (This
155 // is independent of whether we started out with a cross-process navigation.)
156 // - If not, it just tells the ResourceDispatcherHost to resume the response
157 // to its current RenderViewHost.
158 // - If so, it cancels the current pending RenderViewHost and sets up a new
159 // navigation using RequestTransferURL. When the transferred request
160 // arrives in the ResourceDispatcherHost, we transfer the response and
161 // resume it.
162 // - The pending renderer sends a FrameNavigate message that invokes the
163 // DidNavigate method. This replaces the current RVH with the
164 // pending RVH.
165 // - The previous renderer is kept swapped out in RenderFrameHostManager in case
166 // the user goes back. The process only stays live if another tab is using
167 // it, but if so, the existing frame relationships will be maintained.
168
169 namespace content { 118 namespace content {
170 namespace { 119 namespace {
171 120
172 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; 121 const int kMinimumDelayBetweenLoadingUpdatesMS = 100;
173 122
174 // This matches what Blink's ProgressTracker has traditionally used for a 123 // This matches what Blink's ProgressTracker has traditionally used for a
175 // minimum progress value. 124 // minimum progress value.
176 const double kMinimumLoadingProgress = 0.1; 125 const double kMinimumLoadingProgress = 0.1;
177 126
178 const char kDotGoogleDotCom[] = ".google.com"; 127 const char kDotGoogleDotCom[] = ".google.com";
(...skipping 4194 matching lines...) Expand 10 before | Expand all | Expand 10 after
4373 node->render_manager()->ResumeResponseDeferredAtStart(); 4322 node->render_manager()->ResumeResponseDeferredAtStart();
4374 } 4323 }
4375 4324
4376 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4325 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4377 force_disable_overscroll_content_ = force_disable; 4326 force_disable_overscroll_content_ = force_disable;
4378 if (view_) 4327 if (view_)
4379 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4328 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4380 } 4329 }
4381 4330
4382 } // namespace content 4331 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698