OLD | NEW |
---|---|
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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 // Sanitizes the navigation_start timestamp for browser-initiated navigations, | 558 // Sanitizes the navigation_start timestamp for browser-initiated navigations, |
559 // where the browser possibly has a better notion of start time than the | 559 // where the browser possibly has a better notion of start time than the |
560 // renderer. In the case of cross-process navigations, this carries over the | 560 // renderer. In the case of cross-process navigations, this carries over the |
561 // time of finishing the onbeforeunload handler of the previous page. | 561 // time of finishing the onbeforeunload handler of the previous page. |
562 // TimeTicks is sometimes not monotonic across processes, and because | 562 // TimeTicks is sometimes not monotonic across processes, and because |
563 // |browser_navigation_start| is likely before this process existed, | 563 // |browser_navigation_start| is likely before this process existed, |
564 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by | 564 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by |
565 // clamping it to renderer_navigation_start, initialized earlier in the call | 565 // clamping it to renderer_navigation_start, initialized earlier in the call |
566 // stack. | 566 // stack. |
567 base::TimeTicks SanitizeNavigationTiming( | 567 base::TimeTicks SanitizeNavigationTiming( |
568 blink::WebFrameLoadType load_type, | |
569 const base::TimeTicks& browser_navigation_start, | 568 const base::TimeTicks& browser_navigation_start, |
570 const base::TimeTicks& renderer_navigation_start) { | 569 const base::TimeTicks& renderer_navigation_start) { |
571 if (load_type != blink::WebFrameLoadType::Standard) | |
572 return base::TimeTicks(); | |
573 DCHECK(!browser_navigation_start.is_null()); | 570 DCHECK(!browser_navigation_start.is_null()); |
574 base::TimeTicks navigation_start = | 571 base::TimeTicks navigation_start = |
575 std::min(browser_navigation_start, renderer_navigation_start); | 572 std::min(browser_navigation_start, renderer_navigation_start); |
576 base::TimeDelta difference = | 573 base::TimeDelta difference = |
577 renderer_navigation_start - browser_navigation_start; | 574 renderer_navigation_start - browser_navigation_start; |
578 if (difference > base::TimeDelta()) { | 575 if (difference > base::TimeDelta()) { |
579 UMA_HISTOGRAM_TIMES("Navigation.Start.RendererBrowserDifference.Positive", | 576 UMA_HISTOGRAM_TIMES("Navigation.Start.RendererBrowserDifference.Positive", |
580 difference); | 577 difference); |
581 } else { | 578 } else { |
582 UMA_HISTOGRAM_TIMES("Navigation.Start.RendererBrowserDifference.Negative", | 579 UMA_HISTOGRAM_TIMES("Navigation.Start.RendererBrowserDifference.Negative", |
(...skipping 3080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3663 frame->dataSource()->request().inputPerfMetricReportPolicy()); | 3660 frame->dataSource()->request().inputPerfMetricReportPolicy()); |
3664 base::TimeTicks ui_timestamp = base::TimeTicks() + | 3661 base::TimeTicks ui_timestamp = base::TimeTicks() + |
3665 base::TimeDelta::FromSecondsD( | 3662 base::TimeDelta::FromSecondsD( |
3666 frame->dataSource()->request().uiStartTime()); | 3663 frame->dataSource()->request().uiStartTime()); |
3667 | 3664 |
3668 Send(new FrameHostMsg_DocumentOnLoadCompleted( | 3665 Send(new FrameHostMsg_DocumentOnLoadCompleted( |
3669 routing_id_, report_type, ui_timestamp)); | 3666 routing_id_, report_type, ui_timestamp)); |
3670 } | 3667 } |
3671 } | 3668 } |
3672 | 3669 |
3670 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
| |
3671 // If there are pending navigation params, then the beforeunload event was | |
3672 // caused by a same-process browser-initiated navigation, and the | |
3673 // navigation_start was recorded before dispatching beforeunload, which means | |
3674 // it should not be used, and the right timestamp is |Now|. | |
3675 // If this is the first navigation in the frame, and the initial document did | |
3676 // not have a beforeunload handler, then it is likely a cross-process | |
3677 // navigation, and the browser timestamp is the right one. | |
3678 if (pending_navigation_params_ && | |
3679 (eventListenerCalled || !current_history_item_.isNull())) { | |
3680 pending_navigation_params_->common_params.navigation_start = | |
3681 base::TimeTicks::Now(); | |
3682 } | |
3683 } | |
3684 | |
3673 void RenderFrameImpl::didFailLoad(blink::WebLocalFrame* frame, | 3685 void RenderFrameImpl::didFailLoad(blink::WebLocalFrame* frame, |
3674 const blink::WebURLError& error, | 3686 const blink::WebURLError& error, |
3675 blink::WebHistoryCommitType commit_type) { | 3687 blink::WebHistoryCommitType commit_type) { |
3676 TRACE_EVENT1("navigation", "RenderFrameImpl::didFailLoad", | 3688 TRACE_EVENT1("navigation", "RenderFrameImpl::didFailLoad", |
3677 "id", routing_id_); | 3689 "id", routing_id_); |
3678 DCHECK_EQ(frame_, frame); | 3690 DCHECK_EQ(frame_, frame); |
3679 // TODO(nasko): Move implementation here. No state needed. | 3691 // TODO(nasko): Move implementation here. No state needed. |
3680 WebDataSource* ds = frame->dataSource(); | 3692 WebDataSource* ds = frame->dataSource(); |
3681 DCHECK(ds); | 3693 DCHECK(ds); |
3682 | 3694 |
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5461 } | 5473 } |
5462 | 5474 |
5463 // If the navigation is for "view source", the WebLocalFrame needs to be put | 5475 // If the navigation is for "view source", the WebLocalFrame needs to be put |
5464 // in a special mode. | 5476 // in a special mode. |
5465 if (request_params.is_view_source) | 5477 if (request_params.is_view_source) |
5466 frame_->enableViewSourceMode(true); | 5478 frame_->enableViewSourceMode(true); |
5467 | 5479 |
5468 pending_navigation_params_.reset( | 5480 pending_navigation_params_.reset( |
5469 new NavigationParams(common_params, start_params, request_params)); | 5481 new NavigationParams(common_params, start_params, request_params)); |
5470 | 5482 |
5471 // Unless the load is a WebFrameLoadType::Standard, this should remain | 5483 // Sanitize navigation start and store in |pending_navigation_params_|. |
5472 // uninitialized. It will be updated when the load type is determined to be | 5484 // It will be picked up in UpdateNavigationState. |
5473 // Standard, or after the previous document's unload handler has been | |
5474 // triggered. This occurs in UpdateNavigationState. | |
5475 // TODO(csharrison) See if we can always use the browser timestamp. | |
5476 pending_navigation_params_->common_params.navigation_start = | 5485 pending_navigation_params_->common_params.navigation_start = |
5477 base::TimeTicks(); | 5486 SanitizeNavigationTiming(common_params.navigation_start, |
5487 renderer_navigation_start); | |
5478 | 5488 |
5479 // Create parameters for a standard navigation, indicating whether it should | 5489 // Create parameters for a standard navigation, indicating whether it should |
5480 // replace the current NavigationEntry. | 5490 // replace the current NavigationEntry. |
5481 blink::WebFrameLoadType load_type = | 5491 blink::WebFrameLoadType load_type = |
5482 common_params.should_replace_current_entry | 5492 common_params.should_replace_current_entry |
5483 ? blink::WebFrameLoadType::ReplaceCurrentItem | 5493 ? blink::WebFrameLoadType::ReplaceCurrentItem |
5484 : blink::WebFrameLoadType::Standard; | 5494 : blink::WebFrameLoadType::Standard; |
5485 blink::WebHistoryLoadType history_load_type = | 5495 blink::WebHistoryLoadType history_load_type = |
5486 blink::WebHistoryDifferentDocumentLoad; | 5496 blink::WebHistoryDifferentDocumentLoad; |
5487 bool should_load_request = false; | 5497 bool should_load_request = false; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5591 GetWebHTTPBodyForRequestBody(common_params.post_data)); | 5601 GetWebHTTPBodyForRequestBody(common_params.post_data)); |
5592 } | 5602 } |
5593 | 5603 |
5594 // A session history navigation should have been accompanied by state. | 5604 // A session history navigation should have been accompanied by state. |
5595 CHECK_EQ(request_params.page_id, -1); | 5605 CHECK_EQ(request_params.page_id, -1); |
5596 | 5606 |
5597 should_load_request = true; | 5607 should_load_request = true; |
5598 } | 5608 } |
5599 | 5609 |
5600 if (should_load_request) { | 5610 if (should_load_request) { |
5601 // Sanitize navigation start now that we know the load_type. | |
5602 pending_navigation_params_->common_params.navigation_start = | |
5603 SanitizeNavigationTiming(load_type, common_params.navigation_start, | |
5604 renderer_navigation_start); | |
5605 | |
5606 // PlzNavigate: check if the navigation being committed originated as a | 5611 // PlzNavigate: check if the navigation being committed originated as a |
5607 // client redirect. | 5612 // client redirect. |
5608 bool is_client_redirect = | 5613 bool is_client_redirect = |
5609 browser_side_navigation | 5614 browser_side_navigation |
5610 ? !!(common_params.transition & ui::PAGE_TRANSITION_CLIENT_REDIRECT) | 5615 ? !!(common_params.transition & ui::PAGE_TRANSITION_CLIENT_REDIRECT) |
5611 : false; | 5616 : false; |
5612 | 5617 |
5613 // Perform a navigation to a data url if needed. | 5618 // Perform a navigation to a data url if needed. |
5614 // Note: the base URL might be invalid, so also check the data URL string. | 5619 // Note: the base URL might be invalid, so also check the data URL string. |
5615 bool should_load_data_url = !common_params.base_url_for_data_url.is_empty(); | 5620 bool should_load_data_url = !common_params.base_url_for_data_url.is_empty(); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6034 // If this was a browser-initiated navigation, then there could be pending | 6039 // If this was a browser-initiated navigation, then there could be pending |
6035 // navigation params, so use them. Otherwise, just reset the document state | 6040 // navigation params, so use them. Otherwise, just reset the document state |
6036 // here, since if pending navigation params exist they are for some other | 6041 // here, since if pending navigation params exist they are for some other |
6037 // navigation <https://crbug.com/597239>. | 6042 // navigation <https://crbug.com/597239>. |
6038 if (!pending_navigation_params_ || content_initiated) { | 6043 if (!pending_navigation_params_ || content_initiated) { |
6039 document_state->set_navigation_state( | 6044 document_state->set_navigation_state( |
6040 NavigationStateImpl::CreateContentInitiated()); | 6045 NavigationStateImpl::CreateContentInitiated()); |
6041 return; | 6046 return; |
6042 } | 6047 } |
6043 | 6048 |
6044 // If this is a browser-initiated load that doesn't override | 6049 DCHECK(!pending_navigation_params_->common_params.navigation_start.is_null()); |
6045 // navigation_start, set it here. | |
6046 if (pending_navigation_params_->common_params.navigation_start.is_null()) { | |
6047 pending_navigation_params_->common_params.navigation_start = | |
6048 base::TimeTicks::Now(); | |
6049 } | |
6050 document_state->set_navigation_state(CreateNavigationStateFromPending()); | 6050 document_state->set_navigation_state(CreateNavigationStateFromPending()); |
6051 | 6051 |
6052 // The |set_was_load_data_with_base_url_request| state should not change for | 6052 // The |set_was_load_data_with_base_url_request| state should not change for |
6053 // an in-page navigation, so skip updating it from the in-page navigation | 6053 // an in-page navigation, so skip updating it from the in-page navigation |
6054 // params in this case. | 6054 // params in this case. |
6055 if (!was_within_same_page) { | 6055 if (!was_within_same_page) { |
6056 const CommonNavigationParams& common_params = | 6056 const CommonNavigationParams& common_params = |
6057 pending_navigation_params_->common_params; | 6057 pending_navigation_params_->common_params; |
6058 bool load_data = !common_params.base_url_for_data_url.is_empty() && | 6058 bool load_data = !common_params.base_url_for_data_url.is_empty() && |
6059 !common_params.history_url_for_data_url.is_empty() && | 6059 !common_params.history_url_for_data_url.is_empty() && |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6310 // event target. Potentially a Pepper plugin will receive the event. | 6310 // event target. Potentially a Pepper plugin will receive the event. |
6311 // In order to tell whether a plugin gets the last mouse event and which it | 6311 // In order to tell whether a plugin gets the last mouse event and which it |
6312 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6312 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6313 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6313 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6314 // |pepper_last_mouse_event_target_|. | 6314 // |pepper_last_mouse_event_target_|. |
6315 pepper_last_mouse_event_target_ = nullptr; | 6315 pepper_last_mouse_event_target_ = nullptr; |
6316 #endif | 6316 #endif |
6317 } | 6317 } |
6318 | 6318 |
6319 } // namespace content | 6319 } // namespace content |
OLD | NEW |