Chromium Code Reviews| Index: chrome_elf/chrome_elf_util.cc |
| diff --git a/chrome_elf/chrome_elf_util.cc b/chrome_elf/chrome_elf_util.cc |
| index a547d0bda04730b73f6c50dd6bb5ed3118dda50b..b385dd0e154875f5794f0374a9156ff090f7ca8e 100644 |
| --- a/chrome_elf/chrome_elf_util.cc |
| +++ b/chrome_elf/chrome_elf_util.cc |
| @@ -193,17 +193,23 @@ bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled) { |
| } |
| bool IsNonBrowserProcess() { |
| - typedef bool (*IsSandboxedProcessFunc)(); |
| - IsSandboxedProcessFunc is_sandboxed_process_func = |
| - reinterpret_cast<IsSandboxedProcessFunc>( |
| - GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); |
| - bool is_sandboxed_process = |
| - is_sandboxed_process_func && is_sandboxed_process_func(); |
| - |
| - // TODO(robertshield): Drop the command line check when we drop support for |
| - // enabling chrome_elf in unsandboxed processes. |
| - wchar_t* command_line = GetCommandLine(); |
| - bool has_process_type_flag = command_line && wcsstr(command_line, L"--type"); |
| - |
| + static bool initialized = false; |
| + // Assume a non-browser process until proven otherwise. |
| + static bool is_sandboxed_process = true; |
| + static bool has_process_type_flag = true; |
| + if (!initialized) { |
|
Sigurður Ásgeirsson
2015/05/08 14:36:33
This mode of initialization is not thread safe. It
grt (UTC plus 2)
2015/05/08 14:44:22
In practice, I think that the first call will be d
Sigurður Ásgeirsson
2015/05/08 16:59:42
If you can guarantee that this function is invoked
|
| + typedef bool (*IsSandboxedProcessFunc)(); |
| + IsSandboxedProcessFunc is_sandboxed_process_func = |
| + reinterpret_cast<IsSandboxedProcessFunc>( |
| + GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); |
| + is_sandboxed_process = |
|
grt (UTC plus 2)
2015/05/08 04:44:34
if this is true, there's no need to check the comm
|
| + is_sandboxed_process_func && is_sandboxed_process_func(); |
| + |
| + // TODO(robertshield): Drop the command line check when we drop support for |
| + // enabling chrome_elf in unsandboxed processes. |
| + wchar_t* command_line = GetCommandLine(); |
| + has_process_type_flag = command_line && wcsstr(command_line, L"--type"); |
| + initialized = true; |
| + } |
| return (has_process_type_flag || is_sandboxed_process); |
| } |