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

Side by Side Diff: chrome/browser/dom_ui/dom_ui_theme_source.h

Issue 179069: Improve New Tab Page load performance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_DOM_UI_DOM_UI_THEME_SOURCE_H_ 5 #ifndef CHROME_BROWSER_DOM_UI_DOM_UI_THEME_SOURCE_H_
6 #define CHROME_BROWSER_DOM_UI_DOM_UI_THEME_SOURCE_H_ 6 #define CHROME_BROWSER_DOM_UI_DOM_UI_THEME_SOURCE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" 10 #include "chrome/browser/dom_ui/chrome_url_data_manager.h"
11 11
12 class Profile; 12 class Profile;
13 13
14 // ThumbnailSource is the gateway between network-level chrome: 14 // ThumbnailSource is the gateway between network-level chrome:
15 // requests for thumbnails and the history backend that serves these. 15 // requests for thumbnails and the history backend that serves these.
16 class DOMUIThemeSource : public ChromeURLDataManager::DataSource { 16 class DOMUIThemeSource : public ChromeURLDataManager::DataSource {
17 public: 17 public:
18 explicit DOMUIThemeSource(Profile* profile); 18 explicit DOMUIThemeSource(Profile* profile);
19 19
20 // Called when the network layer has requested a resource underneath 20 // Called when the network layer has requested a resource underneath
21 // the path we registered. 21 // the path we registered.
22 virtual void StartDataRequest(const std::string& path, int request_id); 22 virtual void StartDataRequest(const std::string& path, int request_id);
23 virtual std::string GetMimeType(const std::string& path) const; 23 virtual std::string GetMimeType(const std::string& path) const;
24 24
25 virtual void SendResponse(int request_id, RefCountedBytes* data); 25 virtual void SendResponse(int request_id, RefCountedBytes* data);
26 26
27 virtual MessageLoop* MessageLoopForRequestPath(const std::string& path) const;
28
27 private: 29 private:
28 // Generate and send the CSS for the new tab. 30 // Populate new_tab_css_ and new_incognito_tab_css. These must be called
29 void SendNewTabCSS(int request_id); 31 // from the UI thread because they involve profile and theme access.
32 //
33 // A new DOMUIThemeSource object is used for each new tab page instance
34 // and each reload of an existing new tab page, so there is no concern about
35 // cached data becoming stale.
36 void InitNewTabCSS();
37 void InitNewIncognitoTabCSS();
30 38
31 // Generate and send the CSS for the new incognito tab. 39 // Send the CSS for the new tab or the new incognito tab.
32 void SendNewIncognitoTabCSS(int request_id); 40 void SendNewTabCSS(int request_id, const std::string& css_string);
33 41
34 // Fetch and send the theme bitmap. 42 // Fetch and send the theme bitmap.
35 void SendThemeBitmap(int request_id, int resource_id); 43 void SendThemeBitmap(int request_id, int resource_id);
36 44
37 // Get the CSS string for the background position on the new tab page for the 45 // Get the CSS string for the background position on the new tab page for the
38 // states when the bar is attached or detached. 46 // states when the bar is attached or detached.
39 std::string GetNewTabBackgroundCSS(bool bar_attached); 47 std::string GetNewTabBackgroundCSS(bool bar_attached);
40 48
41 // How the background image on the new tab page should be tiled (see tiling 49 // How the background image on the new tab page should be tiled (see tiling
42 // masks in browser_theme_provider.h). 50 // masks in browser_theme_provider.h).
43 std::string GetNewTabBackgroundTilingCSS(); 51 std::string GetNewTabBackgroundTilingCSS();
44 52
53 // The content to be served by SendNewTabCSS, stored by InitNewTabCSS and
54 // InitNewIncognitoTabCSS.
55 std::string new_tab_css_;
56 std::string new_incognito_tab_css_;
57
45 Profile* profile_; 58 Profile* profile_;
46 DISALLOW_COPY_AND_ASSIGN(DOMUIThemeSource); 59 DISALLOW_COPY_AND_ASSIGN(DOMUIThemeSource);
47 }; 60 };
48 61
49 #endif // CHROME_BROWSER_DOM_UI_DOM_UI_THEME_SOURCE_H_ 62 #endif // CHROME_BROWSER_DOM_UI_DOM_UI_THEME_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698