Ensure that the DirectWrite font cache works in Chrome canary on Windows 8+ with...
commitbbca53aa082320e13909d995a9af66bed7de69a8
authorananta <ananta@chromium.org>
Thu, 30 Apr 2015 21:58:42 +0000 (30 14:58 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 30 Apr 2015 22:00:24 +0000 (30 22:00 +0000)
tree6c34908ef45851931653e963ba5bd805a37590e3
parent74f38717c9c07028dd5661b5ea5588daa04b57d9
Ensure that the DirectWrite font cache works in Chrome canary on Windows 8+ with AppContainer protection.

The DirectWrite font cache is mapped as a shared section by the renderer processes. The browser creates
the section. On Windows 8+ with AppContainer protection the renderers are unable to open this shared section
as the BaseNamedObjects object directory is virtualized to \Sessions\SessionId\AppContainerNamedObjects.

This effectively means that the renderers now fallback to the old method of enumerating all fonts while DirectWrite
builds up its font cache. This hurts performance.

Proposed fix is as below :-
1. When the renderer process is launched we get notified in the RenderProcessHost::OnProcessLaunched method.
   We send a control IPC message here ViewMsg_FontCacheSectionHandle which contains the duplicated font cache
   section handle.

2. The ViewMsg_FontCacheSectionHandle message is handled by RenderThreadImpl. It ensures that the shared handle
   is set by calling a helper function SetFontCacheSectionHandle. This function then triggers the setting of the
   DirectWrite font factory in skia.

3. Some of the code in the WarmupDirectWrite function is no longer needed like the code to create the font factory
   and create some fonts to warm up DirectWrite. This is because DirectWrite in the renderer now uses the custom
   font collection which means that most of the code now can run in the sandbox. The only parts which need to run
   outside the sandbox are the loading of the dwrite.dll and the code in the FontCollectionLoader which reads fonts
   from the registry.

4. The GetPreSandboxWarmupFontMgr helper function has been renamed to GetDirectWriteFontManager.

The UMA metric DirectWrite.Fonts.LoadTime.Cached should be available if the font cache is loaded in the renderer.

BUG=481285
R=cpu

Review URL: https://codereview.chromium.org/1105763004

Cr-Commit-Position: refs/heads/master@{#327804}
19 files changed:
content/browser/battery_status/battery_monitor_integration_browsertest.cc
content/browser/renderer_host/render_process_host_impl.cc
content/browser/renderer_host/render_process_host_impl.h
content/common/dwrite_font_platform_win.cc
content/common/view_messages.h
content/public/common/content_switches.cc
content/public/common/content_switches.h
content/public/common/dwrite_font_platform_win.h
content/public/renderer/render_font_warmup_win.h
content/renderer/render_font_warmup_win.cc
content/renderer/render_thread_impl.cc
content/renderer/render_thread_impl.h
content/renderer/renderer_main_platform_delegate_win.cc
content/shell/browser/shell_content_browser_client.cc
content/shell/browser/shell_content_browser_client.h
content/shell/renderer/layout_test/layout_test_content_renderer_client.cc
extensions/DEPS
extensions/shell/browser/shell_content_browser_client.cc
extensions/shell/browser/shell_content_browser_client.h