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

Unified Diff: chrome/app/main_dll_loader_win.cc

Issue 1416133003: Crashpad Windows: Use the Crashpad client instead of Breakpad on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 5 years, 1 month 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
Index: chrome/app/main_dll_loader_win.cc
diff --git a/chrome/app/main_dll_loader_win.cc b/chrome/app/main_dll_loader_win.cc
index 4f831ff6bb5a9dea72cca67b1024cbeef5f92deb..0f00624f2dd259c5e455b3223a1a775aaf1b0571 100644
--- a/chrome/app/main_dll_loader_win.cc
+++ b/chrome/app/main_dll_loader_win.cc
@@ -21,6 +21,7 @@
#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"
@@ -39,8 +40,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"
@@ -82,19 +83,65 @@ void ClearDidRun(const base::FilePath& dll_path) {
GoogleUpdateSettings::UpdateDidRunState(false, system_level);
}
-bool InMetroMode() {
- return (wcsstr(
- ::GetCommandLineW(), L" -ServerName:DefaultBrowserServer") != nullptr);
+typedef int (*InitMetro)();
+
+// Returns the directory in which the currently running executable resides.
+base::FilePath GetExecutableDir() {
+ base::char16 path[MAX_PATH];
+ ::GetModuleFileNameW(nullptr, path, MAX_PATH);
+ return base::FilePath(path).DirName();
}
-typedef int (*InitMetro)();
+bool WrapMessageBoxWithSEH(const wchar_t* text,
+ const wchar_t* caption,
+ UINT flags,
+ bool* exit_now) {
+ // We wrap the call to MessageBoxW with a SEH handler because it some
Mark Mentovai 2015/11/10 17:21:17 it→on
scottmg 2015/11/16 21:48:39 Done.
+ // machines with CursorXP, PeaDict or with FontExplorer installed it crashes
+ // uncontrollably here. Being this a best effort deal we better go away.
+ __try {
+ *exit_now = (IDOK != ::MessageBoxW(NULL, text, caption, flags));
Mark Mentovai 2015/11/10 17:21:17 and maybe restyle this copied stuff to modern stan
scottmg 2015/11/16 21:48:39 Done.
+ } __except(EXCEPTION_EXECUTE_HANDLER) {
+ // Its not safe to continue executing, exit silently here.
+ ::TerminateProcess(
+ ::GetCurrentProcess(),
+ g_chrome_crash_client.Pointer()->GetResultCodeRespawnFailed());
+ }
+
+ return true;
+}
+
+// This function is executed by the child process that DumpDoneCallback()
+// spawned and basically just shows the 'chrome has crashed' dialog if
+// the CHROME_CRASHED environment variable is present.
+bool ShowRestartDialogIfCrashed(bool* exit_now) {
+ // If we are being launched in metro mode don't try to show the dialog.
+ if (base::win::IsMetroProcess())
+ return false;
+
+ base::string16 message;
+ base::string16 title;
+ bool is_rtl_locale;
+ if (!g_chrome_crash_client.Pointer()->ShouldShowRestartDialog(
+ &title, &message, &is_rtl_locale)) {
+ return false;
+ }
+
+ // If the UI layout is right-to-left, we need to pass the appropriate MB_XXX
+ // flags so that an RTL message box is displayed.
+ UINT flags = MB_OKCANCEL | MB_ICONWARNING;
+ if (is_rtl_locale)
+ flags |= MB_RIGHT | MB_RTLREADING;
+
+ return WrapMessageBoxWithSEH(message.c_str(), title.c_str(), flags, exit_now);
+}
} // namespace
//=============================================================================
MainDllLoader::MainDllLoader()
- : dll_(nullptr), metro_mode_(InMetroMode()) {
+ : dll_(nullptr), metro_mode_(base::win::IsMetroProcess()) {
cpu_(ooo_6.6-7.5) 2015/11/10 03:06:50 note that IsProcessImmersive() does not exist in w
scottmg 2015/11/16 21:48:39 Hmm, is that OK? IsMetroProcess https://code.googl
}
MainDllLoader::~MainDllLoader() {
@@ -158,8 +205,9 @@ int MainDllLoader::Launch(HINSTANCE instance) {
return chrome_metro_main();
}
+ chrome::RegisterPathProvider();
+
if (process_type_ == "watcher") {
- chrome::RegisterPathProvider();
base::win::ScopedHandle parent_process;
base::win::ScopedHandle on_initialized_event;
@@ -209,14 +257,15 @@ int MainDllLoader::Launch(HINSTANCE instance) {
crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer());
bool exit_now = true;
if (process_type_.empty()) {
- if (breakpad::ShowRestartDialogIfCrashed(&exit_now)) {
+ if (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_);
+
+ crash_reporter::InitializeCrashpad(process_type_ == "", process_type_);
dll_ = Load(&version, &file);
if (!dll_)
@@ -230,12 +279,6 @@ 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)
cpu_(ooo_6.6-7.5) 2015/11/10 03:06:50 scary ..
scottmg 2015/11/16 21:48:39 Yeah, I asked Will about this one, and he said it
- breakpad::ConsumeInvalidHandleExceptions();
return rc;
}

Powered by Google App Engine
This is Rietveld 408576698