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

Unified Diff: content/common/font_warmup_win.cc

Issue 1438603002: Create direct write font proxy classes and unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding crash logging Created 5 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
Index: content/common/font_warmup_win.cc
diff --git a/content/common/font_warmup_win.cc b/content/common/font_warmup_win.cc
index 6a059d03c42bd6b74630921e4b2b817fe7ff0934..ddc1889d11dd93d52ef67d13e19dd8ee1febda7b 100644
--- a/content/common/font_warmup_win.cc
+++ b/content/common/font_warmup_win.cc
@@ -96,56 +96,6 @@ NTSTATUS WINAPI NtALpcConnectPortPatch(HANDLE* port_handle,
return STATUS_ACCESS_DENIED;
}
-// Directwrite connects to the font cache service to retrieve information about
-// fonts installed on the system etc. This works well outside the sandbox and
-// within the sandbox as long as the lpc connection maintained by the current
-// process with the font cache service remains valid. It appears that there
-// are cases when this connection is dropped after which directwrite is unable
-// to connect to the font cache service which causes problems with characters
-// disappearing.
-// Directwrite has fallback code to enumerate fonts if it is unable to connect
-// to the font cache service. We need to intercept the following APIs to
-// ensure that it does not connect to the font cache service.
-// NtALpcConnectPort
-// OpenSCManagerW
-// OpenServiceW
-// StartServiceW
-// CloseServiceHandle.
-// These are all IAT patched.
-void PatchServiceManagerCalls() {
- static bool is_patched = false;
- if (is_patched)
- return;
- const char* service_provider_dll =
- (base::win::GetVersion() >= base::win::VERSION_WIN8
- ? "api-ms-win-service-management-l1-1-0.dll"
- : "advapi32.dll");
-
- is_patched = true;
-
- DWORD patched =
- g_iat_patch_open_sc_manager.Patch(L"dwrite.dll", service_provider_dll,
- "OpenSCManagerW", OpenSCManagerWPatch);
- DCHECK(patched == 0);
-
- patched = g_iat_patch_close_service_handle.Patch(
- L"dwrite.dll", service_provider_dll, "CloseServiceHandle",
- CloseServiceHandlePatch);
- DCHECK(patched == 0);
-
- patched = g_iat_patch_open_service.Patch(L"dwrite.dll", service_provider_dll,
- "OpenServiceW", OpenServiceWPatch);
- DCHECK(patched == 0);
-
- patched = g_iat_patch_start_service.Patch(
- L"dwrite.dll", service_provider_dll, "StartServiceW", StartServiceWPatch);
- DCHECK(patched == 0);
-
- patched = g_iat_patch_nt_connect_port.Patch(
- L"dwrite.dll", "ntdll.dll", "NtAlpcConnectPort", NtALpcConnectPortPatch);
- DCHECK(patched == 0);
-}
-
// Windows-only DirectWrite support. These warm up the DirectWrite paths
// before sandbox lock down to allow Skia access to the Font Manager service.
void CreateDirectWriteFactory(IDWriteFactory** factory) {
@@ -461,6 +411,56 @@ GdiFontPatchDataImpl::GdiFontPatchDataImpl(const base::FilePath& path) {
} // namespace
+// Directwrite connects to the font cache service to retrieve information about
jam 2015/11/20 17:39:31 why is this code in content/common? i see it's onl
Ilya Kulshin 2015/11/20 22:10:58 Mostly because it was here when I found it. Unless
+// fonts installed on the system etc. This works well outside the sandbox and
+// within the sandbox as long as the lpc connection maintained by the current
+// process with the font cache service remains valid. It appears that there
+// are cases when this connection is dropped after which directwrite is unable
+// to connect to the font cache service which causes problems with characters
+// disappearing.
+// Directwrite has fallback code to enumerate fonts if it is unable to connect
+// to the font cache service. We need to intercept the following APIs to
+// ensure that it does not connect to the font cache service.
+// NtALpcConnectPort
+// OpenSCManagerW
+// OpenServiceW
+// StartServiceW
+// CloseServiceHandle.
+// These are all IAT patched.
+void PatchServiceManagerCalls() {
+ static bool is_patched = false;
+ if (is_patched)
+ return;
+ const char* service_provider_dll =
+ (base::win::GetVersion() >= base::win::VERSION_WIN8
+ ? "api-ms-win-service-management-l1-1-0.dll"
+ : "advapi32.dll");
+
+ is_patched = true;
+
+ DWORD patched =
+ g_iat_patch_open_sc_manager.Patch(L"dwrite.dll", service_provider_dll,
+ "OpenSCManagerW", OpenSCManagerWPatch);
+ DCHECK(patched == 0);
+
+ patched = g_iat_patch_close_service_handle.Patch(
+ L"dwrite.dll", service_provider_dll, "CloseServiceHandle",
+ CloseServiceHandlePatch);
+ DCHECK(patched == 0);
+
+ patched = g_iat_patch_open_service.Patch(L"dwrite.dll", service_provider_dll,
+ "OpenServiceW", OpenServiceWPatch);
+ DCHECK(patched == 0);
+
+ patched = g_iat_patch_start_service.Patch(
+ L"dwrite.dll", service_provider_dll, "StartServiceW", StartServiceWPatch);
+ DCHECK(patched == 0);
+
+ patched = g_iat_patch_nt_connect_port.Patch(
+ L"dwrite.dll", "ntdll.dll", "NtAlpcConnectPort", NtALpcConnectPortPatch);
+ DCHECK(patched == 0);
+}
+
void DoPreSandboxWarmupForTypeface(SkTypeface* typeface) {
SkPaint paint_warmup;
paint_warmup.setTypeface(typeface);

Powered by Google App Engine
This is Rietveld 408576698