Commit f73e72f9 authored by samarth@chromium.org's avatar samarth@chromium.org

InstantExtended: don't preload the local NTP.

In local-only mode, don't bother preloading the Instant NTP. The speed savings
of preloading a local page are minimal and this will help reduce the memory
usage.

BUG=none

Review URL: https://chromiumcodereview.appspot.com/14232007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194982 0039d316-1c4b-4281-b951-d872f2087c98
parent 91ee55bb
...@@ -220,7 +220,7 @@ InstantController::InstantController(BrowserInstantController* browser, ...@@ -220,7 +220,7 @@ InstantController::InstantController(BrowserInstantController* browser,
: browser_(browser), : browser_(browser),
extended_enabled_(extended_enabled), extended_enabled_(extended_enabled),
instant_enabled_(false), instant_enabled_(false),
use_local_overlay_only_(true), use_local_page_only_(true),
model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
last_omnibox_text_has_inline_autocompletion_(false), last_omnibox_text_has_inline_autocompletion_(false),
last_verbatim_(false), last_verbatim_(false),
...@@ -504,8 +504,16 @@ scoped_ptr<content::WebContents> InstantController::ReleaseNTPContents() { ...@@ -504,8 +504,16 @@ scoped_ptr<content::WebContents> InstantController::ReleaseNTPContents() {
scoped_ptr<content::WebContents> ntp_contents = ntp_->ReleaseContents(); scoped_ptr<content::WebContents> ntp_contents = ntp_->ReleaseContents();
// Override the blacklist on an explicit user action. if (!use_local_page_only_) {
ResetNTP(true, false); // Preload a new Instant NTP, unless using the local NTP which is not
// preloaded to conserve memory.
//
// Since this corresponds to a user action, give the remote page another
// try, even if it's blacklisted. We don't want to blacklist pages for the
// duration of a Browser object (for some people, that's effectively
// "forever").
ResetNTP(true, false);
}
return ntp_contents.Pass(); return ntp_contents.Pass();
} }
...@@ -887,26 +895,33 @@ void InstantController::TabDeactivated(content::WebContents* contents) { ...@@ -887,26 +895,33 @@ void InstantController::TabDeactivated(content::WebContents* contents) {
} }
void InstantController::SetInstantEnabled(bool instant_enabled, void InstantController::SetInstantEnabled(bool instant_enabled,
bool use_local_overlay_only) { bool use_local_page_only) {
LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf( LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf(
"SetInstantEnabled: instant_enabled=%d, use_local_overlay_only=%d", "SetInstantEnabled: instant_enabled=%d, use_local_page_only=%d",
instant_enabled, use_local_overlay_only)); instant_enabled, use_local_page_only));
// Non extended mode does not care about |use_local_overlay_only|. // Non extended mode does not care about |use_local_page_only|.
if (instant_enabled == instant_enabled_ && if (instant_enabled == instant_enabled_ &&
(!extended_enabled_ || (!extended_enabled_ ||
use_local_overlay_only == use_local_overlay_only_)) { use_local_page_only == use_local_page_only_)) {
return; return;
} }
instant_enabled_ = instant_enabled; instant_enabled_ = instant_enabled;
use_local_overlay_only_ = use_local_overlay_only; use_local_page_only_ = use_local_page_only;
HideInternal(); HideInternal();
overlay_.reset(); overlay_.reset();
if (extended_enabled_ || instant_enabled_) if (extended_enabled_ || instant_enabled_)
EnsureOverlayIsCurrent(false); EnsureOverlayIsCurrent(false);
if (extended_enabled_) if (extended_enabled_) {
ResetNTP(false, false); // Preload the Instant NTP. But if we are using the local NTP, delete any
// existing preloaded NTP (which we should no longer use) and don't preload
// the local one to conserve memory.
if (use_local_page_only_)
ntp_.reset();
else
ResetNTP(false, false);
}
if (instant_tab_) if (instant_tab_)
instant_tab_->SetDisplayInstantResults(instant_enabled_); instant_tab_->SetDisplayInstantResults(instant_enabled_);
} }
...@@ -1449,7 +1464,7 @@ void InstantController::SendPopupBoundsToPage() { ...@@ -1449,7 +1464,7 @@ void InstantController::SendPopupBoundsToPage() {
bool InstantController::GetInstantURL(Profile* profile, bool InstantController::GetInstantURL(Profile* profile,
bool ignore_blacklist, bool ignore_blacklist,
std::string* instant_url) const { std::string* instant_url) const {
if (extended_enabled_ && use_local_overlay_only_) if (extended_enabled_ && use_local_page_only_)
return false; return false;
const GURL instant_url_obj = chrome::GetInstantURL(profile, const GURL instant_url_obj = chrome::GetInstantURL(profile,
......
...@@ -154,10 +154,10 @@ class InstantController : public InstantPage::Delegate, ...@@ -154,10 +154,10 @@ class InstantController : public InstantPage::Delegate,
// The user is about to switch tabs. Commit the overlay if needed. // The user is about to switch tabs. Commit the overlay if needed.
void TabDeactivated(content::WebContents* contents); void TabDeactivated(content::WebContents* contents);
// Sets whether Instant should show result overlays. |use_local_overlay_only| // Sets whether Instant should show result overlays. |use_local_page_only|
// will force the use of kLocalOmniboxPopupURL as the Instant URL and is only // will force the use of baked-in page as the Instant URL and is only
// applicable if |extended_enabled_| is true. // applicable if |extended_enabled_| is true.
void SetInstantEnabled(bool instant_enabled, bool use_local_overlay_only); void SetInstantEnabled(bool instant_enabled, bool use_local_page_only);
// The theme has changed. Pass the message to the overlay page. // The theme has changed. Pass the message to the overlay page.
void ThemeChanged(const ThemeBackgroundInfo& theme_info); void ThemeChanged(const ThemeBackgroundInfo& theme_info);
...@@ -223,7 +223,7 @@ class InstantController : public InstantPage::Delegate, ...@@ -223,7 +223,7 @@ class InstantController : public InstantPage::Delegate,
FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ValidatesSuggestions); FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ValidatesSuggestions);
FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest,
OmniboxCommitsWhenShownFullHeight); OmniboxCommitsWhenShownFullHeight);
FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, LocalNTPIsNotLocalOverlay); FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, LocalNTPIsNotPreloaded);
FRIEND_TEST_ALL_PREFIXES(InstantExtendedManualTest, FRIEND_TEST_ALL_PREFIXES(InstantExtendedManualTest,
MANUAL_OmniboxFocusLoadsInstant); MANUAL_OmniboxFocusLoadsInstant);
...@@ -377,7 +377,7 @@ class InstantController : public InstantPage::Delegate, ...@@ -377,7 +377,7 @@ class InstantController : public InstantPage::Delegate,
bool instant_enabled_; bool instant_enabled_;
// If true, the Instant URL is set to kLocalOmniboxPopupURL. // If true, the Instant URL is set to kLocalOmniboxPopupURL.
bool use_local_overlay_only_; bool use_local_page_only_;
// The state of the overlay page, i.e., the page owned by |overlay_|. Ignored // The state of the overlay page, i.e., the page owned by |overlay_|. Ignored
// if |instant_tab_| is in use. // if |instant_tab_| is in use.
......
...@@ -1482,17 +1482,16 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, AutocompleteProvidersDone) { ...@@ -1482,17 +1482,16 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, AutocompleteProvidersDone) {
EXPECT_EQ(1, on_native_suggestions_calls_); EXPECT_EQ(1, on_native_suggestions_calls_);
} }
// Test that the local NTP doesn't end up with the local overlay's URL. // Test that the local NTP is not preloaded.
IN_PROC_BROWSER_TEST_F(InstantExtendedTest, LocalNTPIsNotLocalOverlay) { IN_PROC_BROWSER_TEST_F(InstantExtendedTest, LocalNTPIsNotPreloaded) {
ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
EXPECT_EQ(instant_url(), instant()->ntp_->contents()->GetURL()); EXPECT_EQ(instant_url(), instant()->ntp_->contents()->GetURL());
// The second argument says to use only the local overlay. // The second argument says to use only the local overlay and NTP.
instant()->SetInstantEnabled(false, true); instant()->SetInstantEnabled(false, true);
EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), EXPECT_EQ(NULL, instant()->ntp());
instant()->ntp_->contents()->GetURL());
} }
// Verify top bars visibility when searching on |DEFAULT| pages and switching // Verify top bars visibility when searching on |DEFAULT| pages and switching
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment