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

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: rebase again 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 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 bool ignore_cache = (common_params.navigation_type == 1121 bool ignore_cache = (common_params.navigation_type ==
1122 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); 1122 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE);
1123 1123
1124 if (reload_original_url) 1124 if (reload_original_url)
1125 frame->reloadWithOverrideURL(common_params.url, true); 1125 frame->reloadWithOverrideURL(common_params.url, true);
1126 else 1126 else
1127 frame->reload(ignore_cache); 1127 frame->reload(ignore_cache);
1128 } else if (is_history_navigation) { 1128 } else if (is_history_navigation) {
1129 // We must know the page ID of the page we are navigating back to. 1129 // We must know the page ID of the page we are navigating back to.
1130 DCHECK_NE(request_params.page_id, -1); 1130 DCHECK_NE(request_params.page_id, -1);
1131 // We must know the nav entry ID of the page we are navigating back to,
1132 // which should be the case because history navigations are routed via the
1133 // browser.
1134 DCHECK_NE(0, request_params.nav_entry_id);
1131 scoped_ptr<HistoryEntry> entry = 1135 scoped_ptr<HistoryEntry> entry =
1132 PageStateToHistoryEntry(request_params.page_state); 1136 PageStateToHistoryEntry(request_params.page_state);
1133 if (entry) { 1137 if (entry) {
1134 // Ensure we didn't save the swapped out URL in UpdateState, since the 1138 // Ensure we didn't save the swapped out URL in UpdateState, since the
1135 // browser should never be telling us to navigate to swappedout://. 1139 // browser should never be telling us to navigate to swappedout://.
1136 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); 1140 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
1137 scoped_ptr<NavigationParams> navigation_params( 1141 scoped_ptr<NavigationParams> navigation_params(
1138 new NavigationParams(*pending_navigation_params_.get())); 1142 new NavigationParams(*pending_navigation_params_.get()));
1139 render_view_->history_controller()->GoToEntry( 1143 render_view_->history_controller()->GoToEntry(
1140 entry.Pass(), navigation_params.Pass(), cache_policy); 1144 entry.Pass(), navigation_params.Pass(), cache_policy);
(...skipping 27 matching lines...) Expand all
1168 data = reinterpret_cast<const char*>( 1172 data = reinterpret_cast<const char*>(
1169 &start_params.browser_initiated_post_data.front()); 1173 &start_params.browser_initiated_post_data.front());
1170 } 1174 }
1171 http_body.appendData( 1175 http_body.appendData(
1172 WebData(data, start_params.browser_initiated_post_data.size())); 1176 WebData(data, start_params.browser_initiated_post_data.size()));
1173 request.setHTTPBody(http_body); 1177 request.setHTTPBody(http_body);
1174 } 1178 }
1175 1179
1176 // A session history navigation should have been accompanied by state. 1180 // A session history navigation should have been accompanied by state.
1177 CHECK_EQ(request_params.page_id, -1); 1181 CHECK_EQ(request_params.page_id, -1);
1182 // FYIREMOVEME(avi): Page id being -1 will happen with browser-initiated new
1183 // (non-history) navigations, and that's the test here. Nav entry unique
1184 // ids, however, are always provided with browser-initiated navigations,
1185 // history or new, so this test isn't valid for nav entry unique ids.
1178 1186
1179 // Record this before starting the load, we need a lower bound of this time 1187 // Record this before starting the load, we need a lower bound of this time
1180 // to sanitize the navigationStart override set below. 1188 // to sanitize the navigationStart override set below.
1181 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 1189 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
1182 frame->loadRequest(request); 1190 frame->loadRequest(request);
1183 1191
1184 UpdateFrameNavigationTiming(frame, request_params.browser_navigation_start, 1192 UpdateFrameNavigationTiming(frame, request_params.browser_navigation_start,
1185 renderer_navigation_start); 1193 renderer_navigation_start);
1186 } 1194 }
1187 1195
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 const blink::WebURLError& error, 2593 const blink::WebURLError& error,
2586 blink::WebHistoryCommitType commit_type) { 2594 blink::WebHistoryCommitType commit_type) {
2587 TRACE_EVENT1("navigation", "RenderFrameImpl::didFailProvisionalLoad", 2595 TRACE_EVENT1("navigation", "RenderFrameImpl::didFailProvisionalLoad",
2588 "id", routing_id_); 2596 "id", routing_id_);
2589 DCHECK(!frame_ || frame_ == frame); 2597 DCHECK(!frame_ || frame_ == frame);
2590 WebDataSource* ds = frame->provisionalDataSource(); 2598 WebDataSource* ds = frame->provisionalDataSource();
2591 DCHECK(ds); 2599 DCHECK(ds);
2592 2600
2593 const WebURLRequest& failed_request = ds->request(); 2601 const WebURLRequest& failed_request = ds->request();
2594 2602
2603 DocumentState* document_state = DocumentState::FromDataSource(ds);
2604 NavigationStateImpl* navigation_state =
2605 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2606
2595 // Notify the browser that we failed a provisional load with an error. 2607 // Notify the browser that we failed a provisional load with an error.
2596 // 2608 //
2597 // Note: It is important this notification occur before DidStopLoading so the 2609 // Note: It is important this notification occur before DidStopLoading so the
2598 // SSL manager can react to the provisional load failure before being 2610 // SSL manager can react to the provisional load failure before being
2599 // notified the load stopped. 2611 // notified the load stopped.
2600 // 2612 //
2601 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2613 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2602 DidFailProvisionalLoad(frame, error)); 2614 DidFailProvisionalLoad(frame, error));
2603 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, 2615 FOR_EACH_OBSERVER(RenderFrameObserver, observers_,
2604 DidFailProvisionalLoad(error)); 2616 DidFailProvisionalLoad(error));
2605 2617
2606 SendFailedProvisionalLoad(failed_request, error, frame); 2618 SendFailedProvisionalLoad(
2619 failed_request, error, navigation_state->request_params(), frame);
2607 2620
2608 if (!ShouldDisplayErrorPageForFailedLoad(error.reason, error.unreachableURL)) 2621 if (!ShouldDisplayErrorPageForFailedLoad(error.reason, error.unreachableURL))
2609 return; 2622 return;
2610 2623
2611 // Make sure we never show errors in view source mode. 2624 // Make sure we never show errors in view source mode.
2612 frame->enableViewSourceMode(false); 2625 frame->enableViewSourceMode(false);
2613 2626
2614 DocumentState* document_state = DocumentState::FromDataSource(ds);
2615 NavigationStateImpl* navigation_state =
2616 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2617
2618 // If this is a failed back/forward/reload navigation, then we need to do a 2627 // If this is a failed back/forward/reload navigation, then we need to do a
2619 // 'replace' load. This is necessary to avoid messing up session history. 2628 // 'replace' load. This is necessary to avoid messing up session history.
2620 // Otherwise, we do a normal load, which simulates a 'go' navigation as far 2629 // Otherwise, we do a normal load, which simulates a 'go' navigation as far
2621 // as session history is concerned. 2630 // as session history is concerned.
2622 bool replace = commit_type != blink::WebStandardCommit; 2631 bool replace = commit_type != blink::WebStandardCommit;
2623 2632
2624 // If we failed on a browser initiated request, then make sure that our error 2633 // If we failed on a browser initiated request, then make sure that our error
2625 // page load is regarded as the same browser initiated request. 2634 // page load is regarded as the same browser initiated request.
2626 if (!navigation_state->IsContentInitiated()) { 2635 if (!navigation_state->IsContentInitiated()) {
2627 pending_navigation_params_.reset(new NavigationParams( 2636 pending_navigation_params_.reset(new NavigationParams(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2694 !navigation_state->start_params().should_replace_current_entry) { 2703 !navigation_state->start_params().should_replace_current_entry) {
2695 // Advance our offset in session history, applying the length limit. 2704 // Advance our offset in session history, applying the length limit.
2696 // There is now no forward history. 2705 // There is now no forward history.
2697 render_view_->history_list_offset_++; 2706 render_view_->history_list_offset_++;
2698 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) 2707 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries)
2699 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; 2708 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1;
2700 render_view_->history_list_length_ = 2709 render_view_->history_list_length_ =
2701 render_view_->history_list_offset_ + 1; 2710 render_view_->history_list_offset_ + 1;
2702 } 2711 }
2703 } else { 2712 } else {
2704 // Inspect the navigation_state on this frame to see if the navigation 2713 // FYIREMOVEME(avi): This used to check if the page id matched because
2705 // corresponds to a session history navigation... Note: |frame| may or 2714 // UpdateSessionHistory was called here, and we didn't want to call it twice
2706 // may not be the toplevel frame, but for the case of capturing session 2715 // on the same load. After r271220, when it was moved elsewhere, we don't
2707 // history, the first committed frame suffices. We keep track of whether 2716 // have that worry.
2708 // we've seen this commit before so that only capture session history once 2717 if (navigation_state->request_params().page_id != -1) {
2709 // per navigation.
2710 //
2711 // Note that we need to check if the page ID changed. In the case of a
2712 // reload, the page ID doesn't change, and UpdateSessionHistory gets the
2713 // previous URL and the current page ID, which would be wrong.
2714 if (navigation_state->request_params().page_id != -1 &&
2715 navigation_state->request_params().page_id != render_view_->page_id_) {
2716 // This is a successful session history navigation! 2718 // This is a successful session history navigation!
2717 render_view_->page_id_ = navigation_state->request_params().page_id; 2719 render_view_->page_id_ = navigation_state->request_params().page_id;
2718 2720
2719 render_view_->history_list_offset_ = 2721 render_view_->history_list_offset_ =
2720 navigation_state->request_params().pending_history_list_offset; 2722 navigation_state->request_params().pending_history_list_offset;
2721 } 2723 }
2722 } 2724 }
2723 2725
2724 bool sent = Send( 2726 bool sent = Send(
2725 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); 2727 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_));
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3863 DocumentState* document_state = DocumentState::FromDataSource(ds); 3865 DocumentState* document_state = DocumentState::FromDataSource(ds);
3864 NavigationStateImpl* navigation_state = 3866 NavigationStateImpl* navigation_state =
3865 static_cast<NavigationStateImpl*>(document_state->navigation_state()); 3867 static_cast<NavigationStateImpl*>(document_state->navigation_state());
3866 InternalDocumentStateData* internal_data = 3868 InternalDocumentStateData* internal_data =
3867 InternalDocumentStateData::FromDocumentState(document_state); 3869 InternalDocumentStateData::FromDocumentState(document_state);
3868 3870
3869 FrameHostMsg_DidCommitProvisionalLoad_Params params; 3871 FrameHostMsg_DidCommitProvisionalLoad_Params params;
3870 params.http_status_code = response.httpStatusCode(); 3872 params.http_status_code = response.httpStatusCode();
3871 params.url_is_unreachable = ds->hasUnreachableURL(); 3873 params.url_is_unreachable = ds->hasUnreachableURL();
3872 params.is_post = false; 3874 params.is_post = false;
3875 params.did_create_new_entry = commit_type == blink::WebStandardCommit;
3873 params.post_id = -1; 3876 params.post_id = -1;
3874 params.page_id = render_view_->page_id_; 3877 params.page_id = render_view_->page_id_;
3878 params.nav_entry_id = navigation_state->request_params().nav_entry_id;
3875 // We need to track the RenderViewHost routing_id because of downstream 3879 // We need to track the RenderViewHost routing_id because of downstream
3876 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, 3880 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager,
3877 // ResourceDispatcherHostImpl, MediaStreamUIProxy, 3881 // ResourceDispatcherHostImpl, MediaStreamUIProxy,
3878 // SpeechRecognitionDispatcherHost and possibly others). They look up the view 3882 // SpeechRecognitionDispatcherHost and possibly others). They look up the view
3879 // based on the ID stored in the resource requests. Once those dependencies 3883 // based on the ID stored in the resource requests. Once those dependencies
3880 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the 3884 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the
3881 // client to be based on the routing_id of the RenderFrameHost. 3885 // client to be based on the routing_id of the RenderFrameHost.
3882 params.render_view_routing_id = render_view_->routing_id(); 3886 params.render_view_routing_id = render_view_->routing_id();
3883 params.socket_address.set_host(response.remoteIPAddress().utf8()); 3887 params.socket_address.set_host(response.remoteIPAddress().utf8());
3884 params.socket_address.set_port(response.remotePort()); 3888 params.socket_address.set_port(response.remotePort());
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
4156 // TODO(clamy): Properly set is_transition_navigation. 4160 // TODO(clamy): Properly set is_transition_navigation.
4157 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 4161 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
4158 routing_id_, common_params.url, false)); 4162 routing_id_, common_params.url, false));
4159 4163
4160 // Send the provisional load failure. 4164 // Send the provisional load failure.
4161 blink::WebURLError error = 4165 blink::WebURLError error =
4162 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); 4166 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code);
4163 WebURLRequest failed_request = CreateURLRequestForNavigation( 4167 WebURLRequest failed_request = CreateURLRequestForNavigation(
4164 common_params, scoped_ptr<StreamOverrideParameters>(), 4168 common_params, scoped_ptr<StreamOverrideParameters>(),
4165 frame_->isViewSourceModeEnabled()); 4169 frame_->isViewSourceModeEnabled());
4166 SendFailedProvisionalLoad(failed_request, error, frame_); 4170 SendFailedProvisionalLoad(failed_request, error, request_params, frame_);
4167 4171
4168 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { 4172 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) {
4169 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); 4173 Send(new FrameHostMsg_DidDropNavigation(routing_id_));
4170 return; 4174 return;
4171 } 4175 }
4172 4176
4173 // Make sure errors are not shown in view source mode. 4177 // Make sure errors are not shown in view source mode.
4174 frame_->enableViewSourceMode(false); 4178 frame_->enableViewSourceMode(false);
4175 4179
4176 // Replace the current history entry in reloads, history navigations and loads 4180 // Replace the current history entry in reloads, history navigations and loads
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
4676 false); 4680 false);
4677 } else { 4681 } else {
4678 CHECK(false) << "Invalid URL passed: " 4682 CHECK(false) << "Invalid URL passed: "
4679 << params.url.possibly_invalid_spec(); 4683 << params.url.possibly_invalid_spec();
4680 } 4684 }
4681 } 4685 }
4682 4686
4683 void RenderFrameImpl::SendFailedProvisionalLoad( 4687 void RenderFrameImpl::SendFailedProvisionalLoad(
4684 const blink::WebURLRequest& request, 4688 const blink::WebURLRequest& request,
4685 const blink::WebURLError& error, 4689 const blink::WebURLError& error,
4690 const RequestNavigationParams& request_params,
Charlie Reis 2015/04/22 05:27:25 Any reason we need to pass in the whole request_pa
Avi (use Gerrit) 2015/04/22 18:31:51 Done.
4686 blink::WebLocalFrame* frame) { 4691 blink::WebLocalFrame* frame) {
4687 bool show_repost_interstitial = (error.reason == net::ERR_CACHE_MISS && 4692 bool show_repost_interstitial = (error.reason == net::ERR_CACHE_MISS &&
4688 EqualsASCII(request.httpMethod(), "POST")); 4693 EqualsASCII(request.httpMethod(), "POST"));
4689 4694
4690 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; 4695 FrameHostMsg_DidFailProvisionalLoadWithError_Params params;
4691 params.error_code = error.reason; 4696 params.error_code = error.reason;
4697 params.nav_entry_id = request_params.nav_entry_id;
4692 GetContentClient()->renderer()->GetNavigationErrorStrings( 4698 GetContentClient()->renderer()->GetNavigationErrorStrings(
4693 render_view_.get(), frame, request, error, NULL, 4699 render_view_.get(), frame, request, error, NULL,
4694 &params.error_description); 4700 &params.error_description);
4695 params.url = error.unreachableURL; 4701 params.url = error.unreachableURL;
4696 params.showing_repost_interstitial = show_repost_interstitial; 4702 params.showing_repost_interstitial = show_repost_interstitial;
4697 Send(new FrameHostMsg_DidFailProvisionalLoadWithError(routing_id_, params)); 4703 Send(new FrameHostMsg_DidFailProvisionalLoadWithError(routing_id_, params));
4698 } 4704 }
4699 4705
4700 bool RenderFrameImpl::ShouldDisplayErrorPageForFailedLoad( 4706 bool RenderFrameImpl::ShouldDisplayErrorPageForFailedLoad(
4701 int error_code, 4707 int error_code,
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
4857 #elif defined(ENABLE_BROWSER_CDMS) 4863 #elif defined(ENABLE_BROWSER_CDMS)
4858 cdm_manager_, 4864 cdm_manager_,
4859 #endif 4865 #endif
4860 this); 4866 this);
4861 } 4867 }
4862 4868
4863 return cdm_factory_; 4869 return cdm_factory_;
4864 } 4870 }
4865 4871
4866 } // namespace content 4872 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698