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

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

Issue 2381503003: PlzNav: Fix NavigationControllerBrowserTest.EnsureSamePageNavigationUpdatesFrameNaviga… (Closed)
Patch Set: improve test (3) Created 4 years, 2 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/navigator_impl.h" 5 #include "content/browser/frame_host/navigator_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "net/base/net_errors.h" 48 #include "net/base/net_errors.h"
49 #include "url/gurl.h" 49 #include "url/gurl.h"
50 #include "url/url_constants.h" 50 #include "url/url_constants.h"
51 51
52 namespace content { 52 namespace content {
53 53
54 namespace { 54 namespace {
55 55
56 FrameMsg_Navigate_Type::Value GetNavigationType( 56 FrameMsg_Navigate_Type::Value GetNavigationType(
57 BrowserContext* browser_context, 57 BrowserContext* browser_context,
58 const FrameTreeNode* frame_tree_node,
58 const NavigationEntryImpl& entry, 59 const NavigationEntryImpl& entry,
59 ReloadType reload_type) { 60 ReloadType reload_type,
61 bool is_same_document_history_load) {
60 switch (reload_type) { 62 switch (reload_type) {
61 case ReloadType::NORMAL: 63 case ReloadType::NORMAL:
62 return FrameMsg_Navigate_Type::RELOAD; 64 return FrameMsg_Navigate_Type::RELOAD;
63 case ReloadType::MAIN_RESOURCE: 65 case ReloadType::MAIN_RESOURCE:
64 return FrameMsg_Navigate_Type::RELOAD_MAIN_RESOURCE; 66 return FrameMsg_Navigate_Type::RELOAD_MAIN_RESOURCE;
65 case ReloadType::BYPASSING_CACHE: 67 case ReloadType::BYPASSING_CACHE:
66 case ReloadType::DISABLE_LOFI_MODE: 68 case ReloadType::DISABLE_LOFI_MODE:
67 return FrameMsg_Navigate_Type::RELOAD_BYPASSING_CACHE; 69 return FrameMsg_Navigate_Type::RELOAD_BYPASSING_CACHE;
68 case ReloadType::ORIGINAL_REQUEST_URL: 70 case ReloadType::ORIGINAL_REQUEST_URL:
69 return FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; 71 return FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL;
70 case ReloadType::NONE: 72 case ReloadType::NONE:
71 break; // Fall through to rest of function. 73 break; // Fall through to rest of function.
72 } 74 }
73 75
74 // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates 76 // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates
75 // between |RESTORE_WITH_POST| and |RESTORE|. 77 // between |RESTORE_WITH_POST| and |RESTORE|.
76 if (entry.restore_type() == RestoreType::LAST_SESSION_EXITED_CLEANLY) { 78 if (entry.restore_type() == RestoreType::LAST_SESSION_EXITED_CLEANLY) {
77 if (entry.GetHasPostData()) 79 if (entry.GetHasPostData())
78 return FrameMsg_Navigate_Type::RESTORE_WITH_POST; 80 return FrameMsg_Navigate_Type::RESTORE_WITH_POST;
79 return FrameMsg_Navigate_Type::RESTORE; 81 return FrameMsg_Navigate_Type::RESTORE;
80 } 82 }
81 83
84 // A normal load of the current URL should be treated as a reload.
85 if (frame_tree_node->current_url() == entry.GetURL() &&
clamy 2016/10/12 11:28:32 Sanity check: this is only called for browser-init
86 entry.GetHistoryURLForDataURL().is_empty() && !entry.GetHasPostData() &&
87 !is_same_document_history_load) {
88 return FrameMsg_Navigate_Type::RELOAD_MAIN_RESOURCE;
Charlie Reis 2016/10/15 00:00:49 I'm curious, does this list of conditions correspo
89 }
90
82 return FrameMsg_Navigate_Type::NORMAL; 91 return FrameMsg_Navigate_Type::NORMAL;
83 } 92 }
84 93
85 } // namespace 94 } // namespace
86 95
87 struct NavigatorImpl::NavigationMetricsData { 96 struct NavigatorImpl::NavigationMetricsData {
88 NavigationMetricsData(base::TimeTicks start_time, 97 NavigationMetricsData(base::TimeTicks start_time,
89 GURL url, 98 GURL url,
90 RestoreType restore_type) 99 RestoreType restore_type)
91 : start_time_(start_time), url_(url) { 100 : start_time_(start_time), url_(url) {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 // which began in the chosen RenderFrameHost, since the request has already 393 // which began in the chosen RenderFrameHost, since the request has already
385 // been issued. In that case, simply resume the response. 394 // been issued. In that case, simply resume the response.
386 bool is_transfer_to_same = 395 bool is_transfer_to_same =
387 is_transfer && 396 is_transfer &&
388 entry.transferred_global_request_id().child_id == 397 entry.transferred_global_request_id().child_id ==
389 dest_render_frame_host->GetProcess()->GetID(); 398 dest_render_frame_host->GetProcess()->GetID();
390 if (!is_transfer_to_same) { 399 if (!is_transfer_to_same) {
391 navigation_data_.reset(new NavigationMetricsData( 400 navigation_data_.reset(new NavigationMetricsData(
392 navigation_start, dest_url, entry.restore_type())); 401 navigation_start, dest_url, entry.restore_type()));
393 // Create the navigation parameters. 402 // Create the navigation parameters.
394 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( 403 FrameMsg_Navigate_Type::Value navigation_type =
395 controller_->GetBrowserContext(), entry, reload_type); 404 GetNavigationType(controller_->GetBrowserContext(), frame_tree_node,
405 entry, reload_type, is_same_document_history_load);
396 dest_render_frame_host->Navigate( 406 dest_render_frame_host->Navigate(
397 entry.ConstructCommonNavigationParams( 407 entry.ConstructCommonNavigationParams(
398 frame_entry, post_body, dest_url, dest_referrer, navigation_type, 408 frame_entry, post_body, dest_url, dest_referrer, navigation_type,
399 lofi_state, navigation_start), 409 lofi_state, navigation_start),
400 entry.ConstructStartNavigationParams(), 410 entry.ConstructStartNavigationParams(),
401 entry.ConstructRequestNavigationParams( 411 entry.ConstructRequestNavigationParams(
402 frame_entry, is_same_document_history_load, 412 frame_entry, is_same_document_history_load,
403 is_history_navigation_in_new_child, 413 is_history_navigation_in_new_child,
404 entry.GetSubframeUniqueNames(frame_tree_node), 414 entry.GetSubframeUniqueNames(frame_tree_node),
405 frame_tree_node->has_committed_real_load(), 415 frame_tree_node->has_committed_real_load(),
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 bool is_history_navigation_in_new_child, 1100 bool is_history_navigation_in_new_child,
1091 base::TimeTicks navigation_start) { 1101 base::TimeTicks navigation_start) {
1092 CHECK(IsBrowserSideNavigationEnabled()); 1102 CHECK(IsBrowserSideNavigationEnabled());
1093 DCHECK(frame_tree_node); 1103 DCHECK(frame_tree_node);
1094 1104
1095 // This value must be set here because creating a NavigationRequest might 1105 // This value must be set here because creating a NavigationRequest might
1096 // change the renderer live/non-live status and change this result. 1106 // change the renderer live/non-live status and change this result.
1097 bool should_dispatch_beforeunload = 1107 bool should_dispatch_beforeunload =
1098 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); 1108 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload();
1099 FrameMsg_Navigate_Type::Value navigation_type = 1109 FrameMsg_Navigate_Type::Value navigation_type =
1100 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); 1110 GetNavigationType(controller_->GetBrowserContext(), frame_tree_node,
1111 entry, reload_type, is_same_document_history_load);
1101 std::unique_ptr<NavigationRequest> scoped_request = 1112 std::unique_ptr<NavigationRequest> scoped_request =
1102 NavigationRequest::CreateBrowserInitiated( 1113 NavigationRequest::CreateBrowserInitiated(
1103 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, 1114 frame_tree_node, dest_url, dest_referrer, frame_entry, entry,
1104 navigation_type, lofi_state, is_same_document_history_load, 1115 navigation_type, lofi_state, is_same_document_history_load,
1105 is_history_navigation_in_new_child, navigation_start, controller_); 1116 is_history_navigation_in_new_child, navigation_start, controller_);
1106 NavigationRequest* navigation_request = scoped_request.get(); 1117 NavigationRequest* navigation_request = scoped_request.get();
1107 1118
1108 // Navigation to a javascript URL is not a "real" navigation so there is no 1119 // Navigation to a javascript URL is not a "real" navigation so there is no
1109 // need to create a NavigationHandle. The navigation commits immediately and 1120 // need to create a NavigationHandle. The navigation commits immediately and
1110 // the NavigationRequest is not assigned to the FrameTreeNode as navigating to 1121 // the NavigationRequest is not assigned to the FrameTreeNode as navigating to
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 if (navigation_handle) 1240 if (navigation_handle)
1230 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); 1241 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID());
1231 1242
1232 controller_->SetPendingEntry(std::move(entry)); 1243 controller_->SetPendingEntry(std::move(entry));
1233 if (delegate_) 1244 if (delegate_)
1234 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 1245 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
1235 } 1246 }
1236 } 1247 }
1237 1248
1238 } // namespace content 1249 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698