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

Side by Side Diff: content/test/test_web_contents.cc

Issue 701953006: PlzNavigate: Speculatively spawns a renderer process for navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed missing references to |base| namespace. Created 5 years, 11 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/test/test_web_contents.h" 5 #include "content/test/test_web_contents.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 "content/browser/browser_url_handler_impl.h" 10 #include "content/browser/browser_url_handler_impl.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 TestRenderFrameHost* old_rfh = GetMainFrame(); 147 TestRenderFrameHost* old_rfh = GetMainFrame();
148 const NavigationEntry* entry = GetController().GetPendingEntry(); 148 const NavigationEntry* entry = GetController().GetPendingEntry();
149 DCHECK(entry); 149 DCHECK(entry);
150 150
151 // Simulate the BeforeUnload ACK if necessary. 151 // Simulate the BeforeUnload ACK if necessary.
152 // PlzNavigate: the pending RFH is not created before the navigation commit, 152 // PlzNavigate: the pending RFH is not created before the navigation commit,
153 // so it is necessary to simulate the IO thread response here to commit in the 153 // so it is necessary to simulate the IO thread response here to commit in the
154 // proper renderer. 154 // proper renderer.
155 old_rfh->PrepareForCommit(entry->GetURL()); 155 old_rfh->PrepareForCommit(entry->GetURL());
156 156
157 TestRenderFrameHost* rfh = GetPendingMainFrame(); 157 TestRenderFrameHost* rfh = GetFutureMainFrame();
158
158 if (!rfh) 159 if (!rfh)
159 rfh = old_rfh; 160 rfh = old_rfh;
160 161
161 int page_id = entry->GetPageID(); 162 int page_id = entry->GetPageID();
162 if (page_id == -1) { 163 if (page_id == -1) {
163 // It's a new navigation, assign a never-seen page id to it. 164 // It's a new navigation, assign a never-seen page id to it.
164 page_id = GetMaxPageIDForSiteInstance(rfh->GetSiteInstance()) + 1; 165 page_id = GetMaxPageIDForSiteInstance(rfh->GetSiteInstance()) + 1;
165 } 166 }
166 167
167 rfh->SendNavigate(page_id, entry->GetURL()); 168 rfh->SendNavigate(page_id, entry->GetURL());
168 // Simulate the SwapOut_ACK. This is needed when cross-site navigation 169 // Simulate the SwapOut_ACK. This is needed when cross-site navigation
169 // happens. 170 // happens.
170 if (old_rfh != rfh) 171 if (old_rfh != rfh)
171 old_rfh->OnSwappedOut(); 172 old_rfh->OnSwappedOut();
172 } 173 }
173 174
174 void TestWebContents::ProceedWithCrossSiteNavigation() { 175 void TestWebContents::ProceedWithCrossSiteNavigation() {
175 if (!GetPendingMainFrame()) 176 if (!GetPendingMainFrame() ||
clamy 2014/12/29 17:36:22 This return is no longer necessary, as following t
carlosk 2014/12/30 15:54:50 Done.
177 base::CommandLine::ForCurrentProcess()->HasSwitch(
178 switches::kEnableBrowserSideNavigation)) {
176 return; 179 return;
180 }
177 GetMainFrame()->SendBeforeUnloadACK(true); 181 GetMainFrame()->SendBeforeUnloadACK(true);
178 } 182 }
179 183
180 RenderViewHostDelegateView* TestWebContents::GetDelegateView() { 184 RenderViewHostDelegateView* TestWebContents::GetDelegateView() {
181 if (delegate_view_override_) 185 if (delegate_view_override_)
182 return delegate_view_override_; 186 return delegate_view_override_;
183 return WebContentsImpl::GetDelegateView(); 187 return WebContentsImpl::GetDelegateView();
184 } 188 }
185 189
186 void TestWebContents::SetOpener(TestWebContents* opener) { 190 void TestWebContents::SetOpener(TestWebContents* opener) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 bool user_gesture) { 254 bool user_gesture) {
251 } 255 }
252 256
253 void TestWebContents::ShowCreatedWidget(int route_id, 257 void TestWebContents::ShowCreatedWidget(int route_id,
254 const gfx::Rect& initial_pos) { 258 const gfx::Rect& initial_pos) {
255 } 259 }
256 260
257 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { 261 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) {
258 } 262 }
259 263
264 TestRenderFrameHost* TestWebContents::GetSpeculativeMainFrame() const {
265 return static_cast<TestRenderFrameHost*>(
266 GetRenderManager()->speculative_render_frame_host_.get());
267 }
268
269 TestRenderFrameHost* TestWebContents::GetFutureMainFrame() const {
270 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
271 switches::kEnableBrowserSideNavigation)) {
272 return GetSpeculativeMainFrame();
273 }
274 return GetPendingMainFrame();
275 }
276
260 } // namespace content 277 } // namespace content
OLDNEW
« content/test/test_web_contents.h ('K') | « content/test/test_web_contents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698