| 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 13 matching lines...) Expand all Loading... |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 mswr::ComPtr<DWriteFontCollectionProxy> g_font_collection; | 28 mswr::ComPtr<DWriteFontCollectionProxy> g_font_collection; |
| 29 IPC::Sender* g_sender_override = nullptr; | 29 IPC::Sender* g_sender_override = nullptr; |
| 30 | 30 |
| 31 // Windows-only DirectWrite support. These warm up the DirectWrite paths | 31 // Windows-only DirectWrite support. These warm up the DirectWrite paths |
| 32 // before sandbox lock down to allow Skia access to the Font Manager service. | 32 // before sandbox lock down to allow Skia access to the Font Manager service. |
| 33 void CreateDirectWriteFactory(IDWriteFactory** factory) { | 33 void CreateDirectWriteFactory(IDWriteFactory** factory) { |
| 34 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc; | |
| 35 HMODULE dwrite_dll = LoadLibraryW(L"dwrite.dll"); | |
| 36 // TODO(scottmg): Temporary code to track crash in http://crbug.com/387867. | |
| 37 if (!dwrite_dll) { | |
| 38 DWORD load_library_get_last_error = GetLastError(); | |
| 39 base::debug::Alias(&dwrite_dll); | |
| 40 base::debug::Alias(&load_library_get_last_error); | |
| 41 CHECK(false); | |
| 42 } | |
| 43 | |
| 44 // This shouldn't be necessary, but not having this causes breakage in | 34 // This shouldn't be necessary, but not having this causes breakage in |
| 45 // content_browsertests, and possibly other high-stress cases. | 35 // content_browsertests, and possibly other high-stress cases. |
| 46 PatchServiceManagerCalls(); | 36 PatchServiceManagerCalls(); |
| 47 | 37 |
| 48 DWriteCreateFactoryProc dwrite_create_factory_proc = | 38 CHECK(SUCCEEDED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, |
| 49 reinterpret_cast<DWriteCreateFactoryProc>( | 39 __uuidof(IDWriteFactory), |
| 50 GetProcAddress(dwrite_dll, "DWriteCreateFactory")); | 40 reinterpret_cast<IUnknown**>(factory)))); |
| 51 // TODO(scottmg): Temporary code to track crash in http://crbug.com/387867. | |
| 52 if (!dwrite_create_factory_proc) { | |
| 53 DWORD get_proc_address_get_last_error = GetLastError(); | |
| 54 base::debug::Alias(&dwrite_create_factory_proc); | |
| 55 base::debug::Alias(&get_proc_address_get_last_error); | |
| 56 CHECK(false); | |
| 57 } | |
| 58 CHECK(SUCCEEDED(dwrite_create_factory_proc( | |
| 59 DWRITE_FACTORY_TYPE_ISOLATED, __uuidof(IDWriteFactory), | |
| 60 reinterpret_cast<IUnknown**>(factory)))); | |
| 61 } | 41 } |
| 62 | 42 |
| 63 } // namespace | 43 } // namespace |
| 64 | 44 |
| 65 void InitializeDWriteFontProxy() { | 45 void InitializeDWriteFontProxy() { |
| 66 mswr::ComPtr<IDWriteFactory> factory; | 46 mswr::ComPtr<IDWriteFactory> factory; |
| 67 | 47 |
| 68 CreateDirectWriteFactory(&factory); | 48 CreateDirectWriteFactory(&factory); |
| 69 | 49 |
| 70 if (!g_font_collection) { | 50 if (!g_font_collection) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 void UninitializeDWriteFontProxy() { | 84 void UninitializeDWriteFontProxy() { |
| 105 if (g_font_collection) | 85 if (g_font_collection) |
| 106 g_font_collection->Unregister(); | 86 g_font_collection->Unregister(); |
| 107 } | 87 } |
| 108 | 88 |
| 109 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { | 89 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { |
| 110 g_sender_override = sender; | 90 g_sender_override = sender; |
| 111 } | 91 } |
| 112 | 92 |
| 113 } // namespace content | 93 } // namespace content |
| OLD | NEW |