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

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: unit tests Created 5 years, 9 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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 bool ignore_cache = (common_params.navigation_type == 1084 bool ignore_cache = (common_params.navigation_type ==
1085 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); 1085 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE);
1086 1086
1087 if (reload_original_url) 1087 if (reload_original_url)
1088 frame->reloadWithOverrideURL(common_params.url, true); 1088 frame->reloadWithOverrideURL(common_params.url, true);
1089 else 1089 else
1090 frame->reload(ignore_cache); 1090 frame->reload(ignore_cache);
1091 } else if (is_history_navigation) { 1091 } else if (is_history_navigation) {
1092 // We must know the page ID of the page we are navigating back to. 1092 // We must know the page ID of the page we are navigating back to.
1093 DCHECK_NE(history_params.page_id, -1); 1093 DCHECK_NE(history_params.page_id, -1);
1094 // We must know the nav entry ID of the page we are navigating back to,
1095 // which should be the case because history navigations are routed via the
1096 // browser.
1097 DCHECK_NE(0, history_params.nav_entry_id);
1094 scoped_ptr<HistoryEntry> entry = 1098 scoped_ptr<HistoryEntry> entry =
1095 PageStateToHistoryEntry(history_params.page_state); 1099 PageStateToHistoryEntry(history_params.page_state);
1096 if (entry) { 1100 if (entry) {
1097 // Ensure we didn't save the swapped out URL in UpdateState, since the 1101 // Ensure we didn't save the swapped out URL in UpdateState, since the
1098 // browser should never be telling us to navigate to swappedout://. 1102 // browser should never be telling us to navigate to swappedout://.
1099 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); 1103 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
1100 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); 1104 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy);
1101 } 1105 }
1102 } else if (!common_params.base_url_for_data_url.is_empty()) { 1106 } else if (!common_params.base_url_for_data_url.is_empty()) {
1103 LoadDataURL(common_params, frame); 1107 LoadDataURL(common_params, frame);
(...skipping 24 matching lines...) Expand all
1128 data = reinterpret_cast<const char*>( 1132 data = reinterpret_cast<const char*>(
1129 &start_params.browser_initiated_post_data.front()); 1133 &start_params.browser_initiated_post_data.front());
1130 } 1134 }
1131 http_body.appendData( 1135 http_body.appendData(
1132 WebData(data, start_params.browser_initiated_post_data.size())); 1136 WebData(data, start_params.browser_initiated_post_data.size()));
1133 request.setHTTPBody(http_body); 1137 request.setHTTPBody(http_body);
1134 } 1138 }
1135 1139
1136 // A session history navigation should have been accompanied by state. 1140 // A session history navigation should have been accompanied by state.
1137 CHECK_EQ(history_params.page_id, -1); 1141 CHECK_EQ(history_params.page_id, -1);
1142 // FYIREMOVEME(avi): Page id being -1 will happen with browser-initiated new
1143 // (non-history) navigations, and that's the test here. Nav entry unique
1144 // ids, however, are always provided with browser-initiated navigations,
1145 // history or new, so this test isn't valid for nav entry unique ids.
1138 1146
1139 // Record this before starting the load, we need a lower bound of this time 1147 // Record this before starting the load, we need a lower bound of this time
1140 // to sanitize the navigationStart override set below. 1148 // to sanitize the navigationStart override set below.
1141 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 1149 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
1142 frame->loadRequest(request); 1150 frame->loadRequest(request);
1143 1151
1144 UpdateFrameNavigationTiming(frame, commit_params.browser_navigation_start, 1152 UpdateFrameNavigationTiming(frame, commit_params.browser_navigation_start,
1145 renderer_navigation_start); 1153 renderer_navigation_start);
1146 } 1154 }
1147 1155
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2429 // If this is a failed back/forward/reload navigation, then we need to do a 2437 // If this is a failed back/forward/reload navigation, then we need to do a
2430 // 'replace' load. This is necessary to avoid messing up session history. 2438 // 'replace' load. This is necessary to avoid messing up session history.
2431 // Otherwise, we do a normal load, which simulates a 'go' navigation as far 2439 // Otherwise, we do a normal load, which simulates a 'go' navigation as far
2432 // as session history is concerned. 2440 // as session history is concerned.
2433 // 2441 //
2434 // AUTO_SUBFRAME loads should always be treated as loads that do not advance 2442 // AUTO_SUBFRAME loads should always be treated as loads that do not advance
2435 // the page id. 2443 // the page id.
2436 // 2444 //
2437 // TODO(davidben): This should also take the failed navigation's replacement 2445 // TODO(davidben): This should also take the failed navigation's replacement
2438 // state into account, if a location.replace() failed. 2446 // state into account, if a location.replace() failed.
2447 ui::PageTransition transition = navigation_state->transition_type();
2439 bool replace = 2448 bool replace =
2440 navigation_state->pending_page_id() != -1 || 2449 navigation_state->pending_page_id() != -1 ||
2441 ui::PageTransitionCoreTypeIs(navigation_state->transition_type(), 2450 ui::PageTransitionCoreTypeIs(transition,
2442 ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2451 ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2452 bool replace2 =
2453 ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) ||
2454 transition & ui::PAGE_TRANSITION_FORWARD_BACK ||
2455 ui::PageTransitionCoreTypeIs(transition,
2456 ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2457 DCHECK_EQ(replace, replace2);
2443 2458
2444 // If we failed on a browser initiated request, then make sure that our error 2459 // If we failed on a browser initiated request, then make sure that our error
2445 // page load is regarded as the same browser initiated request. 2460 // page load is regarded as the same browser initiated request.
2446 if (!navigation_state->is_content_initiated()) { 2461 if (!navigation_state->is_content_initiated()) {
2447 render_view_->pending_navigation_params_.reset(new NavigationParams( 2462 render_view_->pending_navigation_params_.reset(new NavigationParams(
2448 CommonNavigationParams( 2463 CommonNavigationParams(
2449 error.unreachableURL, Referrer(), 2464 error.unreachableURL, Referrer(),
2450 navigation_state->transition_type(), FrameMsg_Navigate_Type::NORMAL, 2465 navigation_state->transition_type(), FrameMsg_Navigate_Type::NORMAL,
2451 true, base::TimeTicks(), 2466 true, base::TimeTicks(),
2452 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL()), 2467 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL()),
2453 StartNavigationParams(false, std::string(), 2468 StartNavigationParams(false, std::string(),
2454 std::vector<unsigned char>(), replace, -1, -1), 2469 std::vector<unsigned char>(), replace, -1, -1),
2455 CommitNavigationParams(false, base::TimeTicks(), std::vector<GURL>(), 2470 CommitNavigationParams(false, base::TimeTicks(), std::vector<GURL>(),
2456 false, std::string(), 2471 false, std::string(),
2457 document_state->request_time()), 2472 document_state->request_time()),
2458 HistoryNavigationParams( 2473 HistoryNavigationParams(
2459 PageState(), navigation_state->pending_page_id(), 2474 PageState(), navigation_state->pending_page_id(),
2475 navigation_state->pending_nav_entry_id(),
2460 navigation_state->pending_history_list_offset(), -1, 0, 2476 navigation_state->pending_history_list_offset(), -1, 0,
2461 navigation_state->history_list_was_cleared()))); 2477 navigation_state->history_list_was_cleared())));
2462 } 2478 }
2463 2479
2464 // Load an error page. 2480 // Load an error page.
2465 LoadNavigationErrorPage(failed_request, error, replace); 2481 LoadNavigationErrorPage(failed_request, error, replace);
2466 } 2482 }
2467 2483
2468 void RenderFrameImpl::didCommitProvisionalLoad( 2484 void RenderFrameImpl::didCommitProvisionalLoad(
2469 blink::WebLocalFrame* frame, 2485 blink::WebLocalFrame* frame,
(...skipping 28 matching lines...) Expand all
2498 2514
2499 if (document_state->commit_load_time().is_null()) 2515 if (document_state->commit_load_time().is_null())
2500 document_state->set_commit_load_time(Time::Now()); 2516 document_state->set_commit_load_time(Time::Now());
2501 2517
2502 if (internal_data->must_reset_scroll_and_scale_state()) { 2518 if (internal_data->must_reset_scroll_and_scale_state()) {
2503 render_view_->webview()->resetScrollAndScaleState(); 2519 render_view_->webview()->resetScrollAndScaleState();
2504 internal_data->set_must_reset_scroll_and_scale_state(false); 2520 internal_data->set_must_reset_scroll_and_scale_state(false);
2505 } 2521 }
2506 internal_data->set_use_error_page(false); 2522 internal_data->set_use_error_page(false);
2507 2523
2524 bool successful_history_nav = false;
2508 bool is_new_navigation = commit_type == blink::WebStandardCommit; 2525 bool is_new_navigation = commit_type == blink::WebStandardCommit;
2509 if (is_new_navigation) { 2526 if (is_new_navigation) {
2510 // We bump our Page ID to correspond with the new session history entry. 2527 // We bump our Page ID to correspond with the new session history entry.
2511 render_view_->page_id_ = render_view_->next_page_id_++; 2528 render_view_->page_id_ = render_view_->next_page_id_++;
2512 2529
2513 // Don't update history list values for kSwappedOutURL, since 2530 // Don't update history list values for kSwappedOutURL, since
2514 // we don't want to forget the entry that was there, and since we will 2531 // we don't want to forget the entry that was there, and since we will
2515 // never come back to kSwappedOutURL. Note that we have to call 2532 // never come back to kSwappedOutURL. Note that we have to call
2516 // UpdateSessionHistory and update page_id_ even in this case, so that 2533 // UpdateSessionHistory and update page_id_ even in this case, so that
2517 // the current entry gets a state update and so that we don't send a 2534 // the current entry gets a state update and so that we don't send a
(...skipping 18 matching lines...) Expand all
2536 // we've seen this commit before so that only capture session history once 2553 // we've seen this commit before so that only capture session history once
2537 // per navigation. 2554 // per navigation.
2538 // 2555 //
2539 // Note that we need to check if the page ID changed. In the case of a 2556 // Note that we need to check if the page ID changed. In the case of a
2540 // reload, the page ID doesn't change, and UpdateSessionHistory gets the 2557 // reload, the page ID doesn't change, and UpdateSessionHistory gets the
2541 // previous URL and the current page ID, which would be wrong. 2558 // previous URL and the current page ID, which would be wrong.
2542 if (navigation_state->pending_page_id() != -1 && 2559 if (navigation_state->pending_page_id() != -1 &&
2543 navigation_state->pending_page_id() != render_view_->page_id_ && 2560 navigation_state->pending_page_id() != render_view_->page_id_ &&
2544 !navigation_state->request_committed()) { 2561 !navigation_state->request_committed()) {
2545 // This is a successful session history navigation! 2562 // This is a successful session history navigation!
2563 successful_history_nav = true;
2546 render_view_->page_id_ = navigation_state->pending_page_id(); 2564 render_view_->page_id_ = navigation_state->pending_page_id();
2547 2565
2548 render_view_->history_list_offset_ = 2566 render_view_->history_list_offset_ =
2549 navigation_state->pending_history_list_offset(); 2567 navigation_state->pending_history_list_offset();
2550 } 2568 }
2551 } 2569 }
2552 2570
2571 if (commit_type == blink::WebBackForwardCommit) {
2572 // Checking the commit type is planned to be the replacement for the if()
2573 // block containing the comment "This is a successful session history
2574 // navigation!" Make sure that it fires correspondingly.
2575 DCHECK(successful_history_nav);
2576 }
2577
2553 bool sent = Send( 2578 bool sent = Send(
2554 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); 2579 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_));
2555 CHECK(sent); // http://crbug.com/407376 2580 CHECK(sent); // http://crbug.com/407376
2556 2581
2557 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, 2582 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_,
2558 DidCommitProvisionalLoad(frame, is_new_navigation)); 2583 DidCommitProvisionalLoad(frame, is_new_navigation));
2559 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, 2584 FOR_EACH_OBSERVER(RenderFrameObserver, observers_,
2560 DidCommitProvisionalLoad( 2585 DidCommitProvisionalLoad(
2561 is_new_navigation, 2586 is_new_navigation,
2562 navigation_state->was_within_same_page())); 2587 navigation_state->was_within_same_page()));
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
3697 3722
3698 DocumentState* document_state = DocumentState::FromDataSource(ds); 3723 DocumentState* document_state = DocumentState::FromDataSource(ds);
3699 NavigationState* navigation_state = document_state->navigation_state(); 3724 NavigationState* navigation_state = document_state->navigation_state();
3700 InternalDocumentStateData* internal_data = 3725 InternalDocumentStateData* internal_data =
3701 InternalDocumentStateData::FromDocumentState(document_state); 3726 InternalDocumentStateData::FromDocumentState(document_state);
3702 3727
3703 FrameHostMsg_DidCommitProvisionalLoad_Params params; 3728 FrameHostMsg_DidCommitProvisionalLoad_Params params;
3704 params.http_status_code = response.httpStatusCode(); 3729 params.http_status_code = response.httpStatusCode();
3705 params.url_is_unreachable = ds->hasUnreachableURL(); 3730 params.url_is_unreachable = ds->hasUnreachableURL();
3706 params.is_post = false; 3731 params.is_post = false;
3732 // params.commit_type = commit_type;
3733 params.did_create_new_entry = commit_type == blink::WebStandardCommit;
3707 params.post_id = -1; 3734 params.post_id = -1;
3708 params.page_id = render_view_->page_id_; 3735 params.page_id = render_view_->page_id_;
3736 params.nav_entry_id = navigation_state->pending_nav_entry_id();
3709 // We need to track the RenderViewHost routing_id because of downstream 3737 // We need to track the RenderViewHost routing_id because of downstream
3710 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, 3738 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager,
3711 // ResourceDispatcherHostImpl, MediaStreamUIProxy, 3739 // ResourceDispatcherHostImpl, MediaStreamUIProxy,
3712 // SpeechRecognitionDispatcherHost and possibly others). They look up the view 3740 // SpeechRecognitionDispatcherHost and possibly others). They look up the view
3713 // based on the ID stored in the resource requests. Once those dependencies 3741 // based on the ID stored in the resource requests. Once those dependencies
3714 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the 3742 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the
3715 // client to be based on the routing_id of the RenderFrameHost. 3743 // client to be based on the routing_id of the RenderFrameHost.
3716 params.render_view_routing_id = render_view_->routing_id(); 3744 params.render_view_routing_id = render_view_->routing_id();
3717 params.socket_address.set_host(response.remoteIPAddress().utf8()); 3745 params.socket_address.set_host(response.remoteIPAddress().utf8());
3718 params.socket_address.set_port(response.remotePort()); 3746 params.socket_address.set_port(response.remotePort());
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3922 WebURLRequest::CachePolicy cache_policy = 3950 WebURLRequest::CachePolicy cache_policy =
3923 WebURLRequest::UseProtocolCachePolicy; 3951 WebURLRequest::UseProtocolCachePolicy;
3924 if (!RenderFrameImpl::PrepareRenderViewForNavigation( 3952 if (!RenderFrameImpl::PrepareRenderViewForNavigation(
3925 common_params.url, is_history_navigation, history_params, &is_reload, 3953 common_params.url, is_history_navigation, history_params, &is_reload,
3926 &cache_policy)) { 3954 &cache_policy)) {
3927 return; 3955 return;
3928 } 3956 }
3929 3957
3930 GetContentClient()->SetActiveURL(common_params.url); 3958 GetContentClient()->SetActiveURL(common_params.url);
3931 3959
3932 // TODO(clamy): reset the pending navigation parameters in RenderView. 3960 // TODO(clamy): reset the pending navigation parameters in RenderView.
clamy 2015/03/16 10:39:55 As noted in the TODO here we do not reset the Navi
3933 3961
3934 if (!common_params.base_url_for_data_url.is_empty() || 3962 if (!common_params.base_url_for_data_url.is_empty() ||
3935 common_params.url.SchemeIs(url::kDataScheme)) { 3963 common_params.url.SchemeIs(url::kDataScheme)) {
3936 LoadDataURL(common_params, frame_); 3964 LoadDataURL(common_params, frame_);
3937 return; 3965 return;
3938 } 3966 }
3939 3967
3940 // Create a WebURLRequest that blink can use to get access to the body of the 3968 // Create a WebURLRequest that blink can use to get access to the body of the
3941 // response through a stream in the browser. Blink will then commit the 3969 // response through a stream in the browser. Blink will then commit the
3942 // navigation. 3970 // navigation.
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
4523 4551
4524 #if defined(ENABLE_BROWSER_CDMS) 4552 #if defined(ENABLE_BROWSER_CDMS)
4525 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4553 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4526 if (!cdm_manager_) 4554 if (!cdm_manager_)
4527 cdm_manager_ = new RendererCdmManager(this); 4555 cdm_manager_ = new RendererCdmManager(this);
4528 return cdm_manager_; 4556 return cdm_manager_;
4529 } 4557 }
4530 #endif // defined(ENABLE_BROWSER_CDMS) 4558 #endif // defined(ENABLE_BROWSER_CDMS)
4531 4559
4532 } // namespace content 4560 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698