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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 2103733004: Set navigationStart correctly for all load types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments, add more tests. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 4167222969def20c760b86eb6e739add6fd9986a..09c5e0d42a29debcf7b7e7064c6d52c68fe1660b 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -565,11 +565,8 @@ WebURLRequest CreateURLRequestForNavigation(
// clamping it to renderer_navigation_start, initialized earlier in the call
// stack.
base::TimeTicks SanitizeNavigationTiming(
- blink::WebFrameLoadType load_type,
const base::TimeTicks& browser_navigation_start,
const base::TimeTicks& renderer_navigation_start) {
- if (load_type != blink::WebFrameLoadType::Standard)
- return base::TimeTicks();
DCHECK(!browser_navigation_start.is_null());
base::TimeTicks navigation_start =
std::min(browser_navigation_start, renderer_navigation_start);
@@ -3670,6 +3667,21 @@ void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) {
}
}
+void RenderFrameImpl::didHandleOnBeforeUnloadEvent(bool eventListenerCalled) {
clamy 2016/06/29 11:15:26 In the case of a same-process navigation, the Befo
Alexander Semashko 2016/06/29 15:08:09 I thought somewhy that some other call path are po
clamy 2016/06/29 15:23:13 This changed around ~a month ago. The only other p
Alexander Semashko 2016/06/29 17:33:30 Because we use the browser-side timestamp only if
clamy 2016/06/30 09:59:49 I don't agree fully with this. Conceptually we hav
Alexander Semashko 2016/06/30 19:35:08 There is always an initial blank document created
+ // If there are pending navigation params, then the beforeunload event was
+ // caused by a same-process browser-initiated navigation, and the
+ // navigation_start was recorded before dispatching beforeunload, which means
+ // it should not be used, and the right timestamp is |Now|.
+ // If this is the first navigation in the frame, and the initial document did
+ // not have a beforeunload handler, then it is likely a cross-process
+ // navigation, and the browser timestamp is the right one.
+ if (pending_navigation_params_ &&
+ (eventListenerCalled || !current_history_item_.isNull())) {
+ pending_navigation_params_->common_params.navigation_start =
+ base::TimeTicks::Now();
+ }
+}
+
void RenderFrameImpl::didFailLoad(blink::WebLocalFrame* frame,
const blink::WebURLError& error,
blink::WebHistoryCommitType commit_type) {
@@ -5468,13 +5480,11 @@ void RenderFrameImpl::NavigateInternal(
pending_navigation_params_.reset(
new NavigationParams(common_params, start_params, request_params));
- // Unless the load is a WebFrameLoadType::Standard, this should remain
- // uninitialized. It will be updated when the load type is determined to be
- // Standard, or after the previous document's unload handler has been
- // triggered. This occurs in UpdateNavigationState.
- // TODO(csharrison) See if we can always use the browser timestamp.
+ // Sanitize navigation start and store in |pending_navigation_params_|.
+ // It will be picked up in UpdateNavigationState.
pending_navigation_params_->common_params.navigation_start =
- base::TimeTicks();
+ SanitizeNavigationTiming(common_params.navigation_start,
+ renderer_navigation_start);
// Create parameters for a standard navigation, indicating whether it should
// replace the current NavigationEntry.
@@ -5598,11 +5608,6 @@ void RenderFrameImpl::NavigateInternal(
}
if (should_load_request) {
- // Sanitize navigation start now that we know the load_type.
- pending_navigation_params_->common_params.navigation_start =
- SanitizeNavigationTiming(load_type, common_params.navigation_start,
- renderer_navigation_start);
-
// PlzNavigate: check if the navigation being committed originated as a
// client redirect.
bool is_client_redirect =
@@ -6041,12 +6046,7 @@ void RenderFrameImpl::UpdateNavigationState(DocumentState* document_state,
return;
}
- // If this is a browser-initiated load that doesn't override
- // navigation_start, set it here.
- if (pending_navigation_params_->common_params.navigation_start.is_null()) {
- pending_navigation_params_->common_params.navigation_start =
- base::TimeTicks::Now();
- }
+ DCHECK(!pending_navigation_params_->common_params.navigation_start.is_null());
document_state->set_navigation_state(CreateNavigationStateFromPending());
// The |set_was_load_data_with_base_url_request| state should not change for

Powered by Google App Engine
This is Rietveld 408576698