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

Unified Diff: chrome/browser/ui/webui/theme_source.cc

Issue 2886973003: ThemeSource: simplify thread hopping for NTP CSS (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/theme_source.cc
diff --git a/chrome/browser/ui/webui/theme_source.cc b/chrome/browser/ui/webui/theme_source.cc
index 2bcf02cbc1bab52a7980f88b3faa00cb9cb2975d..a48745c145e1ba2bd50221100c9da4b486a4f684 100644
--- a/chrome/browser/ui/webui/theme_source.cc
+++ b/chrome/browser/ui/webui/theme_source.cc
@@ -62,14 +62,6 @@ void ProcessResourceOnUiThread(int resource_id,
scale, data);
}
-base::RefCountedMemory* GetNewTabCSSOnUiThread(Profile* profile) {
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-
- NTPResourceCache::WindowType type =
- NTPResourceCache::GetWindowType(profile, nullptr);
- return NTPResourceCacheFactory::GetForProfile(profile)->GetNewTabCSS(type);
-}
-
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -77,8 +69,7 @@ base::RefCountedMemory* GetNewTabCSSOnUiThread(Profile* profile) {
ThemeSource::ThemeSource(Profile* profile) : profile_(profile) {}
-ThemeSource::~ThemeSource() {
-}
+ThemeSource::~ThemeSource() = default;
std::string ThemeSource::GetSource() const {
return chrome::kChromeUIThemeHost;
@@ -94,11 +85,11 @@ void ThemeSource::StartDataRequest(
webui::ParsePathAndScale(GetThemeUrl(path), &parsed_path, &scale);
if (IsNewTabCssPath(parsed_path)) {
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- // NB: it's important that this is |profile_| and not |original_profile_|.
- content::BrowserThread::PostTaskAndReplyWithResult(
- content::BrowserThread::UI, FROM_HERE,
- base::Bind(&GetNewTabCSSOnUiThread, profile_), callback);
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ NTPResourceCache::WindowType type =
+ NTPResourceCache::GetWindowType(profile_, /*render_host=*/nullptr);
+ NTPResourceCache* cache = NTPResourceCacheFactory::GetForProfile(profile_);
+ callback.Run(cache->GetNewTabCSS(type));
return;
}
@@ -167,9 +158,9 @@ ThemeSource::TaskRunnerForRequestPath(const std::string& path) const {
webui::ParsePathAndScale(GetThemeUrl(path), &parsed_path, nullptr);
if (IsNewTabCssPath(parsed_path)) {
- // We generated and cached this when we initialized the object. We don't
- // have to go back to the UI thread to send the data.
- return nullptr;
+ // We'll get this data from the NTPResourceCache, which must be accessed on
+ // the UI thread.
+ return content::URLDataSource::TaskRunnerForRequestPath(path);
}
// If it's not a themeable image, we don't need to go to the UI thread.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698