Commit 88dc419e authored by caitkp's avatar caitkp Committed by Commit bot

Revert of Cache IsNonBrowserProcess values, so we only take a loader-lock the...

Revert of Cache IsNonBrowserProcess values, so we only take a loader-lock the first time. (patchset #4 id:60001 of https://codereview.chromium.org/1132473003/)

Reason for revert:
Possibly causing mysterious fails on the Win DBG bots:
https://build.chromium.org/p/chromium.webkit/builders/Win7%20%28dbg%29/builds/16344

http://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/37896

Original issue's description:
> Cache IsNonBrowserProcess values, so we only take a loader-lock the first time.
>
> BUG=485656,477137
>
> Committed: https://crrev.com/78d41b5d4e59dc7d52d7e7d6530fdd0a78b36d33
> Cr-Commit-Position: refs/heads/master@{#329246}

TBR=siggi@chromium.org,grt@chromium.org,csharp@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=485656,477137

Review URL: https://codereview.chromium.org/1134253002

Cr-Commit-Position: refs/heads/master@{#329467}
parent 421116c2
...@@ -5,13 +5,11 @@ ...@@ -5,13 +5,11 @@
#include <windows.h> #include <windows.h>
#include "chrome_elf/blacklist/blacklist.h" #include "chrome_elf/blacklist/blacklist.h"
#include "chrome_elf/chrome_elf_util.h"
extern "C" void InitBlacklistTestDll() {} extern "C" void InitBlacklistTestDll() {}
BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) { BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) {
if (reason == DLL_PROCESS_ATTACH) { if (reason == DLL_PROCESS_ATTACH) {
InitializeProcessType();
blacklist::Initialize(true); // force always on, no beacon blacklist::Initialize(true); // force always on, no beacon
} }
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "chrome_elf/blacklist/blacklist.h" #include "chrome_elf/blacklist/blacklist.h"
#include "chrome_elf/breakpad.h" #include "chrome_elf/breakpad.h"
#include "chrome_elf/chrome_elf_util.h"
#include "chrome_elf/ntdll_cache.h" #include "chrome_elf/ntdll_cache.h"
void SignalChromeElf() { void SignalChromeElf() {
...@@ -20,7 +19,6 @@ BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) { ...@@ -20,7 +19,6 @@ BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) {
InitializeCrashReporting(); InitializeCrashReporting();
__try { __try {
InitializeProcessType();
InitCache(); InitCache();
blacklist::Initialize(false); // Don't force, abort if beacon is present. blacklist::Initialize(false); // Don't force, abort if beacon is present.
} __except(GenerateCrashDump(GetExceptionInformation())) { } __except(GenerateCrashDump(GetExceptionInformation())) {
......
...@@ -4,14 +4,11 @@ ...@@ -4,14 +4,11 @@
#include "chrome_elf/chrome_elf_util.h" #include "chrome_elf/chrome_elf_util.h"
#include <assert.h>
#include <windows.h> #include <windows.h>
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
ProcessType g_process_type = ProcessType::UNINITIALIZED;
namespace { namespace {
const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState"; const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState";
...@@ -195,27 +192,18 @@ bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled) { ...@@ -195,27 +192,18 @@ bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled) {
return false; return false;
} }
void InitializeProcessType() { bool IsNonBrowserProcess() {
assert(g_process_type == UNINITIALIZED);
typedef bool (*IsSandboxedProcessFunc)(); typedef bool (*IsSandboxedProcessFunc)();
IsSandboxedProcessFunc is_sandboxed_process_func = IsSandboxedProcessFunc is_sandboxed_process_func =
reinterpret_cast<IsSandboxedProcessFunc>( reinterpret_cast<IsSandboxedProcessFunc>(
GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess"));
if (is_sandboxed_process_func && is_sandboxed_process_func()) { bool is_sandboxed_process =
g_process_type = NON_BROWSER_PROCESS; is_sandboxed_process_func && is_sandboxed_process_func();
return;
}
const wchar_t* command_line = GetCommandLine(); // TODO(robertshield): Drop the command line check when we drop support for
if (command_line && wcsstr(command_line, L"--type")) { // enabling chrome_elf in unsandboxed processes.
g_process_type = NON_BROWSER_PROCESS; wchar_t* command_line = GetCommandLine();
return; bool has_process_type_flag = command_line && wcsstr(command_line, L"--type");
}
g_process_type = BROWSER_PROCESS; return (has_process_type_flag || is_sandboxed_process);
}
bool IsNonBrowserProcess() {
assert(g_process_type != UNINITIALIZED);
return g_process_type == NON_BROWSER_PROCESS;
} }
...@@ -7,12 +7,6 @@ ...@@ -7,12 +7,6 @@
#include "base/strings/string16.h" #include "base/strings/string16.h"
enum ProcessType {
UNINITIALIZED,
NON_BROWSER_PROCESS,
BROWSER_PROCESS,
};
// Returns true if |exe_path| points to a Chrome installed in an SxS // Returns true if |exe_path| points to a Chrome installed in an SxS
// installation. // installation.
bool IsCanary(const wchar_t* exe_path); bool IsCanary(const wchar_t* exe_path);
...@@ -30,14 +24,8 @@ bool AreUsageStatsEnabled(const wchar_t* exe_path); ...@@ -30,14 +24,8 @@ bool AreUsageStatsEnabled(const wchar_t* exe_path);
// if stats collecting is permitted by this policy and false if not. // if stats collecting is permitted by this policy and false if not.
bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled); bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled);
// Initializes |g_process_type| which stores whether or not the current process
// is the main browser process.
void InitializeProcessType();
// Returns true if invoked in a Chrome process other than the main browser // Returns true if invoked in a Chrome process other than the main browser
// process. False otherwise. // process. False otherwise.
bool IsNonBrowserProcess(); bool IsNonBrowserProcess();
extern ProcessType g_process_type;
#endif // CHROME_ELF_CHROME_ELF_UTIL_H_ #endif // CHROME_ELF_CHROME_ELF_UTIL_H_
...@@ -48,12 +48,6 @@ TEST(ChromeElfUtilTest, SystemInstallTest) { ...@@ -48,12 +48,6 @@ TEST(ChromeElfUtilTest, SystemInstallTest) {
EXPECT_FALSE(IsSystemInstall(kChromeUserExePath)); EXPECT_FALSE(IsSystemInstall(kChromeUserExePath));
} }
TEST(ChromeElfUtilTest, BrowserProcessTest) {
EXPECT_TRUE(g_process_type == ProcessType::UNINITIALIZED);
InitializeProcessType();
EXPECT_FALSE(IsNonBrowserProcess());
}
// Parameterized test with paramters: // Parameterized test with paramters:
// 1: product: "canary" or "google" // 1: product: "canary" or "google"
// 2: install level: "user" or "system" // 2: install level: "user" or "system"
......
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