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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: Adding a DCHECK to probably make a lot of tests fail. Created 3 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 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/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 2594 matching lines...) Expand 10 before | Expand all | Expand 10 after
2605 // PlzNavigate 2605 // PlzNavigate
2606 void RenderFrameHostImpl::CommitNavigation( 2606 void RenderFrameHostImpl::CommitNavigation(
2607 ResourceResponse* response, 2607 ResourceResponse* response,
2608 std::unique_ptr<StreamHandle> body, 2608 std::unique_ptr<StreamHandle> body,
2609 const CommonNavigationParams& common_params, 2609 const CommonNavigationParams& common_params,
2610 const RequestNavigationParams& request_params, 2610 const RequestNavigationParams& request_params,
2611 bool is_view_source) { 2611 bool is_view_source) {
2612 DCHECK((response && body.get()) || 2612 DCHECK((response && body.get()) ||
2613 common_params.url.SchemeIs(url::kDataScheme) || 2613 common_params.url.SchemeIs(url::kDataScheme) ||
2614 !ShouldMakeNetworkRequestForURL(common_params.url) || 2614 !ShouldMakeNetworkRequestForURL(common_params.url) ||
2615 request_params.is_same_document_fragment_change ||
2616 request_params.is_same_document_history_load ||
2615 IsRendererDebugURL(common_params.url)); 2617 IsRendererDebugURL(common_params.url));
2616 UpdatePermissionsForNavigation(common_params, request_params); 2618 UpdatePermissionsForNavigation(common_params, request_params);
2617 2619
2618 // Get back to a clean state, in case we start a new navigation without 2620 // Get back to a clean state, in case we start a new navigation without
2619 // completing an unload handler. 2621 // completing an unload handler.
2620 ResetWaitingState(); 2622 ResetWaitingState();
2621 2623
2622 // The renderer can exit view source mode when any error or cancellation 2624 // The renderer can exit view source mode when any error or cancellation
2623 // happen. When reusing the same renderer, overwrite to recover the mode. 2625 // happen. When reusing the same renderer, overwrite to recover the mode.
2624 if (is_view_source && 2626 if (is_view_source &&
2625 this == frame_tree_node_->render_manager()->current_frame_host()) { 2627 this == frame_tree_node_->render_manager()->current_frame_host()) {
2626 DCHECK(!GetParent()); 2628 DCHECK(!GetParent());
2627 render_view_host()->Send(new FrameMsg_EnableViewSourceMode(routing_id_)); 2629 render_view_host()->Send(new FrameMsg_EnableViewSourceMode(routing_id_));
2628 } 2630 }
2629 2631
2630 const GURL body_url = body.get() ? body->GetURL() : GURL(); 2632 const GURL body_url = body.get() ? body->GetURL() : GURL();
2631 const ResourceResponseHead head = response ? 2633 const ResourceResponseHead head = response ?
2632 response->head : ResourceResponseHead(); 2634 response->head : ResourceResponseHead();
2633 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, 2635 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params,
2634 request_params)); 2636 request_params));
2635 2637
2636 // If a network request was made, update the Previews state. 2638 // If a network request was made, update the LoFi state.
nasko 2017/01/13 19:36:57 nit: Why change Preview back to LoFi? This is chan
arthursonzogni 2017/01/17 15:24:47 Thanks! I missed this line when resolving merge co
2637 if (ShouldMakeNetworkRequestForURL(common_params.url)) 2639 if (ShouldMakeNetworkRequestForURL(common_params.url) &&
2640 !request_params.is_same_document_fragment_change &&
2641 !request_params.is_same_document_history_load) {
2638 last_navigation_previews_state_ = common_params.previews_state; 2642 last_navigation_previews_state_ = common_params.previews_state;
2643 }
2639 2644
2640 // TODO(clamy): Release the stream handle once the renderer has finished 2645 // TODO(clamy): Release the stream handle once the renderer has finished
2641 // reading it. 2646 // reading it.
2642 stream_handle_ = std::move(body); 2647 stream_handle_ = std::move(body);
2643 2648
2644 // When navigating to a debug url, no commit is expected from the 2649 // When navigating to a debug url, no commit is expected from the
2645 // RenderFrameHost, nor should the throbber start. The NavigationRequest is 2650 // RenderFrameHost, nor should the throbber start. The NavigationRequest is
2646 // also not stored in the FrameTreeNode. Therefore do not reset it, as this 2651 // also not stored in the FrameTreeNode. Therefore do not reset it, as this
2647 // could cancel an existing pending navigation. 2652 // could cancel an existing pending navigation.
2648 if (!IsRendererDebugURL(common_params.url)) { 2653 if (!IsRendererDebugURL(common_params.url)) {
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
3303 } 3308 }
3304 3309
3305 void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() { 3310 void RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError() {
3306 DCHECK(media_interface_proxy_); 3311 DCHECK(media_interface_proxy_);
3307 media_interface_proxy_.reset(); 3312 media_interface_proxy_.reset();
3308 } 3313 }
3309 3314
3310 std::unique_ptr<NavigationHandleImpl> 3315 std::unique_ptr<NavigationHandleImpl>
3311 RenderFrameHostImpl::TakeNavigationHandleForCommit( 3316 RenderFrameHostImpl::TakeNavigationHandleForCommit(
3312 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 3317 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
3318 bool is_browser_initiated = (params.nav_entry_id != 0);
3319
3313 // If this is a same-page navigation, there isn't an existing NavigationHandle 3320 // If this is a same-page navigation, there isn't an existing NavigationHandle
3314 // to use for the navigation. Create one, but don't reset any NavigationHandle 3321 // to use for the navigation. Create one, but don't reset any NavigationHandle
3315 // tracking an ongoing navigation, since this may lead to the cancellation of 3322 // tracking an ongoing navigation, since this may lead to the cancellation of
3316 // the navigation. 3323 // the navigation.
3324 // PlzNavigate: This doesn't apply for browser-initiated same-page navigation,
3325 // because a NavigationHandle is created.
nasko 2017/01/13 19:36:57 I'm not sure I can follow this comment well. Did y
arthursonzogni 2017/01/17 15:24:47 Yes.
3317 if (params.was_within_same_page) { 3326 if (params.was_within_same_page) {
3327 if (IsBrowserSideNavigationEnabled() && is_browser_initiated &&
3328 navigation_handle_ && navigation_handle_->IsSamePage() &&
3329 navigation_handle_->GetURL() == params.url) {
3330 return std::move(navigation_handle_);
3331 }
3332
3318 // We don't ever expect navigation_handle_ to match, because handles are not 3333 // We don't ever expect navigation_handle_ to match, because handles are not
3319 // created for same-page navigations. 3334 // created for same-page navigations.
nasko 2017/01/13 19:36:57 This comment seems to contradict the new comment a
arthursonzogni 2017/01/17 15:24:48 Okay, I will try to move/rephrase comments.
nasko 2017/01/19 00:43:35 This is awesome! Thanks for the changes, it is muc
3320 DCHECK(!navigation_handle_ || !navigation_handle_->IsSamePage()); 3335 DCHECK(IsBrowserSideNavigationEnabled() || !navigation_handle_ ||
3336 !navigation_handle_->IsSamePage());
3321 3337
3322 // First, determine if the navigation corresponds to the pending navigation 3338 // First, determine if the navigation corresponds to the pending navigation
3323 // entry. This is the case for a browser-initiated same-page navigation, 3339 // entry. This is the case for a browser-initiated same-page navigation,
3324 // which does not cause a NavigationHandle to be created because it does not 3340 // which does not cause a NavigationHandle to be created because it does not
3325 // go through DidStartProvisionalLoad. 3341 // go through DidStartProvisionalLoad.
3326 bool is_renderer_initiated = true; 3342 bool is_renderer_initiated = true;
3327 int pending_nav_entry_id = 0; 3343 int pending_nav_entry_id = 0;
3328 NavigationEntryImpl* pending_entry = 3344 NavigationEntryImpl* pending_entry =
3329 NavigationEntryImpl::FromNavigationEntry( 3345 NavigationEntryImpl::FromNavigationEntry(
3330 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); 3346 frame_tree_node()->navigator()->GetController()->GetPendingEntry());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3385 // There is no pending NavigationEntry in these cases, so pass 0 as the 3401 // There is no pending NavigationEntry in these cases, so pass 0 as the
3386 // pending_nav_entry_id. If the previous handle was a prematurely aborted 3402 // pending_nav_entry_id. If the previous handle was a prematurely aborted
3387 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. 3403 // navigation loaded via LoadDataWithBaseURL, propagate the entry id.
3388 return NavigationHandleImpl::Create( 3404 return NavigationHandleImpl::Create(
3389 params.url, frame_tree_node_, is_renderer_initiated, 3405 params.url, frame_tree_node_, is_renderer_initiated,
3390 params.was_within_same_page, base::TimeTicks::Now(), 3406 params.was_within_same_page, base::TimeTicks::Now(),
3391 entry_id_for_data_nav, false); // started_from_context_menu 3407 entry_id_for_data_nav, false); // started_from_context_menu
3392 } 3408 }
3393 3409
3394 } // namespace content 3410 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698