Clean up ownership semantics for NavigateParams.
This CL is a refactor with no intended behavior change.
Previously, NavigateParams was a copy-able class that sometimes passed
ownership of its member target_contents to the Navigate() method. Furthermore,
target_contents was overloaded to have different semantics before, during, and
after the call to Navigate().
This CL makes NavigateParams a move-only class. It has the input parameter
|contents_to_insert| which explicitly passes ownership [with clear semantics] to
the Navigate() method. It has another input parameter |switch_to_singleton_tab|
to indicate that a tab switch should occur, but no ownership is passed. Finaly,
it has an output parameter |navigated_or_inserted_contents| which does not
convey ownership.
With these new semantics, the helper class ScopedTargetContentsOwner is no
longer necessary. Furthermore, the Navigate() method now uses an internal,
temporary variable |contents_to_navigate_or_insert| rather than overloading the
semantics of NavigateParams.target_contents.
This CL creates a new struct PrerenderManager::Params to function as both input
and output parameters to PrerenderManager::MaybeUsePrerenderedPage, rather than
overloading the NavigateParam struct to have different semantics.
Change-Id: Ic94284b9f6d2a0305375127858020271f7a97601
Bug: 832879
Reviewed-on: https://chromium-review.googlesource.com/1028458
Reviewed-by: Nico Weber <[email protected]>
Reviewed-by: Sergey Volk <[email protected]>
Reviewed-by: Ken Rockot <[email protected]>
Reviewed-by: Egor Pasko <[email protected]>
Commit-Queue: Erik Chen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#554128}
diff --git a/chrome/browser/ui/singleton_tabs.h b/chrome/browser/ui/singleton_tabs.h
index f9115b98..3dd4eb4 100644
--- a/chrome/browser/ui/singleton_tabs.h
+++ b/chrome/browser/ui/singleton_tabs.h
@@ -25,8 +25,7 @@
// As ShowSingletonTab, but if the current tab is the new tab page or
// about:blank, then overwrite it with the passed contents.
-void ShowSingletonTabOverwritingNTP(Browser* browser,
- const NavigateParams& params);
+void ShowSingletonTabOverwritingNTP(Browser* browser, NavigateParams params);
// Creates a NavigateParams struct for a singleton tab navigation.
NavigateParams GetSingletonTabNavigateParams(Browser* browser, const GURL& url);