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

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

Issue 1048463004: PlzNavigate: track pending commits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed other occurences of main_test_rfh Created 5 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_render_frame_host.h" 5 #include "content/test/test_render_frame_host.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/browser/frame_host/frame_tree.h" 8 #include "content/browser/frame_host/frame_tree.h"
9 #include "content/browser/frame_host/navigation_request.h" 9 #include "content/browser/frame_host/navigation_request.h"
10 #include "content/browser/frame_host/navigator.h" 10 #include "content/browser/frame_host/navigator.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 params.page_state = PageState::CreateForTesting( 197 params.page_state = PageState::CreateForTesting(
198 url, 198 url,
199 false, 199 false,
200 file_path_for_history_item ? "data" : NULL, 200 file_path_for_history_item ? "data" : NULL,
201 file_path_for_history_item); 201 file_path_for_history_item);
202 202
203 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), params); 203 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), params);
204 OnDidCommitProvisionalLoad(msg); 204 OnDidCommitProvisionalLoad(msg);
205 } 205 }
206 206
207 void TestRenderFrameHost::NavigateAndCommitRendererInitiated(int page_id,
208 const GURL& url) {
209 SendRendererInitiatedNavigationRequest(url, false);
210 PrepareForCommit();
211 SendNavigate(page_id, url);
212 }
213
207 void TestRenderFrameHost::SendRendererInitiatedNavigationRequest( 214 void TestRenderFrameHost::SendRendererInitiatedNavigationRequest(
208 const GURL& url, 215 const GURL& url,
209 bool has_user_gesture) { 216 bool has_user_gesture) {
210 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 217 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
211 switches::kEnableBrowserSideNavigation)) { 218 switches::kEnableBrowserSideNavigation)) {
212 BeginNavigationParams begin_params("GET", std::string(), net::LOAD_NORMAL, 219 BeginNavigationParams begin_params("GET", std::string(), net::LOAD_NORMAL,
213 has_user_gesture); 220 has_user_gesture);
214 CommonNavigationParams common_params; 221 CommonNavigationParams common_params;
215 common_params.url = url; 222 common_params.url = url;
216 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); 223 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault);
217 common_params.transition = ui::PAGE_TRANSITION_LINK; 224 common_params.transition = ui::PAGE_TRANSITION_LINK;
218 OnBeginNavigation(common_params, begin_params, 225 OnBeginNavigation(common_params, begin_params,
219 scoped_refptr<ResourceRequestBody>()); 226 scoped_refptr<ResourceRequestBody>());
220 } 227 }
221 } 228 }
222 229
223 void TestRenderFrameHost::DidDisownOpener() { 230 void TestRenderFrameHost::DidDisownOpener() {
224 OnDidDisownOpener(); 231 OnDidDisownOpener();
225 } 232 }
226 233
227 void TestRenderFrameHost::PrepareForCommit() { 234 void TestRenderFrameHost::PrepareForCommit() {
228 PrepareForCommitWithServerRedirect(GURL()); 235 PrepareForCommitWithServerRedirect(GURL());
229 } 236 }
230 237
231 void TestRenderFrameHost::PrepareForCommitWithServerRedirect( 238 void TestRenderFrameHost::PrepareForCommitWithServerRedirect(
232 const GURL& redirect_url) { 239 const GURL& redirect_url) {
233 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 240 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
234 switches::kEnableBrowserSideNavigation)) { 241 switches::kEnableBrowserSideNavigation)) {
235 // Non PlzNavigate 242 // Non PlzNavigate
236 SendBeforeUnloadACK(true); 243 if (IsWaitingForBeforeUnloadACK())
244 SendBeforeUnloadACK(true);
237 return; 245 return;
238 } 246 }
239 247
240 // PlzNavigate 248 // PlzNavigate
241 NavigationRequest* request = frame_tree_node_->navigation_request(); 249 NavigationRequest* request = frame_tree_node_->navigation_request();
242 CHECK(request); 250 CHECK(request);
243 251
244 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for 252 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for
245 // it. If it runs it will update the request state. 253 // it. If it runs it will update the request state.
246 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) 254 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE)
(...skipping 17 matching lines...) Expand all
264 url_loader->SimulateServerRedirect(redirect_url); 272 url_loader->SimulateServerRedirect(redirect_url);
265 273
266 // Simulate the network stack commit. 274 // Simulate the network stack commit.
267 scoped_refptr<ResourceResponse> response(new ResourceResponse); 275 scoped_refptr<ResourceResponse> response(new ResourceResponse);
268 // TODO(carlosk): ideally with PlzNavigate it should be possible someday to 276 // TODO(carlosk): ideally with PlzNavigate it should be possible someday to
269 // fully commit the navigation at this call to CallOnResponseStarted. 277 // fully commit the navigation at this call to CallOnResponseStarted.
270 url_loader->CallOnResponseStarted(response, MakeEmptyStream()); 278 url_loader->CallOnResponseStarted(response, MakeEmptyStream());
271 } 279 }
272 280
273 } // namespace content 281 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698