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

Unified Diff: chrome/app/chrome_exe_main_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: commandline and rebase 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/chrome_exe_main_win.cc
diff --git a/chrome/app/chrome_exe_main_win.cc b/chrome/app/chrome_exe_main_win.cc
index d26676fe0f7fb1d552040185afd4098a3fb01221..3b92f2421b64cd8a35c795d3182d5dfd8db741ba 100644
--- a/chrome/app/chrome_exe_main_win.cc
+++ b/chrome/app/chrome_exe_main_win.cc
@@ -13,6 +13,7 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/win/windows_version.h"
#include "chrome/app/main_dll_loader_win.h"
@@ -23,6 +24,7 @@
#include "chrome_elf/chrome_elf_main.h"
#include "components/startup_metric_utils/startup_metric_utils.h"
#include "content/public/common/result_codes.h"
+#include "third_party/crashpad/crashpad/handler/handler_main.h"
#include "ui/gfx/win/dpi.h"
namespace {
@@ -121,6 +123,26 @@ void SwitchToLFHeap() {
}
}
+bool RunAsCrashpadHandler(const base::CommandLine& command_line, int* rc) {
+ if (command_line.HasSwitch("crashpad_handler")) {
+ std::vector<base::string16> argv = command_line.argv();
+ argv.erase(std::remove(argv.begin(), argv.end(), L"--crashpad_handler"),
+ argv.end());
+
+ scoped_ptr<char* []> argv_as_utf8(new char*[argv.size() + 1]);
+ std::vector<std::string> storage;
+ storage.reserve(argv.size());
+ for (size_t i = 0; i < argv.size(); ++i) {
+ storage.push_back(base::UTF16ToUTF8(argv[i]));
+ argv_as_utf8[i] = &storage[i][0];
+ }
+ argv_as_utf8[argv.size()] = nullptr;
+ *rc = crashpad::HandlerMain(argv.size(), argv_as_utf8.get());
+ return true;
+ }
+ return false;
+}
+
} // namespace
#if !defined(ADDRESS_SANITIZER)
@@ -131,6 +153,13 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) {
int main() {
HINSTANCE instance = GetModuleHandle(NULL);
#endif
+ // Initialize the commandline singleton from the environment.
+ base::CommandLine::Init(0, NULL);
cpu_(ooo_6.6-7.5) 2015/11/07 01:53:17 lets move this Init(0, NULL) inside the RunAsCrash
scottmg 2015/11/09 18:29:56 I think it's better out here, since it's also init
+
+ int rc;
+ if (RunAsCrashpadHandler(*base::CommandLine::ForCurrentProcess(), &rc))
+ return rc;
+
SwitchToLFHeap();
startup_metric_utils::RecordExeMainEntryPointTime(base::Time::Now());
@@ -138,8 +167,6 @@ int main() {
// Signal Chrome Elf that Chrome has begun to start.
SignalChromeElf();
- // Initialize the commandline singleton from the environment.
- base::CommandLine::Init(0, NULL);
// The exit manager is in charge of calling the dtors of singletons.
base::AtExitManager exit_manager;
@@ -155,7 +182,7 @@ int main() {
// Load and launch the chrome dll. *Everything* happens inside.
VLOG(1) << "About to load main DLL.";
MainDllLoader* loader = MakeMainDllLoader();
- int rc = loader->Launch(instance);
+ rc = loader->Launch(instance);
loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded();
delete loader;
return rc;

Powered by Google App Engine
This is Rietveld 408576698