Chromium Code Reviews| 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 #include "chrome_elf/chrome_elf_util.h" | 5 #include "chrome_elf/chrome_elf_util.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 *breakpad_enabled = value != 0; | 186 *breakpad_enabled = value != 0; |
| 187 } | 187 } |
| 188 ::RegCloseKey(key); | 188 ::RegCloseKey(key); |
| 189 return size == sizeof(value); | 189 return size == sizeof(value); |
| 190 } | 190 } |
| 191 | 191 |
| 192 return false; | 192 return false; |
| 193 } | 193 } |
| 194 | 194 |
| 195 bool IsNonBrowserProcess() { | 195 bool IsNonBrowserProcess() { |
| 196 typedef bool (*IsSandboxedProcessFunc)(); | 196 static bool initialized = false; |
| 197 IsSandboxedProcessFunc is_sandboxed_process_func = | 197 // Assume a non-browser process until proven otherwise. |
| 198 reinterpret_cast<IsSandboxedProcessFunc>( | 198 static bool is_sandboxed_process = true; |
| 199 GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); | 199 static bool has_process_type_flag = true; |
| 200 bool is_sandboxed_process = | 200 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
| |
| 201 is_sandboxed_process_func && is_sandboxed_process_func(); | 201 typedef bool (*IsSandboxedProcessFunc)(); |
| 202 IsSandboxedProcessFunc is_sandboxed_process_func = | |
| 203 reinterpret_cast<IsSandboxedProcessFunc>( | |
| 204 GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); | |
| 205 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
| |
| 206 is_sandboxed_process_func && is_sandboxed_process_func(); | |
| 202 | 207 |
| 203 // TODO(robertshield): Drop the command line check when we drop support for | 208 // TODO(robertshield): Drop the command line check when we drop support for |
| 204 // enabling chrome_elf in unsandboxed processes. | 209 // enabling chrome_elf in unsandboxed processes. |
| 205 wchar_t* command_line = GetCommandLine(); | 210 wchar_t* command_line = GetCommandLine(); |
| 206 bool has_process_type_flag = command_line && wcsstr(command_line, L"--type"); | 211 has_process_type_flag = command_line && wcsstr(command_line, L"--type"); |
| 207 | 212 initialized = true; |
| 213 } | |
| 208 return (has_process_type_flag || is_sandboxed_process); | 214 return (has_process_type_flag || is_sandboxed_process); |
| 209 } | 215 } |
| OLD | NEW |