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

Unified Diff: chrome/browser/chrome_browser_main_win.cc

Issue 724633002: DirectWrite Font Cache browser side hookup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Enforcing cache file size limit 20MB and reducing cached percentile. Created 6 years, 1 month 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 | « chrome/browser/chrome_browser_main_win.h ('k') | 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 aa39454cb351e898861143b35750f3d58938c87c..9a62aa876ea7144b6b2f3cb0288df812b47e8bbf 100644
--- a/chrome/browser/chrome_browser_main_win.cc
+++ b/chrome/browser/chrome_browser_main_win.cc
@@ -12,6 +12,7 @@
#include "base/command_line.h"
#include "base/environment.h"
#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/i18n/rtl.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
@@ -36,6 +37,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/chrome_utility_messages.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/terminate_on_heap_corruption_experiment_win.h"
@@ -47,7 +49,10 @@
#include "chrome/installer/util/l10n_string_util.h"
#include "chrome/installer/util/shell_util.h"
#include "content/public/browser/browser_thread.h"
+#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 "installer_util_strings/installer_util_strings.h"
#include "ui/base/cursor/cursor_loader_win.h"
@@ -57,6 +62,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"
namespace {
@@ -97,6 +103,14 @@ bool IsSafeModeStart() {
return ::GetEnvironmentVariableA(chrome::kSafeModeEnvVar, NULL, 0) != 0;
}
+void ExecuteFontCacheBuildTask(const base::FilePath& path) {
+ base::WeakPtr<content::UtilityProcessHost> utility_process_host(
+ content::UtilityProcessHost::Create(NULL, NULL)->AsWeakPtr());
+ utility_process_host->DisableSandbox();
+ utility_process_host->Send(
+ new ChromeUtilityHostMsg_BuildDirectWriteFontCache(path));
+}
+
} // namespace
void ShowCloseBrowserFirstMessageBox() {
@@ -244,6 +258,24 @@ void ChromeBrowserMainPartsWin::ShowMissingLocaleMessageBox() {
MB_OK | MB_ICONERROR | MB_TOPMOST);
}
+void ChromeBrowserMainPartsWin::PostProfileInit() {
+ ChromeBrowserMainParts::PostProfileInit();
+
+ // DirectWrite support is mainly available Windows 7 and up.
+ if (gfx::win::ShouldUseDirectWrite()) {
+ 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)) {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(ExecuteFontCacheBuildTask, path));
+ }
+ }
+}
+
void ChromeBrowserMainPartsWin::PostBrowserStart() {
ChromeBrowserMainParts::PostBrowserStart();
« no previous file with comments | « chrome/browser/chrome_browser_main_win.h ('k') | chrome/chrome_utility.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698