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

Unified Diff: components/crash/content/app/run_as_crashpad_handler_win.cc

Issue 2799013002: Monitor crashpad_handler for crashes [sometimes] (Closed)
Patch Set: Address review feedback (scottmg) Created 3 years, 8 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 | « components/crash/content/app/run_as_crashpad_handler_win.h ('k') | components/version_info/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/crash/content/app/run_as_crashpad_handler_win.cc
diff --git a/components/crash/content/app/run_as_crashpad_handler_win.cc b/components/crash/content/app/run_as_crashpad_handler_win.cc
index 20be2d108cf68043bd69d11ccc3318d189d18c2d..0724eac4bc320054a119ab3624921443b19ac951 100644
--- a/components/crash/content/app/run_as_crashpad_handler_win.cc
+++ b/components/crash/content/app/run_as_crashpad_handler_win.cc
@@ -14,25 +14,46 @@
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "third_party/crashpad/crashpad/client/crashpad_info.h"
+#include "third_party/crashpad/crashpad/client/simple_string_dictionary.h"
#include "third_party/crashpad/crashpad/handler/handler_main.h"
namespace crash_reporter {
-int RunAsCrashpadHandler(const base::CommandLine& command_line) {
+int RunAsCrashpadHandler(const base::CommandLine& command_line,
+ const char* process_type_switch) {
// Make sure this process terminates on OOM in the same mode as other Chrome
// processes.
base::EnableTerminationOnOutOfMemory();
+ // If the handler is started with --monitor-self, it'll need a ptype
+ // annotation set. It'll normally set one itself by being invoked with
+ // --monitor-self-annotation=ptype=crashpad-handler, but that leaves a window
+ // during self-monitoring initialization when the ptype is not set at all, so
+ // provide one here.
+ const std::string process_type =
+ command_line.GetSwitchValueASCII(process_type_switch);
+ if (!process_type.empty()) {
+ crashpad::SimpleStringDictionary* annotations =
+ new crashpad::SimpleStringDictionary();
+ annotations->SetKeyValue("ptype", process_type.c_str());
+ crashpad::CrashpadInfo* crashpad_info =
+ crashpad::CrashpadInfo::GetCrashpadInfo();
+ DCHECK(!crashpad_info->simple_annotations());
+ crashpad_info->set_simple_annotations(annotations);
+ }
+
std::vector<base::string16> argv = command_line.argv();
- const base::string16 process_type = L"--type=";
- argv.erase(std::remove_if(argv.begin(), argv.end(),
- [&process_type](const base::string16& str) {
- return base::StartsWith(
- str, process_type,
- base::CompareCase::SENSITIVE) ||
- (!str.empty() && str[0] == L'/');
- }),
- argv.end());
+ const base::string16 process_type_arg_prefix =
+ base::string16(L"--") + base::UTF8ToUTF16(process_type_switch) + L"=";
+ argv.erase(
+ std::remove_if(argv.begin(), argv.end(),
+ [&process_type_arg_prefix](const base::string16& str) {
+ return base::StartsWith(str, process_type_arg_prefix,
+ base::CompareCase::SENSITIVE) ||
+ (!str.empty() && str[0] == L'/');
+ }),
+ argv.end());
std::unique_ptr<char* []> argv_as_utf8(new char*[argv.size() + 1]);
std::vector<std::string> storage;
« no previous file with comments | « components/crash/content/app/run_as_crashpad_handler_win.h ('k') | components/version_info/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698