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

Unified Diff: content/browser/frame_host/navigator_impl.cc

Issue 483773002: PlzNavigate: implement CommitNavigation on the browser side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using non-inherited structs Created 6 years, 3 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/browser/frame_host/navigator_impl.cc
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index ea9f921fc4de728d55746b0e285e3ddcd0d517ff..6436af3dd91b9e059dd67d745924d06b6f9e791b 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -71,26 +71,39 @@ RenderFrameHostManager* GetRenderManager(RenderFrameHostImpl* rfh) {
return rfh->frame_tree_node()->frame_tree()->root()->render_manager();
}
-} // namespace
-
+void InitializeCoreNavigationParams(
+ const NavigationEntryImpl& entry,
+ NavigationControllerImpl* controller,
+ NavigationController::ReloadType reload_type,
+ CoreNavigationParams* params) {
+ params->url = entry.GetURL();
+ params->referrer = entry.GetReferrer();
+ params->transition = entry.GetTransitionType();
+ params->navigation_type =
+ GetNavigationType(controller->GetBrowserContext(), entry, reload_type);
+ params->allow_download = !entry.IsViewSourceMode();
+}
-NavigatorImpl::NavigatorImpl(
- NavigationControllerImpl* navigation_controller,
- NavigatorDelegate* delegate)
- : controller_(navigation_controller),
- delegate_(delegate) {
+void InitializeRequestNavigationParams(const NavigationEntryImpl& entry,
+ RequestNavigationParams* params) {
+ params->is_post = entry.GetHasPostData();
+ // Avoid downloading when in view-source mode.
Charlie Reis 2014/09/19 23:12:31 This comment sounds like it belongs above line 84.
clamy 2014/09/23 21:13:25 Moved to the description of the parameter in CoreN
+ params->extra_headers = entry.extra_headers();
+ if (entry.GetBrowserInitiatedPostData()) {
+ params->browser_initiated_post_data.assign(
+ entry.GetBrowserInitiatedPostData()->front(),
+ entry.GetBrowserInitiatedPostData()->front() +
+ entry.GetBrowserInitiatedPostData()->size());
+ }
}
-// static.
-void NavigatorImpl::MakeNavigateParams(
+void InitializeCommitNavigationParams(
const NavigationEntryImpl& entry,
- const NavigationControllerImpl& controller,
- NavigationController::ReloadType reload_type,
+ NavigationControllerImpl* controller,
base::TimeTicks navigation_start,
- FrameMsg_Navigate_Params* params) {
+ CommitNavigationParams* params) {
params->page_id = entry.GetPageID();
params->should_clear_history_list = entry.should_clear_history_list();
- params->should_replace_current_entry = entry.should_replace_entry();
if (entry.should_clear_history_list()) {
// Set the history list related parameters to the same values a
// NavigationController would return before its first navigation. This will
@@ -99,44 +112,43 @@ void NavigatorImpl::MakeNavigateParams(
params->current_history_list_offset = -1;
params->current_history_list_length = 0;
} else {
- params->pending_history_list_offset = controller.GetIndexOfEntry(&entry);
+ params->pending_history_list_offset = controller->GetIndexOfEntry(&entry);
params->current_history_list_offset =
- controller.GetLastCommittedEntryIndex();
- params->current_history_list_length = controller.GetEntryCount();
+ controller->GetLastCommittedEntryIndex();
+ params->current_history_list_length = controller->GetEntryCount();
}
- params->url = entry.GetURL();
+ params->page_state = entry.GetPageState();
+ params->is_overriding_user_agent = entry.GetIsOverridingUserAgent();
+ params->browser_navigation_start = navigation_start;
+}
+
+void MakeNavigateParams(const NavigationEntryImpl& entry,
+ NavigationControllerImpl* controller,
+ NavigationController::ReloadType reload_type,
+ base::TimeTicks navigation_start,
+ FrameMsg_Navigate_Params* params) {
+ InitializeCoreNavigationParams(
+ entry, controller, reload_type, &params->core_params);
+ InitializeRequestNavigationParams(entry, &params->request_params);
+ InitializeCommitNavigationParams(
+ entry, controller, navigation_start, &params->commit_params);
if (!entry.GetBaseURLForDataURL().is_empty()) {
params->base_url_for_data_url = entry.GetBaseURLForDataURL();
params->history_url_for_data_url = entry.GetVirtualURL();
}
- params->referrer = entry.GetReferrer();
- params->transition = entry.GetTransitionType();
- params->page_state = entry.GetPageState();
- params->navigation_type =
- GetNavigationType(controller.GetBrowserContext(), entry, reload_type);
+ params->should_replace_current_entry = entry.should_replace_entry();
// This is used by the old performance infrastructure to set up DocumentState
// associated with the RenderView.
// TODO(ppi): make it go away.
params->request_time = base::Time::Now();
- params->extra_headers = entry.extra_headers();
params->transferred_request_child_id =
entry.transferred_global_request_id().child_id;
params->transferred_request_request_id =
entry.transferred_global_request_id().request_id;
- params->is_overriding_user_agent = entry.GetIsOverridingUserAgent();
- // Avoid downloading when in view-source mode.
- params->allow_download = !entry.IsViewSourceMode();
- params->is_post = entry.GetHasPostData();
- if (entry.GetBrowserInitiatedPostData()) {
- params->browser_initiated_post_data.assign(
- entry.GetBrowserInitiatedPostData()->front(),
- entry.GetBrowserInitiatedPostData()->front() +
- entry.GetBrowserInitiatedPostData()->size());
- }
// Set the redirect chain to the navigation's redirects, unless we are
// returning to a completed navigation (whose previous redirects don't apply).
- if (PageTransitionIsNewNavigation(params->transition)) {
+ if (PageTransitionIsNewNavigation(params->core_params.transition)) {
params->redirects = entry.GetRedirectChain();
} else {
params->redirects.clear();
@@ -144,7 +156,16 @@ void NavigatorImpl::MakeNavigateParams(
params->can_load_local_resources = entry.GetCanLoadLocalResources();
params->frame_to_navigate = entry.GetFrameToNavigate();
- params->browser_navigation_start = navigation_start;
+}
+
+} // namespace
+
+
+NavigatorImpl::NavigatorImpl(
+ NavigationControllerImpl* navigation_controller,
+ NavigatorDelegate* delegate)
+ : controller_(navigation_controller),
+ delegate_(delegate) {
}
NavigationController* NavigatorImpl::GetController() {
@@ -342,7 +363,6 @@ bool NavigatorImpl::NavigateToEntry(
// capture the time needed for the RenderFrameHost initialization.
base::TimeTicks navigation_start = base::TimeTicks::Now();
- FrameMsg_Navigate_Params navigate_params;
RenderFrameHostManager* manager =
render_frame_host->frame_tree_node()->render_manager();
@@ -351,10 +371,17 @@ bool NavigatorImpl::NavigateToEntry(
// node.
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation)) {
- // Create the navigation parameters.
- MakeNavigateParams(
- entry, *controller_, reload_type, navigation_start, &navigate_params);
- return manager->RequestNavigation(entry, navigate_params);
+ scoped_ptr<CoreNavigationParams> core_params(new CoreNavigationParams());
+ scoped_ptr<CommitNavigationParams> commit_params(
+ new CommitNavigationParams());
+ RequestNavigationParams request_params;
Charlie Reis 2014/09/19 23:12:31 Why are the first two scoped_ptrs and this one isn
clamy 2014/09/23 21:13:25 Following changes in ownership of the *Params, the
+ InitializeCoreNavigationParams(
+ entry, controller_, reload_type, core_params.get());
+ InitializeCommitNavigationParams(
+ entry, controller_, navigation_start, commit_params.get());
+ InitializeRequestNavigationParams(entry, &request_params);
+ return manager->RequestNavigation(
+ core_params.Pass(), request_params, commit_params.Pass());
}
RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry);
@@ -376,8 +403,9 @@ bool NavigatorImpl::NavigateToEntry(
// Create the navigation parameters.
// TODO(vitalybuka): Move this before AboutToNavigateRenderFrame once
// http://crbug.com/408684 is fixed.
+ FrameMsg_Navigate_Params navigate_params;
MakeNavigateParams(
- entry, *controller_, reload_type, navigation_start, &navigate_params);
+ entry, controller_, reload_type, navigation_start, &navigate_params);
// Navigate in the desired RenderFrameHost.
// We can skip this step in the rare case that this is a transfer navigation
@@ -659,11 +687,23 @@ void NavigatorImpl::RequestTransferURL(
void NavigatorImpl::CommitNavigation(
RenderFrameHostImpl* render_frame_host,
- const NavigationBeforeCommitInfo& info) {
- CheckWebUIRendererDoesNotDisplayNormalURL(
- render_frame_host, info.navigation_url);
- // TODO(clamy): the render_frame_host should now send a commit IPC to the
- // renderer.
+ const GURL& stream_url,
+ const CoreNavigationParams& core_params,
+ const CommitNavigationParams& commit_params) {
+ CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, core_params.url);
+ render_frame_host->CommitNavigation(stream_url, core_params, commit_params);
+}
+
+void NavigatorImpl::MakeNavigationParamsForTest(
+ const NavigationEntryImpl& entry,
+ NavigationController::ReloadType reload_type,
+ CoreNavigationParams* core_params,
+ RequestNavigationParams* request_params,
+ CommitNavigationParams* commit_params) {
+ InitializeCoreNavigationParams(entry, controller_, reload_type, core_params);
+ InitializeRequestNavigationParams(entry, request_params);
+ InitializeCommitNavigationParams(
+ entry, controller_, base::TimeTicks::Now(), commit_params);
}
void NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(

Powered by Google App Engine
This is Rietveld 408576698