OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CONTENT_CHILD_FONT_WARMUP_WIN_H_ | 5 #ifndef CONTENT_CHILD_FONT_WARMUP_WIN_H_ |
6 #define CONTENT_CHILD_FONT_WARMUP_WIN_H_ | 6 #define CONTENT_CHILD_FONT_WARMUP_WIN_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 | 13 |
14 class SkFontMgr; | 14 class SkFontMgr; |
15 class SkTypeface; | 15 class SkTypeface; |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
| 19 // Make necessary calls to cache the data for a given font, used before |
| 20 // sandbox lockdown. |
| 21 CONTENT_EXPORT void DoPreSandboxWarmupForTypeface(SkTypeface* typeface); |
| 22 |
| 23 // Get the shared font manager used during pre-sandbox warmup for DirectWrite |
| 24 // fonts. |
| 25 CONTENT_EXPORT SkFontMgr* GetPreSandboxWarmupFontMgr(); |
| 26 |
19 class GdiFontPatchData { | 27 class GdiFontPatchData { |
20 public: | 28 public: |
21 virtual ~GdiFontPatchData() {} | 29 virtual ~GdiFontPatchData() {} |
22 | 30 |
23 protected: | 31 protected: |
24 GdiFontPatchData() {} | 32 GdiFontPatchData() {} |
25 | 33 |
26 private: | 34 private: |
27 DISALLOW_COPY_AND_ASSIGN(GdiFontPatchData); | 35 DISALLOW_COPY_AND_ASSIGN(GdiFontPatchData); |
28 }; | 36 }; |
29 | 37 |
30 // Hook a module's imported GDI font functions to reimplement font enumeration | 38 // Hook a module's imported GDI font functions to reimplement font enumeration |
31 // and font data retrieval for DLLs which can't be easily modified. | 39 // and font data retrieval for DLLs which can't be easily modified. |
32 CONTENT_EXPORT GdiFontPatchData* PatchGdiFontEnumeration( | 40 CONTENT_EXPORT GdiFontPatchData* PatchGdiFontEnumeration( |
33 const base::FilePath& path); | 41 const base::FilePath& path); |
34 | 42 |
35 // Testing method to get the number of in-flight emulated GDI handles. | 43 // Testing method to get the number of in-flight emulated GDI handles. |
36 CONTENT_EXPORT size_t GetEmulatedGdiHandleCountForTesting(); | 44 CONTENT_EXPORT size_t GetEmulatedGdiHandleCountForTesting(); |
37 | 45 |
38 // Testing method to reset the table of emulated GDI handles. | 46 // Testing method to reset the table of emulated GDI handles. |
39 CONTENT_EXPORT void ResetEmulatedGdiHandlesForTesting(); | 47 CONTENT_EXPORT void ResetEmulatedGdiHandlesForTesting(); |
40 | 48 |
41 // Sets the pre-sandbox warmup font manager directly. This should only be used | 49 // Sets the pre-sandbox warmup font manager directly. This should only be used |
42 // for testing the implementation. | 50 // for testing the implementation. |
43 CONTENT_EXPORT void SetPreSandboxWarmupFontMgrForTesting(SkFontMgr* fontmgr); | 51 CONTENT_EXPORT void SetPreSandboxWarmupFontMgrForTesting(SkFontMgr* fontmgr); |
44 | 52 |
| 53 // Warmup the direct write font manager for content processes. |
| 54 CONTENT_EXPORT void WarmupDirectWrite(); |
| 55 |
45 // Directwrite connects to the font cache service to retrieve information about | 56 // Directwrite connects to the font cache service to retrieve information about |
46 // fonts installed on the system etc. This works well outside the sandbox and | 57 // fonts installed on the system etc. This works well outside the sandbox and |
47 // within the sandbox as long as the lpc connection maintained by the current | 58 // within the sandbox as long as the lpc connection maintained by the current |
48 // process with the font cache service remains valid. It appears that there | 59 // process with the font cache service remains valid. It appears that there |
49 // are cases when this connection is dropped after which directwrite is unable | 60 // are cases when this connection is dropped after which directwrite is unable |
50 // to connect to the font cache service which causes problems with characters | 61 // to connect to the font cache service which causes problems with characters |
51 // disappearing. | 62 // disappearing. |
52 // Directwrite has fallback code to enumerate fonts if it is unable to connect | 63 // Directwrite has fallback code to enumerate fonts if it is unable to connect |
53 // to the font cache service. We need to intercept the following APIs to | 64 // to the font cache service. We need to intercept the following APIs to |
54 // ensure that it does not connect to the font cache service. | 65 // ensure that it does not connect to the font cache service. |
55 // NtALpcConnectPort | 66 // NtALpcConnectPort |
56 // OpenSCManagerW | 67 // OpenSCManagerW |
57 // OpenServiceW | 68 // OpenServiceW |
58 // StartServiceW | 69 // StartServiceW |
59 // CloseServiceHandle. | 70 // CloseServiceHandle. |
60 // These are all IAT patched. | 71 // These are all IAT patched. |
61 CONTENT_EXPORT void PatchServiceManagerCalls(); | 72 CONTENT_EXPORT void PatchServiceManagerCalls(); |
62 | 73 |
63 } // namespace content | 74 } // namespace content |
64 | 75 |
65 #endif // CONTENT_CHILD_FONT_WARMUP_WIN_H_ | 76 #endif // CONTENT_CHILD_FONT_WARMUP_WIN_H_ |
OLD | NEW |