Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7157)

Unified Diff: chrome_elf/chrome_elf_util.cc

Issue 1132473003: Cache IsNonBrowserProcess values, so we only take a loader-lock the first time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make g_is_non_browser_process global Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_elf/chrome_elf_util.h ('k') | chrome_elf/chrome_elf_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..66dc8d4d978a440b8daaea81fb42fd1451938046 100644
--- a/chrome_elf/chrome_elf_util.cc
+++ b/chrome_elf/chrome_elf_util.cc
@@ -4,11 +4,14 @@
#include "chrome_elf/chrome_elf_util.h"
+#include <assert.h>
#include <windows.h>
#include "base/macros.h"
#include "base/strings/string16.h"
+ProcessType g_is_non_browser_process = ProcessType::UNINITIALIZED;
csharp 2015/05/11 20:31:32 As discussed, maybe flip it to become g_is_browser
Sigurður Ásgeirsson 2015/05/11 20:37:41 g_process_type, perhaps?
Cait (Slow) 2015/05/11 21:16:21 Done.
Cait (Slow) 2015/05/11 21:16:21 Acknowledged.
+
namespace {
const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState";
@@ -192,18 +195,27 @@ bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled) {
return false;
}
-bool IsNonBrowserProcess() {
+void InitializeIsNonBrowserProcess() {
+ assert(g_is_non_browser_process == UNINITIALIZED);
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();
+ if (is_sandboxed_process_func && is_sandboxed_process_func()) {
+ g_is_non_browser_process = NON_BROWSER_PROCESS;
+ return;
+ }
- // 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");
+ const wchar_t* command_line = GetCommandLine();
+ if (command_line && wcsstr(command_line, L"--type")) {
+ g_is_non_browser_process = NON_BROWSER_PROCESS;
+ return;
+ }
- return (has_process_type_flag || is_sandboxed_process);
+ g_is_non_browser_process = BROWSER_PROCESS;
+}
+
+bool IsNonBrowserProcess() {
+ assert(g_is_non_browser_process != UNINITIALIZED);
+ return g_is_non_browser_process == NON_BROWSER_PROCESS;
}
« no previous file with comments | « chrome_elf/chrome_elf_util.h ('k') | chrome_elf/chrome_elf_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698