summaryrefslogtreecommitdiffstats
path: root/chrome/app/main_dll_loader_win.cc
diff options
context:
space:
mode:
authorscottmg <scottmg@chromium.org>2015-11-25 18:27:49 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-26 02:28:34 +0000
commite3d37e4b4a5683225ee5e2fa427a7129d64fce18 (patch)
tree0f620dfa25d55f65567c4b9f4ad137b4801deb30 /chrome/app/main_dll_loader_win.cc
parentf170638b5c333ef8220ff6ee7836efef7452ebd3 (diff)
downloadchromium_src-e3d37e4b4a5683225ee5e2fa427a7129d64fce18.zip
chromium_src-e3d37e4b4a5683225ee5e2fa427a7129d64fce18.tar.gz
chromium_src-e3d37e4b4a5683225ee5e2fa427a7129d64fce18.tar.bz2
Revert of Crashpad Windows: Use the Crashpad client instead of Breakpad on Windows (patchset #48 id:1160001 of https://codereview.chromium.org/1416133003/ )
Reason for revert: Some failing tests https://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/43485. Unclear why they didn't fail on trybots so I'm going to revert and investigate. Original issue's description: > Crashpad Windows: Use the Crashpad client instead of Breakpad on Windows > > Crashpad is always compiled into chrome and its handler is always > enabled. It only uploads in Official builds. > > On Windows, the crash handler is chrome.exe run with a > --crashpad-handler argument. This is due to concern about > incompatibilities of shipping an additional new different binary for AV, > firewalls, etc. > > Sample renderer crash/1aed2bc785e28995 > Sample browser: crash/66c822815474a5d8 > > See also http://crbug.com/427611 . > > R=mark@chromium.org,cpu@chromium.org > BUG=447073,546288, 456193 > > Committed: https://crrev.com/aaa2ff656f9fcabcbdd9e9964e3b2bdc8f5102ed > Cr-Commit-Position: refs/heads/master@{#361742} TBR=mark@chromium.org,cpu@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=447073,546288, 456193 Review URL: https://codereview.chromium.org/1476193002 Cr-Commit-Position: refs/heads/master@{#361797}
Diffstat (limited to 'chrome/app/main_dll_loader_win.cc')
-rw-r--r--chrome/app/main_dll_loader_win.cc39
1 files changed, 29 insertions, 10 deletions
diff --git a/chrome/app/main_dll_loader_win.cc b/chrome/app/main_dll_loader_win.cc
index 08ce848..ba14dba 100644
--- a/chrome/app/main_dll_loader_win.cc
+++ b/chrome/app/main_dll_loader_win.cc
@@ -21,7 +21,6 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
-#include "base/win/metro.h"
#include "base/win/scoped_handle.h"
#include "base/win/windows_version.h"
#include "chrome/app/chrome_crash_reporter_client.h"
@@ -40,8 +39,8 @@
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/module_util_win.h"
#include "chrome/installer/util/util_constants.h"
+#include "components/crash/content/app/breakpad_win.h"
#include "components/crash/content/app/crash_reporter_client.h"
-#include "components/crash/content/app/crashpad.h"
#include "content/public/app/sandbox_helper_win.h"
#include "content/public/common/content_switches.h"
#include "sandbox/win/src/sandbox.h"
@@ -52,6 +51,9 @@ typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*);
typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)();
+base::LazyInstance<ChromeCrashReporterClient>::Leaky g_chrome_crash_client =
+ LAZY_INSTANCE_INITIALIZER;
+
// Loads |module| after setting the CWD to |module|'s directory. Returns a
// reference to the loaded module on success, or null on error.
HMODULE LoadModuleWithDirectory(const base::FilePath& module, bool pre_read) {
@@ -78,6 +80,11 @@ void ClearDidRun(const base::FilePath& dll_path) {
GoogleUpdateSettings::UpdateDidRunState(false, system_level);
}
+bool InMetroMode() {
+ return (wcsstr(
+ ::GetCommandLineW(), L" -ServerName:DefaultBrowserServer") != nullptr);
+}
+
typedef int (*InitMetro)();
} // namespace
@@ -85,7 +92,7 @@ typedef int (*InitMetro)();
//=============================================================================
MainDllLoader::MainDllLoader()
- : dll_(nullptr), metro_mode_(base::win::IsMetroProcess()) {
+ : dll_(nullptr), metro_mode_(InMetroMode()) {
}
MainDllLoader::~MainDllLoader() {
@@ -197,6 +204,18 @@ int MainDllLoader::Launch(HINSTANCE instance) {
sandbox::SandboxInterfaceInfo sandbox_info = {0};
content::InitializeSandboxInfo(&sandbox_info);
+ crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer());
+ bool exit_now = true;
+ if (process_type_.empty()) {
+ if (breakpad::ShowRestartDialogIfCrashed(&exit_now)) {
+ // We restarted because of a previous crash. Ask user if we should
+ // Relaunch. Only for the browser process. See crbug.com/132119.
+ if (exit_now)
+ return content::RESULT_CODE_NORMAL_EXIT;
+ }
+ }
+ breakpad::InitCrashReporter(process_type_);
+
dll_ = Load(&version, &file);
if (!dll_)
return chrome::RESULT_CODE_MISSING_DATA;
@@ -209,6 +228,12 @@ int MainDllLoader::Launch(HINSTANCE instance) {
reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain"));
int rc = chrome_main(instance, &sandbox_info);
rc = OnBeforeExit(rc, file);
+ // Sandboxed processes close some system DLL handles after lockdown so ignore
+ // EXCEPTION_INVALID_HANDLE generated on Windows 10 during shutdown of these
+ // processes.
+ // TODO(wfh): Check whether MS have fixed this in Win10 RTM. crbug.com/456193
+ if (base::win::GetVersion() >= base::win::VERSION_WIN10)
+ breakpad::ConsumeInvalidHandleExceptions();
return rc;
}
@@ -250,13 +275,7 @@ void ChromeDllLoader::OnBeforeLaunch(const std::string& process_type,
RecordDidRun(dll_path);
// Launch the watcher process if stats collection consent has been granted.
-#if defined(GOOGLE_CHROME_BUILD)
- const bool stats_collection_consent =
- GoogleUpdateSettings::GetCollectStatsConsent();
-#else
- const bool stats_collection_consent = false;
-#endif
- if (stats_collection_consent) {
+ if (g_chrome_crash_client.Get().GetCollectStatsConsent()) {
base::FilePath exe_path;
if (PathService::Get(base::FILE_EXE, &exe_path)) {
chrome_watcher_client_.reset(new ChromeWatcherClient(