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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1002803002: Classify navigations without page id in parallel to the existing classifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: greeeeeeen 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/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 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 bool ignore_cache = (common_params.navigation_type == 1110 bool ignore_cache = (common_params.navigation_type ==
1111 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); 1111 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE);
1112 1112
1113 if (reload_original_url) 1113 if (reload_original_url)
1114 frame->reloadWithOverrideURL(common_params.url, true); 1114 frame->reloadWithOverrideURL(common_params.url, true);
1115 else 1115 else
1116 frame->reload(ignore_cache); 1116 frame->reload(ignore_cache);
1117 } else if (is_history_navigation) { 1117 } else if (is_history_navigation) {
1118 // We must know the page ID of the page we are navigating back to. 1118 // We must know the page ID of the page we are navigating back to.
1119 DCHECK_NE(request_params.page_id, -1); 1119 DCHECK_NE(request_params.page_id, -1);
1120 // We must know the nav entry ID of the page we are navigating back to,
1121 // which should be the case because history navigations are routed via the
1122 // browser.
1123 DCHECK_NE(0, request_params.nav_entry_id);
clamy 2015/04/10 12:05:44 Considering that we are in an IPC handler for a br
Avi (use Gerrit) 2015/04/13 22:42:48 I was auditing the code for uses of page id, and a
clamy 2015/04/14 15:44:47 No I was suggesting having the DCHECK for all navi
Avi (use Gerrit) 2015/04/15 15:10:16 There are lots of parameters that are required for
1120 scoped_ptr<HistoryEntry> entry = 1124 scoped_ptr<HistoryEntry> entry =
1121 PageStateToHistoryEntry(request_params.page_state); 1125 PageStateToHistoryEntry(request_params.page_state);
1122 if (entry) { 1126 if (entry) {
1123 // Ensure we didn't save the swapped out URL in UpdateState, since the 1127 // Ensure we didn't save the swapped out URL in UpdateState, since the
1124 // browser should never be telling us to navigate to swappedout://. 1128 // browser should never be telling us to navigate to swappedout://.
1125 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); 1129 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
1126 scoped_ptr<NavigationParams> navigation_params( 1130 scoped_ptr<NavigationParams> navigation_params(
1127 new NavigationParams(*pending_navigation_params_.get())); 1131 new NavigationParams(*pending_navigation_params_.get()));
1128 render_view_->history_controller()->GoToEntry( 1132 render_view_->history_controller()->GoToEntry(
1129 entry.Pass(), navigation_params.Pass(), cache_policy); 1133 entry.Pass(), navigation_params.Pass(), cache_policy);
(...skipping 27 matching lines...) Expand all
1157 data = reinterpret_cast<const char*>( 1161 data = reinterpret_cast<const char*>(
1158 &start_params.browser_initiated_post_data.front()); 1162 &start_params.browser_initiated_post_data.front());
1159 } 1163 }
1160 http_body.appendData( 1164 http_body.appendData(
1161 WebData(data, start_params.browser_initiated_post_data.size())); 1165 WebData(data, start_params.browser_initiated_post_data.size()));
1162 request.setHTTPBody(http_body); 1166 request.setHTTPBody(http_body);
1163 } 1167 }
1164 1168
1165 // A session history navigation should have been accompanied by state. 1169 // A session history navigation should have been accompanied by state.
1166 CHECK_EQ(request_params.page_id, -1); 1170 CHECK_EQ(request_params.page_id, -1);
1171 // FYIREMOVEME(avi): Page id being -1 will happen with browser-initiated new
1172 // (non-history) navigations, and that's the test here. Nav entry unique
1173 // ids, however, are always provided with browser-initiated navigations,
1174 // history or new, so this test isn't valid for nav entry unique ids.
1167 1175
1168 // Record this before starting the load, we need a lower bound of this time 1176 // Record this before starting the load, we need a lower bound of this time
1169 // to sanitize the navigationStart override set below. 1177 // to sanitize the navigationStart override set below.
1170 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 1178 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
1171 frame->loadRequest(request); 1179 frame->loadRequest(request);
1172 1180
1173 UpdateFrameNavigationTiming(frame, request_params.browser_navigation_start, 1181 UpdateFrameNavigationTiming(frame, request_params.browser_navigation_start,
1174 renderer_navigation_start); 1182 renderer_navigation_start);
1175 } 1183 }
1176 1184
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after
2490 void RenderFrameImpl::didFailProvisionalLoad( 2498 void RenderFrameImpl::didFailProvisionalLoad(
2491 blink::WebLocalFrame* frame, 2499 blink::WebLocalFrame* frame,
2492 const blink::WebURLError& error, 2500 const blink::WebURLError& error,
2493 blink::WebHistoryCommitType commit_type) { 2501 blink::WebHistoryCommitType commit_type) {
2494 TRACE_EVENT1("navigation", "RenderFrameImpl::didFailProvisionalLoad", 2502 TRACE_EVENT1("navigation", "RenderFrameImpl::didFailProvisionalLoad",
2495 "id", routing_id_); 2503 "id", routing_id_);
2496 DCHECK(!frame_ || frame_ == frame); 2504 DCHECK(!frame_ || frame_ == frame);
2497 WebDataSource* ds = frame->provisionalDataSource(); 2505 WebDataSource* ds = frame->provisionalDataSource();
2498 DCHECK(ds); 2506 DCHECK(ds);
2499 2507
2500 const WebURLRequest& failed_request = ds->request();
2501
2502 // Notify the browser that we failed a provisional load with an error. 2508 // Notify the browser that we failed a provisional load with an error.
2503 // 2509 //
2504 // Note: It is important this notification occur before DidStopLoading so the 2510 // Note: It is important this notification occur before DidStopLoading so the
2505 // SSL manager can react to the provisional load failure before being 2511 // SSL manager can react to the provisional load failure before being
2506 // notified the load stopped. 2512 // notified the load stopped.
2507 // 2513 //
2508 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2514 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2509 DidFailProvisionalLoad(frame, error)); 2515 DidFailProvisionalLoad(frame, error));
2510 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, 2516 FOR_EACH_OBSERVER(RenderFrameObserver, observers_,
2511 DidFailProvisionalLoad(error)); 2517 DidFailProvisionalLoad(error));
2512 2518
2519 DocumentState* document_state = DocumentState::FromDataSource(ds);
2520 NavigationStateImpl* navigation_state =
2521 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2522
2523 const WebURLRequest& failed_request = ds->request();
2524
2513 bool show_repost_interstitial = 2525 bool show_repost_interstitial =
2514 (error.reason == net::ERR_CACHE_MISS && 2526 (error.reason == net::ERR_CACHE_MISS &&
2515 EqualsASCII(failed_request.httpMethod(), "POST")); 2527 EqualsASCII(failed_request.httpMethod(), "POST"));
2516 2528
2517 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; 2529 FrameHostMsg_DidFailProvisionalLoadWithError_Params params;
2518 params.error_code = error.reason; 2530 params.error_code = error.reason;
2531 params.nav_entry_id = navigation_state->request_params().nav_entry_id;
2519 GetContentClient()->renderer()->GetNavigationErrorStrings( 2532 GetContentClient()->renderer()->GetNavigationErrorStrings(
2520 render_view_.get(), 2533 render_view_.get(),
2521 frame, 2534 frame,
2522 failed_request, 2535 failed_request,
2523 error, 2536 error,
2524 NULL, 2537 NULL,
2525 &params.error_description); 2538 &params.error_description);
2526 params.url = error.unreachableURL; 2539 params.url = error.unreachableURL;
2527 params.showing_repost_interstitial = show_repost_interstitial; 2540 params.showing_repost_interstitial = show_repost_interstitial;
2528 Send(new FrameHostMsg_DidFailProvisionalLoadWithError( 2541 Send(new FrameHostMsg_DidFailProvisionalLoadWithError(
(...skipping 17 matching lines...) Expand all
2546 } 2559 }
2547 2560
2548 if (RenderThreadImpl::current() && 2561 if (RenderThreadImpl::current() &&
2549 RenderThreadImpl::current()->layout_test_mode()) { 2562 RenderThreadImpl::current()->layout_test_mode()) {
2550 return; 2563 return;
2551 } 2564 }
2552 2565
2553 // Make sure we never show errors in view source mode. 2566 // Make sure we never show errors in view source mode.
2554 frame->enableViewSourceMode(false); 2567 frame->enableViewSourceMode(false);
2555 2568
2556 DocumentState* document_state = DocumentState::FromDataSource(ds);
2557 NavigationStateImpl* navigation_state =
2558 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2559
2560 // If this is a failed back/forward/reload navigation, then we need to do a 2569 // If this is a failed back/forward/reload navigation, then we need to do a
2561 // 'replace' load. This is necessary to avoid messing up session history. 2570 // 'replace' load. This is necessary to avoid messing up session history.
2562 // Otherwise, we do a normal load, which simulates a 'go' navigation as far 2571 // Otherwise, we do a normal load, which simulates a 'go' navigation as far
2563 // as session history is concerned. 2572 // as session history is concerned.
2564 bool replace = commit_type != blink::WebStandardCommit; 2573 bool replace = commit_type != blink::WebStandardCommit;
2565 2574
2566 // If we failed on a browser initiated request, then make sure that our error 2575 // If we failed on a browser initiated request, then make sure that our error
2567 // page load is regarded as the same browser initiated request. 2576 // page load is regarded as the same browser initiated request.
2568 if (!navigation_state->IsContentInitiated()) { 2577 if (!navigation_state->IsContentInitiated()) {
2569 pending_navigation_params_.reset(new NavigationParams( 2578 pending_navigation_params_.reset(new NavigationParams(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 2620
2612 if (document_state->commit_load_time().is_null()) 2621 if (document_state->commit_load_time().is_null())
2613 document_state->set_commit_load_time(Time::Now()); 2622 document_state->set_commit_load_time(Time::Now());
2614 2623
2615 if (internal_data->must_reset_scroll_and_scale_state()) { 2624 if (internal_data->must_reset_scroll_and_scale_state()) {
2616 render_view_->webview()->resetScrollAndScaleState(); 2625 render_view_->webview()->resetScrollAndScaleState();
2617 internal_data->set_must_reset_scroll_and_scale_state(false); 2626 internal_data->set_must_reset_scroll_and_scale_state(false);
2618 } 2627 }
2619 internal_data->set_use_error_page(false); 2628 internal_data->set_use_error_page(false);
2620 2629
2630 bool successful_history_nav = false;
2621 bool is_new_navigation = commit_type == blink::WebStandardCommit; 2631 bool is_new_navigation = commit_type == blink::WebStandardCommit;
2622 if (is_new_navigation) { 2632 if (is_new_navigation) {
2623 // We bump our Page ID to correspond with the new session history entry. 2633 // We bump our Page ID to correspond with the new session history entry.
2624 render_view_->page_id_ = render_view_->next_page_id_++; 2634 render_view_->page_id_ = render_view_->next_page_id_++;
2625 2635
2626 // Don't update history list values for kSwappedOutURL, since 2636 // Don't update history list values for kSwappedOutURL, since
2627 // we don't want to forget the entry that was there, and since we will 2637 // we don't want to forget the entry that was there, and since we will
2628 // never come back to kSwappedOutURL. Note that we have to call 2638 // never come back to kSwappedOutURL. Note that we have to call
2629 // UpdateSessionHistory and update page_id_ even in this case, so that 2639 // UpdateSessionHistory and update page_id_ even in this case, so that
2630 // the current entry gets a state update and so that we don't send a 2640 // the current entry gets a state update and so that we don't send a
2631 // state update to the wrong entry when we swap back in. 2641 // state update to the wrong entry when we swap back in.
2632 DCHECK_IMPLIES( 2642 DCHECK_IMPLIES(
2633 navigation_state->start_params().should_replace_current_entry, 2643 navigation_state->start_params().should_replace_current_entry,
2634 render_view_->history_list_length_ > 0); 2644 render_view_->history_list_length_ > 0);
2635 if (GetLoadingUrl() != GURL(kSwappedOutURL) && 2645 if (GetLoadingUrl() != GURL(kSwappedOutURL) &&
2636 !navigation_state->start_params().should_replace_current_entry) { 2646 !navigation_state->start_params().should_replace_current_entry) {
2637 // Advance our offset in session history, applying the length limit. 2647 // Advance our offset in session history, applying the length limit.
2638 // There is now no forward history. 2648 // There is now no forward history.
2639 render_view_->history_list_offset_++; 2649 render_view_->history_list_offset_++;
2640 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) 2650 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries)
2641 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; 2651 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1;
2642 render_view_->history_list_length_ = 2652 render_view_->history_list_length_ =
2643 render_view_->history_list_offset_ + 1; 2653 render_view_->history_list_offset_ + 1;
2644 } 2654 }
2645 } else { 2655 } else {
2646 // Inspect the navigation_state on this frame to see if the navigation 2656 // FYIREMOVEME(avi): This used to check if the page id matched because
2647 // corresponds to a session history navigation... Note: |frame| may or 2657 // UpdateSessionHistory was called here, and we didn't want to call it twice
2648 // may not be the toplevel frame, but for the case of capturing session 2658 // on the same load. After r271220, when it was moved elsewhere, we don't
2649 // history, the first committed frame suffices. We keep track of whether 2659 // have that worry.
2650 // we've seen this commit before so that only capture session history once 2660 if (navigation_state->request_params().page_id != -1) {
2651 // per navigation.
2652 //
2653 // Note that we need to check if the page ID changed. In the case of a
2654 // reload, the page ID doesn't change, and UpdateSessionHistory gets the
2655 // previous URL and the current page ID, which would be wrong.
2656 if (navigation_state->request_params().page_id != -1 &&
2657 navigation_state->request_params().page_id != render_view_->page_id_) {
2658 // This is a successful session history navigation! 2661 // This is a successful session history navigation!
2662 successful_history_nav = true;
2659 render_view_->page_id_ = navigation_state->request_params().page_id; 2663 render_view_->page_id_ = navigation_state->request_params().page_id;
2660 2664
2661 render_view_->history_list_offset_ = 2665 render_view_->history_list_offset_ =
2662 navigation_state->request_params().pending_history_list_offset; 2666 navigation_state->request_params().pending_history_list_offset;
2663 } 2667 }
2664 } 2668 }
2665 2669
2670 if (commit_type == blink::WebBackForwardCommit) {
2671 // Checking the commit type is planned to be the replacement for the if()
Charlie Reis 2015/04/10 23:54:21 Would it be better to just have DCHECK_EQ(successf
Avi (use Gerrit) 2015/04/13 22:42:49 Good idea.
Avi (use Gerrit) 2015/04/15 20:28:25 And this breaks a lot. I need to dig pretty hard o
2672 // block containing the comment "This is a successful session history
2673 // navigation!" Make sure that it fires correspondingly.
2674 DCHECK(successful_history_nav);
2675 }
2676
2666 bool sent = Send( 2677 bool sent = Send(
2667 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); 2678 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_));
2668 CHECK(sent); // http://crbug.com/407376 2679 CHECK(sent); // http://crbug.com/407376
2669 2680
2670 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, 2681 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_,
2671 DidCommitProvisionalLoad(frame, is_new_navigation)); 2682 DidCommitProvisionalLoad(frame, is_new_navigation));
2672 FOR_EACH_OBSERVER( 2683 FOR_EACH_OBSERVER(
2673 RenderFrameObserver, observers_, 2684 RenderFrameObserver, observers_,
2674 DidCommitProvisionalLoad(is_new_navigation, 2685 DidCommitProvisionalLoad(is_new_navigation,
2675 navigation_state->WasWithinSamePage())); 2686 navigation_state->WasWithinSamePage()));
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
3802 DocumentState* document_state = DocumentState::FromDataSource(ds); 3813 DocumentState* document_state = DocumentState::FromDataSource(ds);
3803 NavigationStateImpl* navigation_state = 3814 NavigationStateImpl* navigation_state =
3804 static_cast<NavigationStateImpl*>(document_state->navigation_state()); 3815 static_cast<NavigationStateImpl*>(document_state->navigation_state());
3805 InternalDocumentStateData* internal_data = 3816 InternalDocumentStateData* internal_data =
3806 InternalDocumentStateData::FromDocumentState(document_state); 3817 InternalDocumentStateData::FromDocumentState(document_state);
3807 3818
3808 FrameHostMsg_DidCommitProvisionalLoad_Params params; 3819 FrameHostMsg_DidCommitProvisionalLoad_Params params;
3809 params.http_status_code = response.httpStatusCode(); 3820 params.http_status_code = response.httpStatusCode();
3810 params.url_is_unreachable = ds->hasUnreachableURL(); 3821 params.url_is_unreachable = ds->hasUnreachableURL();
3811 params.is_post = false; 3822 params.is_post = false;
3823 params.did_create_new_entry = commit_type == blink::WebStandardCommit;
3812 params.post_id = -1; 3824 params.post_id = -1;
3813 params.page_id = render_view_->page_id_; 3825 params.page_id = render_view_->page_id_;
3826 params.nav_entry_id = navigation_state->request_params().nav_entry_id;
3814 // We need to track the RenderViewHost routing_id because of downstream 3827 // We need to track the RenderViewHost routing_id because of downstream
3815 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, 3828 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager,
3816 // ResourceDispatcherHostImpl, MediaStreamUIProxy, 3829 // ResourceDispatcherHostImpl, MediaStreamUIProxy,
3817 // SpeechRecognitionDispatcherHost and possibly others). They look up the view 3830 // SpeechRecognitionDispatcherHost and possibly others). They look up the view
3818 // based on the ID stored in the resource requests. Once those dependencies 3831 // based on the ID stored in the resource requests. Once those dependencies
3819 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the 3832 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the
3820 // client to be based on the routing_id of the RenderFrameHost. 3833 // client to be based on the routing_id of the RenderFrameHost.
3821 params.render_view_routing_id = render_view_->routing_id(); 3834 params.render_view_routing_id = render_view_->routing_id();
3822 params.socket_address.set_host(response.remoteIPAddress().utf8()); 3835 params.socket_address.set_host(response.remoteIPAddress().utf8());
3823 params.socket_address.set_port(response.remotePort()); 3836 params.socket_address.set_port(response.remotePort());
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
4696 #elif defined(ENABLE_BROWSER_CDMS) 4709 #elif defined(ENABLE_BROWSER_CDMS)
4697 cdm_manager_, 4710 cdm_manager_,
4698 #endif 4711 #endif
4699 this); 4712 this);
4700 } 4713 }
4701 4714
4702 return cdm_factory_; 4715 return cdm_factory_;
4703 } 4716 }
4704 4717
4705 } // namespace content 4718 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698