OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" | 5 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" |
6 | 6 |
7 #include <dwrite.h> | 7 #include <dwrite.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 namespace content { | 26 namespace content { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 mswr::ComPtr<DWriteFontCollectionProxy> g_font_collection; | 30 mswr::ComPtr<DWriteFontCollectionProxy> g_font_collection; |
31 IPC::Sender* g_sender_override = nullptr; | 31 IPC::Sender* g_sender_override = nullptr; |
32 | 32 |
33 // Windows-only DirectWrite support. These warm up the DirectWrite paths | 33 // Windows-only DirectWrite support. These warm up the DirectWrite paths |
34 // before sandbox lock down to allow Skia access to the Font Manager service. | 34 // before sandbox lock down to allow Skia access to the Font Manager service. |
35 void CreateDirectWriteFactory(IDWriteFactory** factory) { | 35 void CreateDirectWriteFactory(IDWriteFactory** factory) { |
36 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc; | |
37 HMODULE dwrite_dll = LoadLibraryW(L"dwrite.dll"); | |
38 // TODO(scottmg): Temporary code to track crash in http://crbug.com/387867. | |
39 if (!dwrite_dll) { | |
40 DWORD load_library_get_last_error = GetLastError(); | |
41 base::debug::Alias(&dwrite_dll); | |
42 base::debug::Alias(&load_library_get_last_error); | |
43 CHECK(false); | |
44 } | |
45 | |
46 // This shouldn't be necessary, but not having this causes breakage in | 36 // This shouldn't be necessary, but not having this causes breakage in |
47 // content_browsertests, and possibly other high-stress cases. | 37 // content_browsertests, and possibly other high-stress cases. |
48 PatchServiceManagerCalls(); | 38 PatchServiceManagerCalls(); |
49 | 39 |
50 DWriteCreateFactoryProc dwrite_create_factory_proc = | 40 CHECK(SUCCEEDED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, |
51 reinterpret_cast<DWriteCreateFactoryProc>( | 41 __uuidof(IDWriteFactory), |
52 GetProcAddress(dwrite_dll, "DWriteCreateFactory")); | 42 reinterpret_cast<IUnknown**>(factory)))); |
53 // TODO(scottmg): Temporary code to track crash in http://crbug.com/387867. | |
54 if (!dwrite_create_factory_proc) { | |
55 DWORD get_proc_address_get_last_error = GetLastError(); | |
56 base::debug::Alias(&dwrite_create_factory_proc); | |
57 base::debug::Alias(&get_proc_address_get_last_error); | |
58 CHECK(false); | |
59 } | |
60 CHECK(SUCCEEDED(dwrite_create_factory_proc( | |
61 DWRITE_FACTORY_TYPE_ISOLATED, __uuidof(IDWriteFactory), | |
62 reinterpret_cast<IUnknown**>(factory)))); | |
63 } | 43 } |
64 | 44 |
65 } // namespace | 45 } // namespace |
66 | 46 |
67 void InitializeDWriteFontProxy() { | 47 void InitializeDWriteFontProxy() { |
68 mswr::ComPtr<IDWriteFactory> factory; | 48 mswr::ComPtr<IDWriteFactory> factory; |
69 | 49 |
70 CreateDirectWriteFactory(&factory); | 50 CreateDirectWriteFactory(&factory); |
71 | 51 |
72 IPC::Sender* sender = g_sender_override; | 52 IPC::Sender* sender = g_sender_override; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 void UninitializeDWriteFontProxy() { | 95 void UninitializeDWriteFontProxy() { |
116 if (g_font_collection) | 96 if (g_font_collection) |
117 g_font_collection->Unregister(); | 97 g_font_collection->Unregister(); |
118 } | 98 } |
119 | 99 |
120 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { | 100 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { |
121 g_sender_override = sender; | 101 g_sender_override = sender; |
122 } | 102 } |
123 | 103 |
124 } // namespace content | 104 } // namespace content |
OLD | NEW |