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

Unified Diff: chrome/browser/chrome_browser_main_win.cc

Issue 1845063002: Revert of Remove font cache code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | chrome/chrome_utility.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_browser_main_win.cc
diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc
index 3a996d66a8f5d9c7d8b9e074a54edd37fef51573..3273de1e959d9343ebfd3d826a16352fe57c90a6 100644
--- a/chrome/browser/chrome_browser_main_win.cc
+++ b/chrome/browser/chrome_browser_main_win.cc
@@ -56,6 +56,7 @@
#include "content/public/browser/utility_process_host.h"
#include "content/public/browser/utility_process_host_client.h"
#include "content/public/common/content_switches.h"
+#include "content/public/common/dwrite_font_platform_win.h"
#include "content/public/common/main_function_params.h"
#include "ui/base/cursor/cursor_loader_win.h"
#include "ui/base/l10n/l10n_util.h"
@@ -64,6 +65,7 @@
#include "ui/base/win/message_box_win.h"
#include "ui/gfx/platform_font_win.h"
#include "ui/gfx/switches.h"
+#include "ui/gfx/win/direct_write.h"
#include "ui/strings/grit/app_locale_settings.h"
#if defined(GOOGLE_CHROME_BUILD)
@@ -107,6 +109,16 @@
public:
base::string16 GetLocalizedString(int installer_string_id) override;
};
+
+void ExecuteFontCacheBuildTask(const base::FilePath& path) {
+ base::WeakPtr<content::UtilityProcessHost> utility_process_host(
+ content::UtilityProcessHost::Create(NULL, NULL)->AsWeakPtr());
+ utility_process_host->SetName(
+ l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_FONT_CACHE_BUILDER_NAME));
+ utility_process_host->DisableSandbox();
+ utility_process_host->Send(
+ new ChromeUtilityHostMsg_BuildDirectWriteFontCache(path));
+}
#if BUILDFLAG(ENABLE_KASKO)
void ObserveFailedCrashReportDirectory(const base::FilePath& path, bool error) {
@@ -312,6 +324,37 @@
void ChromeBrowserMainPartsWin::PostProfileInit() {
ChromeBrowserMainParts::PostProfileInit();
+
+ // DirectWrite support is mainly available Windows 7 and up.
+ // Skip loading the font cache if we are using the font proxy field trial.
+ if (gfx::win::ShouldUseDirectWrite() &&
+ !content::ShouldUseDirectWriteFontProxyFieldTrial()) {
+ base::FilePath path(
+ profile()->GetPath().AppendASCII(content::kFontCacheSharedSectionName));
+ // This function will create a read only section if cache file exists
+ // otherwise it will spawn utility process to build cache file, which will
+ // be used during next browser start/postprofileinit.
+ if (!content::LoadFontCache(path)) {
+ // We delay building of font cache until first startup page loads.
+ // During first renderer start there are lot of things happening
+ // simultaneously some of them are:
+ // - Renderer is going through all font files on the system to create a
+ // font collection.
+ // - Renderer loading up startup URL, accessing HTML/JS File cache, net
+ // activity etc.
+ // - Extension initialization.
+ // We delay building of cache mainly to avoid parallel font file loading
+ // along with Renderer. Some systems have significant number of font files
+ // which takes long time to process.
+ // Related information is at http://crbug.com/436195.
+ const int kBuildFontCacheDelaySec = 30;
+ content::BrowserThread::PostDelayedTask(
+ content::BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(ExecuteFontCacheBuildTask, path),
+ base::TimeDelta::FromSeconds(kBuildFontCacheDelaySec));
+ }
+ }
}
void ChromeBrowserMainPartsWin::PostBrowserStart() {
« no previous file with comments | « no previous file | chrome/chrome_utility.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698