Commit 6481d10f authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

win: Remove two exit-time destructors from pdf_child_init and enable...

win: Remove two exit-time destructors from pdf_child_init and enable -Wexit-time-destructors for chrome/child.

The PDF setup code patches up two GDI functions. There's no need
to undo that patching at process exit, so use a function-local static
base::NoDestructor<> instead of a global.

Bug: 404525
Change-Id: I9cb06b857a8b95ba5cbac74be60f8225fbb6f72a
Reviewed-on: https://chromium-review.googlesource.com/1231073Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592112}
parent 737ec250
...@@ -10,10 +10,7 @@ static_library("child") { ...@@ -10,10 +10,7 @@ static_library("child") {
"v8_breakpad_support_win.h", "v8_breakpad_support_win.h",
] ]
# TODO(thakis): Enable on Windows too, http://crbug.com/404525 configs += [ "//build/config/compiler:wexit_time_destructors" ]
if (!is_win) {
configs += [ "//build/config/compiler:wexit_time_destructors" ]
}
deps = [ deps = [
"//base", "//base",
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/no_destructor.h"
#include "base/win/current_module.h" #include "base/win/current_module.h"
#include "base/win/iat_patch_function.h" #include "base/win/iat_patch_function.h"
#include "content/public/child/child_thread.h" #include "content/public/child/child_thread.h"
...@@ -15,8 +16,6 @@ ...@@ -15,8 +16,6 @@
namespace { namespace {
#if defined(OS_WIN) #if defined(OS_WIN)
base::win::IATPatchFunction g_iat_patch_createdca;
HDC WINAPI CreateDCAPatch(LPCSTR driver_name, HDC WINAPI CreateDCAPatch(LPCSTR driver_name,
LPCSTR device_name, LPCSTR device_name,
LPCSTR output, LPCSTR output,
...@@ -37,7 +36,6 @@ typedef DWORD (WINAPI* GetFontDataPtr) (HDC hdc, ...@@ -37,7 +36,6 @@ typedef DWORD (WINAPI* GetFontDataPtr) (HDC hdc,
DWORD length); DWORD length);
GetFontDataPtr g_original_get_font_data = nullptr; GetFontDataPtr g_original_get_font_data = nullptr;
base::win::IATPatchFunction g_iat_patch_get_font_data;
DWORD WINAPI GetFontDataPatch(HDC hdc, DWORD WINAPI GetFontDataPatch(HDC hdc,
DWORD table, DWORD table,
...@@ -66,15 +64,19 @@ DWORD WINAPI GetFontDataPatch(HDC hdc, ...@@ -66,15 +64,19 @@ DWORD WINAPI GetFontDataPatch(HDC hdc,
void InitializePDF() { void InitializePDF() {
#if defined(OS_WIN) #if defined(OS_WIN)
// Need to patch a few functions for font loading to work correctly. This can // Need to patch a few functions for font loading to work correctly. This can
// be removed once we switch PDF to use Skia. // be removed once we switch PDF to use Skia
// (https://bugs.chromium.org/p/pdfium/issues/detail?id=11).
HMODULE current_module = CURRENT_MODULE(); HMODULE current_module = CURRENT_MODULE();
g_iat_patch_createdca.PatchFromModule(
current_module, "gdi32.dll", "CreateDCA", static base::NoDestructor<base::win::IATPatchFunction> patch_createdca;
reinterpret_cast<void*>(CreateDCAPatch)); patch_createdca->PatchFromModule(current_module, "gdi32.dll", "CreateDCA",
g_iat_patch_get_font_data.PatchFromModule( reinterpret_cast<void*>(CreateDCAPatch));
static base::NoDestructor<base::win::IATPatchFunction> patch_get_font_data;
patch_get_font_data->PatchFromModule(
current_module, "gdi32.dll", "GetFontData", current_module, "gdi32.dll", "GetFontData",
reinterpret_cast<void*>(GetFontDataPatch)); reinterpret_cast<void*>(GetFontDataPatch));
g_original_get_font_data = reinterpret_cast<GetFontDataPtr>( g_original_get_font_data = reinterpret_cast<GetFontDataPtr>(
g_iat_patch_get_font_data.original_function()); patch_get_font_data->original_function());
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment