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

Side by Side 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, 8 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
« no previous file with comments | « no previous file | chrome/chrome_utility.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/chrome_browser_main_win.h" 5 #include "chrome/browser/chrome_browser_main_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "chrome/installer/util/browser_distribution.h" 49 #include "chrome/installer/util/browser_distribution.h"
50 #include "chrome/installer/util/helper.h" 50 #include "chrome/installer/util/helper.h"
51 #include "chrome/installer/util/install_util.h" 51 #include "chrome/installer/util/install_util.h"
52 #include "chrome/installer/util/installer_util_strings.h" 52 #include "chrome/installer/util/installer_util_strings.h"
53 #include "chrome/installer/util/l10n_string_util.h" 53 #include "chrome/installer/util/l10n_string_util.h"
54 #include "chrome/installer/util/shell_util.h" 54 #include "chrome/installer/util/shell_util.h"
55 #include "content/public/browser/browser_thread.h" 55 #include "content/public/browser/browser_thread.h"
56 #include "content/public/browser/utility_process_host.h" 56 #include "content/public/browser/utility_process_host.h"
57 #include "content/public/browser/utility_process_host_client.h" 57 #include "content/public/browser/utility_process_host_client.h"
58 #include "content/public/common/content_switches.h" 58 #include "content/public/common/content_switches.h"
59 #include "content/public/common/dwrite_font_platform_win.h"
59 #include "content/public/common/main_function_params.h" 60 #include "content/public/common/main_function_params.h"
60 #include "ui/base/cursor/cursor_loader_win.h" 61 #include "ui/base/cursor/cursor_loader_win.h"
61 #include "ui/base/l10n/l10n_util.h" 62 #include "ui/base/l10n/l10n_util.h"
62 #include "ui/base/l10n/l10n_util_win.h" 63 #include "ui/base/l10n/l10n_util_win.h"
63 #include "ui/base/ui_base_switches.h" 64 #include "ui/base/ui_base_switches.h"
64 #include "ui/base/win/message_box_win.h" 65 #include "ui/base/win/message_box_win.h"
65 #include "ui/gfx/platform_font_win.h" 66 #include "ui/gfx/platform_font_win.h"
66 #include "ui/gfx/switches.h" 67 #include "ui/gfx/switches.h"
68 #include "ui/gfx/win/direct_write.h"
67 #include "ui/strings/grit/app_locale_settings.h" 69 #include "ui/strings/grit/app_locale_settings.h"
68 70
69 #if defined(GOOGLE_CHROME_BUILD) 71 #if defined(GOOGLE_CHROME_BUILD)
70 #include "chrome/browser/google/did_run_updater_win.h" 72 #include "chrome/browser/google/did_run_updater_win.h"
71 #endif 73 #endif
72 74
73 #if BUILDFLAG(ENABLE_KASKO) 75 #if BUILDFLAG(ENABLE_KASKO)
74 #include "syzygy/kasko/api/reporter.h" 76 #include "syzygy/kasko/api/reporter.h"
75 #endif 77 #endif
76 78
(...skipping 24 matching lines...) Expand all
101 base::StringToInt(l10n_util::GetStringUTF16(IDS_MINIMUM_UI_FONT_SIZE), 103 base::StringToInt(l10n_util::GetStringUTF16(IDS_MINIMUM_UI_FONT_SIZE),
102 &min_font_size); 104 &min_font_size);
103 return min_font_size; 105 return min_font_size;
104 } 106 }
105 107
106 class TranslationDelegate : public installer::TranslationDelegate { 108 class TranslationDelegate : public installer::TranslationDelegate {
107 public: 109 public:
108 base::string16 GetLocalizedString(int installer_string_id) override; 110 base::string16 GetLocalizedString(int installer_string_id) override;
109 }; 111 };
110 112
113 void ExecuteFontCacheBuildTask(const base::FilePath& path) {
114 base::WeakPtr<content::UtilityProcessHost> utility_process_host(
115 content::UtilityProcessHost::Create(NULL, NULL)->AsWeakPtr());
116 utility_process_host->SetName(
117 l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_FONT_CACHE_BUILDER_NAME));
118 utility_process_host->DisableSandbox();
119 utility_process_host->Send(
120 new ChromeUtilityHostMsg_BuildDirectWriteFontCache(path));
121 }
122
111 #if BUILDFLAG(ENABLE_KASKO) 123 #if BUILDFLAG(ENABLE_KASKO)
112 void ObserveFailedCrashReportDirectory(const base::FilePath& path, bool error) { 124 void ObserveFailedCrashReportDirectory(const base::FilePath& path, bool error) {
113 DCHECK(!error); 125 DCHECK(!error);
114 if (error) 126 if (error)
115 return; 127 return;
116 base::FileEnumerator enumerator(path, true, base::FileEnumerator::FILES); 128 base::FileEnumerator enumerator(path, true, base::FileEnumerator::FILES);
117 for (base::FilePath report_file = enumerator.Next(); !report_file.empty(); 129 for (base::FilePath report_file = enumerator.Next(); !report_file.empty();
118 report_file = enumerator.Next()) { 130 report_file = enumerator.Next()) {
119 if (report_file.Extension() == 131 if (report_file.Extension() ==
120 kasko::api::kPermanentFailureMinidumpExtension) { 132 kasko::api::kPermanentFailureMinidumpExtension) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 317
306 void ChromeBrowserMainPartsWin::ShowMissingLocaleMessageBox() { 318 void ChromeBrowserMainPartsWin::ShowMissingLocaleMessageBox() {
307 ui::MessageBox(NULL, 319 ui::MessageBox(NULL,
308 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataMessage), 320 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataMessage),
309 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataTitle), 321 base::ASCIIToUTF16(chrome_browser::kMissingLocaleDataTitle),
310 MB_OK | MB_ICONERROR | MB_TOPMOST); 322 MB_OK | MB_ICONERROR | MB_TOPMOST);
311 } 323 }
312 324
313 void ChromeBrowserMainPartsWin::PostProfileInit() { 325 void ChromeBrowserMainPartsWin::PostProfileInit() {
314 ChromeBrowserMainParts::PostProfileInit(); 326 ChromeBrowserMainParts::PostProfileInit();
327
328 // DirectWrite support is mainly available Windows 7 and up.
329 // Skip loading the font cache if we are using the font proxy field trial.
330 if (gfx::win::ShouldUseDirectWrite() &&
331 !content::ShouldUseDirectWriteFontProxyFieldTrial()) {
332 base::FilePath path(
333 profile()->GetPath().AppendASCII(content::kFontCacheSharedSectionName));
334 // This function will create a read only section if cache file exists
335 // otherwise it will spawn utility process to build cache file, which will
336 // be used during next browser start/postprofileinit.
337 if (!content::LoadFontCache(path)) {
338 // We delay building of font cache until first startup page loads.
339 // During first renderer start there are lot of things happening
340 // simultaneously some of them are:
341 // - Renderer is going through all font files on the system to create a
342 // font collection.
343 // - Renderer loading up startup URL, accessing HTML/JS File cache, net
344 // activity etc.
345 // - Extension initialization.
346 // We delay building of cache mainly to avoid parallel font file loading
347 // along with Renderer. Some systems have significant number of font files
348 // which takes long time to process.
349 // Related information is at http://crbug.com/436195.
350 const int kBuildFontCacheDelaySec = 30;
351 content::BrowserThread::PostDelayedTask(
352 content::BrowserThread::IO,
353 FROM_HERE,
354 base::Bind(ExecuteFontCacheBuildTask, path),
355 base::TimeDelta::FromSeconds(kBuildFontCacheDelaySec));
356 }
357 }
315 } 358 }
316 359
317 void ChromeBrowserMainPartsWin::PostBrowserStart() { 360 void ChromeBrowserMainPartsWin::PostBrowserStart() {
318 ChromeBrowserMainParts::PostBrowserStart(); 361 ChromeBrowserMainParts::PostBrowserStart();
319 362
320 UMA_HISTOGRAM_BOOLEAN("Windows.Tablet", base::win::IsTabletDevice(nullptr)); 363 UMA_HISTOGRAM_BOOLEAN("Windows.Tablet", base::win::IsTabletDevice(nullptr));
321 364
322 // Set up a task to verify installed modules in the current process. 365 // Set up a task to verify installed modules in the current process.
323 content::BrowserThread::PostAfterStartupTask( 366 content::BrowserThread::PostAfterStartupTask(
324 FROM_HERE, content::BrowserThread::GetBlockingPool(), 367 FROM_HERE, content::BrowserThread::GetBlockingPool(),
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 if (resource_id) 554 if (resource_id)
512 return l10n_util::GetStringUTF16(resource_id); 555 return l10n_util::GetStringUTF16(resource_id);
513 return base::string16(); 556 return base::string16();
514 } 557 }
515 558
516 // static 559 // static
517 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { 560 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() {
518 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); 561 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ());
519 installer::SetTranslationDelegate(&delegate); 562 installer::SetTranslationDelegate(&delegate);
520 } 563 }
OLDNEW
« 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