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

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: Addressed CR comments, mostly -- but not all -- nits. 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());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 221
221 void TestWebContents::TestDidFailLoadWithError( 222 void TestWebContents::TestDidFailLoadWithError(
222 const GURL& url, 223 const GURL& url,
223 int error_code, 224 int error_code,
224 const base::string16& error_description) { 225 const base::string16& error_description) {
225 FrameHostMsg_DidFailLoadWithError msg( 226 FrameHostMsg_DidFailLoadWithError msg(
226 0, url, error_code, error_description); 227 0, url, error_code, error_description);
227 frame_tree_.root()->current_frame_host()->OnMessageReceived(msg); 228 frame_tree_.root()->current_frame_host()->OnMessageReceived(msg);
228 } 229 }
229 230
231 TestRenderFrameHost* TestWebContents::GetFutureMainFrame() const {
232 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
233 switches::kEnableBrowserSideNavigation)) {
234 return static_cast<TestRenderFrameHost*>(
235 GetRenderManager()->speculative_render_frame_host_.get());
236 }
237 return GetPendingMainFrame();
238 }
239
230 void TestWebContents::CreateNewWindow( 240 void TestWebContents::CreateNewWindow(
231 int render_process_id, 241 int render_process_id,
232 int route_id, 242 int route_id,
233 int main_frame_route_id, 243 int main_frame_route_id,
234 const ViewHostMsg_CreateWindow_Params& params, 244 const ViewHostMsg_CreateWindow_Params& params,
235 SessionStorageNamespace* session_storage_namespace) { 245 SessionStorageNamespace* session_storage_namespace) {
236 } 246 }
237 247
238 void TestWebContents::CreateNewWidget(int render_process_id, 248 void TestWebContents::CreateNewWidget(int render_process_id,
239 int route_id, 249 int route_id,
(...skipping 11 matching lines...) Expand all
251 } 261 }
252 262
253 void TestWebContents::ShowCreatedWidget(int route_id, 263 void TestWebContents::ShowCreatedWidget(int route_id,
254 const gfx::Rect& initial_pos) { 264 const gfx::Rect& initial_pos) {
255 } 265 }
256 266
257 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { 267 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) {
258 } 268 }
259 269
260 } // namespace content 270 } // namespace content
OLDNEW
« content/browser/frame_host/render_frame_host_manager.cc ('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