summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui/dom_ui_theme_source.h
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 20:32:45 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 20:32:45 +0000
commit40da87c1bf6afe0e578ab22503ebc4b3e27d4359 (patch)
tree3d1c6cefd80858772046e2606ef356c02a50fd20 /chrome/browser/dom_ui/dom_ui_theme_source.h
parentea3a8586a45f7be17935bfdc8ba8a06191f14f5c (diff)
downloadchromium_src-40da87c1bf6afe0e578ab22503ebc4b3e27d4359.zip
chromium_src-40da87c1bf6afe0e578ab22503ebc4b3e27d4359.tar.gz
chromium_src-40da87c1bf6afe0e578ab22503ebc4b3e27d4359.tar.bz2
Improve New Tab Page load performance.
This change nets another 65ms (20%) improvement in the duration between the renderer requesting the NTP and it having all of the resources for the NTP available and being completely done with layout on my Mac laptop in release mode. Move the handling of important resource requests needed for NTP layout from the UI thread onto the IO thread. This is handled by caching the necessary data on the UI thread when possible, so that no profile or theme access is needed to service the request. There is often a lot of contention for the UI thread when a new tab is created, and allowing these requests to be handled more directly by the IO thread allows the renderer to lay the page out while the browser is still busy doing UI work. http://groups.google.com/group/chromium-dev/browse_thread/thread/7148074f807dc5f7 TEST=Do the new tab page and new incognito tab page still work? Are they faster? BUG=13337 Review URL: http://codereview.chromium.org/179069 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25232 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui/dom_ui_theme_source.h')
-rw-r--r--chrome/browser/dom_ui/dom_ui_theme_source.h23
1 files changed, 18 insertions, 5 deletions
diff --git a/chrome/browser/dom_ui/dom_ui_theme_source.h b/chrome/browser/dom_ui/dom_ui_theme_source.h
index 47a59f8..fa90eba 100644
--- a/chrome/browser/dom_ui/dom_ui_theme_source.h
+++ b/chrome/browser/dom_ui/dom_ui_theme_source.h
@@ -24,12 +24,20 @@ class DOMUIThemeSource : public ChromeURLDataManager::DataSource {
virtual void SendResponse(int request_id, RefCountedBytes* data);
- private:
- // Generate and send the CSS for the new tab.
- void SendNewTabCSS(int request_id);
+ virtual MessageLoop* MessageLoopForRequestPath(const std::string& path) const;
- // Generate and send the CSS for the new incognito tab.
- void SendNewIncognitoTabCSS(int request_id);
+ private:
+ // Populate new_tab_css_ and new_incognito_tab_css. These must be called
+ // from the UI thread because they involve profile and theme access.
+ //
+ // A new DOMUIThemeSource object is used for each new tab page instance
+ // and each reload of an existing new tab page, so there is no concern about
+ // cached data becoming stale.
+ void InitNewTabCSS();
+ void InitNewIncognitoTabCSS();
+
+ // Send the CSS for the new tab or the new incognito tab.
+ void SendNewTabCSS(int request_id, const std::string& css_string);
// Fetch and send the theme bitmap.
void SendThemeBitmap(int request_id, int resource_id);
@@ -42,6 +50,11 @@ class DOMUIThemeSource : public ChromeURLDataManager::DataSource {
// masks in browser_theme_provider.h).
std::string GetNewTabBackgroundTilingCSS();
+ // The content to be served by SendNewTabCSS, stored by InitNewTabCSS and
+ // InitNewIncognitoTabCSS.
+ std::string new_tab_css_;
+ std::string new_incognito_tab_css_;
+
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(DOMUIThemeSource);
};