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

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: Moved state tracking to 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 params.page_state = PageState::CreateForTesting( 193 params.page_state = PageState::CreateForTesting(
194 url, 194 url,
195 false, 195 false,
196 file_path_for_history_item ? "data" : NULL, 196 file_path_for_history_item ? "data" : NULL,
197 file_path_for_history_item); 197 file_path_for_history_item);
198 198
199 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), params); 199 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), params);
200 OnDidCommitProvisionalLoad(msg); 200 OnDidCommitProvisionalLoad(msg);
201 } 201 }
202 202
203 void TestRenderFrameHost::NavigateAndCommitRendererInitiated(int page_id,
204 const GURL& url) {
205 SendRendererInitiatedNavigationRequest(url, false);
206 PrepareForCommit();
207 SendNavigate(page_id, url);
208 }
209
203 void TestRenderFrameHost::SendRendererInitiatedNavigationRequest( 210 void TestRenderFrameHost::SendRendererInitiatedNavigationRequest(
204 const GURL& url, 211 const GURL& url,
205 bool has_user_gesture) { 212 bool has_user_gesture) {
206 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 213 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
207 switches::kEnableBrowserSideNavigation)) { 214 switches::kEnableBrowserSideNavigation)) {
208 BeginNavigationParams begin_params("GET", std::string(), net::LOAD_NORMAL, 215 BeginNavigationParams begin_params("GET", std::string(), net::LOAD_NORMAL,
209 has_user_gesture); 216 has_user_gesture);
210 CommonNavigationParams common_params; 217 CommonNavigationParams common_params;
211 common_params.url = url; 218 common_params.url = url;
212 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); 219 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault);
213 common_params.transition = ui::PAGE_TRANSITION_LINK; 220 common_params.transition = ui::PAGE_TRANSITION_LINK;
214 OnBeginNavigation(common_params, begin_params, 221 OnBeginNavigation(common_params, begin_params,
215 scoped_refptr<ResourceRequestBody>()); 222 scoped_refptr<ResourceRequestBody>());
216 } 223 }
217 } 224 }
218 225
219 void TestRenderFrameHost::DidDisownOpener() { 226 void TestRenderFrameHost::DidDisownOpener() {
220 OnDidDisownOpener(); 227 OnDidDisownOpener();
221 } 228 }
222 229
223 void TestRenderFrameHost::PrepareForCommit() { 230 void TestRenderFrameHost::PrepareForCommit() {
224 PrepareForCommitWithServerRedirect(GURL()); 231 PrepareForCommitWithServerRedirect(GURL());
225 } 232 }
226 233
227 void TestRenderFrameHost::PrepareForCommitWithServerRedirect( 234 void TestRenderFrameHost::PrepareForCommitWithServerRedirect(
228 const GURL& redirect_url) { 235 const GURL& redirect_url) {
229 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 236 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
230 switches::kEnableBrowserSideNavigation)) { 237 switches::kEnableBrowserSideNavigation)) {
231 // Non PlzNavigate 238 // Non PlzNavigate
232 SendBeforeUnloadACK(true); 239 if (IsWaitingForBeforeUnloadACK())
240 SendBeforeUnloadACK(true);
233 return; 241 return;
234 } 242 }
235 243
236 // PlzNavigate 244 // PlzNavigate
237 NavigationRequest* request = 245 NavigationRequest* request =
238 static_cast<NavigatorImpl*>(frame_tree_node_->navigator()) 246 static_cast<NavigatorImpl*>(frame_tree_node_->navigator())
239 ->GetNavigationRequestForNodeForTesting(frame_tree_node_); 247 ->GetNavigationRequestForNodeForTesting(frame_tree_node_);
240 CHECK(request); 248 CHECK(request);
241 249
242 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for 250 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for
(...skipping 19 matching lines...) Expand all
262 url_loader->SimulateServerRedirect(redirect_url); 270 url_loader->SimulateServerRedirect(redirect_url);
263 271
264 // Simulate the network stack commit. 272 // Simulate the network stack commit.
265 scoped_refptr<ResourceResponse> response(new ResourceResponse); 273 scoped_refptr<ResourceResponse> response(new ResourceResponse);
266 // TODO(carlosk): ideally with PlzNavigate it should be possible someday to 274 // TODO(carlosk): ideally with PlzNavigate it should be possible someday to
267 // fully commit the navigation at this call to CallOnResponseStarted. 275 // fully commit the navigation at this call to CallOnResponseStarted.
268 url_loader->CallOnResponseStarted(response, MakeEmptyStream()); 276 url_loader->CallOnResponseStarted(response, MakeEmptyStream());
269 } 277 }
270 278
271 } // namespace content 279 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698