summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-24 20:35:59 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-24 20:35:59 +0000
commit9e3a9a5085c46b4e6f6024638b295593f1a28293 (patch)
tree242861f0ca9c6a91082404ef76338260796ecfcf /chrome/browser/dom_ui
parent78065c11403827aa9a21547c1c5bfb38cd870d08 (diff)
downloadchromium_src-9e3a9a5085c46b4e6f6024638b295593f1a28293.zip
chromium_src-9e3a9a5085c46b4e6f6024638b295593f1a28293.tar.gz
chromium_src-9e3a9a5085c46b4e6f6024638b295593f1a28293.tar.bz2
Merge in part of the last perf change. Move when we initialize
the CSS/HTML for the NTP. This should allow the history query to happen sooner. Move the first_view logic out of NewTabHTMLSource. It can cause the CSS cache to get flushed, so make sure to run it before the CSS is generated. Also make sure we only hang on to the original profile. I think the incognito profile can be deleted out from under us when the last incognito window is closed. Review URL: http://codereview.chromium.org/434038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32965 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/dom_ui_theme_source.cc2
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc42
2 files changed, 24 insertions, 20 deletions
diff --git a/chrome/browser/dom_ui/dom_ui_theme_source.cc b/chrome/browser/dom_ui/dom_ui_theme_source.cc
index bc3a0aa..3640c40 100644
--- a/chrome/browser/dom_ui/dom_ui_theme_source.cc
+++ b/chrome/browser/dom_ui/dom_ui_theme_source.cc
@@ -28,7 +28,7 @@ static std::string StripQueryParams(const std::string& path) {
DOMUIThemeSource::DOMUIThemeSource(Profile* profile)
: DataSource(chrome::kChromeUIThemePath, MessageLoop::current()),
- profile_(profile) {
+ profile_(profile->GetOriginalProfile()) {
css_bytes_ = profile_->GetNTPResourceCache()->GetNewTabCSS(
profile->IsOffTheRecord());
}
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index a69a4ba..3f0dbf2 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -480,15 +480,16 @@ NewTabUI::NewTabUI(TabContents* contents)
if (NewTabUI::FirstRunDisabled())
NewTabHTMLSource::set_first_run(false);
- InitializeCSSCaches();
- NewTabHTMLSource* html_source =
- new NewTabHTMLSource(GetProfile()->GetOriginalProfile());
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
- NewRunnableMethod(
- Singleton<ChromeURLDataManager>::get(),
- &ChromeURLDataManager::AddDataSource,
- make_scoped_refptr(html_source)));
+ static bool first_view = true;
+ if (first_view) {
+ // Decrement ntp promo counters; the default values are specified in
+ // Browser::RegisterUserPrefs.
+ profile->GetPrefs()->SetInteger(prefs::kNTPPromoLineRemaining,
+ profile->GetPrefs()->GetInteger(prefs::kNTPPromoLineRemaining) - 1);
+ profile->GetPrefs()->SetInteger(prefs::kNTPPromoImageRemaining,
+ profile->GetPrefs()->GetInteger(prefs::kNTPPromoImageRemaining) - 1);
+ first_view = false;
+ }
if (!GetProfile()->IsOffTheRecord()) {
AddMessageHandler((new ShownSectionsHandler())->Attach(this));
@@ -505,6 +506,19 @@ NewTabUI::NewTabUI(TabContents* contents)
AddMessageHandler((new PromotionalMessageHandler())->Attach(this));
}
+ // Initializing the CSS and HTML can require some CPU, so do it after
+ // we've hooked up the most visited handler. This allows the DB query
+ // for the new tab thumbs to happen earlier.
+ InitializeCSSCaches();
+ NewTabHTMLSource* html_source =
+ new NewTabHTMLSource(GetProfile()->GetOriginalProfile());
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ Singleton<ChromeURLDataManager>::get(),
+ &ChromeURLDataManager::AddDataSource,
+ make_scoped_refptr(html_source)));
+
// Listen for theme installation.
registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
NotificationService::AllSources());
@@ -651,16 +665,6 @@ bool NewTabUI::NewTabHTMLSource::first_run_ = true;
NewTabUI::NewTabHTMLSource::NewTabHTMLSource(Profile* profile)
: DataSource(chrome::kChromeUINewTabHost, MessageLoop::current()),
profile_(profile) {
- static bool first_view = true;
- if (first_view) {
- // Decrement ntp promo counters; the default values are specified in
- // Browser::RegisterUserPrefs.
- profile->GetPrefs()->SetInteger(prefs::kNTPPromoLineRemaining,
- profile->GetPrefs()->GetInteger(prefs::kNTPPromoLineRemaining) - 1);
- profile->GetPrefs()->SetInteger(prefs::kNTPPromoImageRemaining,
- profile->GetPrefs()->GetInteger(prefs::kNTPPromoImageRemaining) - 1);
- first_view = false;
- }
}
void NewTabUI::NewTabHTMLSource::StartDataRequest(const std::string& path,