Chromium Code Reviews| 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..f42946a43e3784c5e0c5e7cb30f25e29b2f9f3bf 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,45 @@ |
| #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(); |
|
scottmg
2017/04/10 17:09:31
I'd like to DCHECK that crashpad_info->simple_anno
Mark Mentovai
2017/04/10 17:19:02
scottmg wrote:
|
| + 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; |