Chromium Code Reviews| Index: chrome/common/crash_keys.cc |
| diff --git a/chrome/common/crash_keys.cc b/chrome/common/crash_keys.cc |
| index ad3fb135c2b3e638405ce84b3700a00878f07904..182249d405a46310c2d88b3ecb9c0dce99aa2682 100644 |
| --- a/chrome/common/crash_keys.cc |
| +++ b/chrome/common/crash_keys.cc |
| @@ -5,13 +5,13 @@ |
| #include "chrome/common/crash_keys.h" |
| #include "base/base_switches.h" |
| +#include "base/bind.h" |
| #include "base/command_line.h" |
| #include "base/format_macros.h" |
| #include "base/logging.h" |
| #include "base/strings/string_split.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/stringprintf.h" |
| -#include "base/strings/utf_string_conversions.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "components/flags_ui/flags_ui_switches.h" |
| #include "content/public/common/content_switches.h" |
| @@ -29,9 +29,6 @@ const char kActiveURL[] = "url-chunk"; |
| const char kFontKeyName[] = "font_key_name"; |
| -const char kSwitch[] = "switch-%" PRIuS; |
| -const char kNumSwitches[] = "num-switches"; |
| - |
| const char kExtensionID[] = "extension-%" PRIuS; |
| const char kNumExtensionsCount[] = "num-extensions"; |
| @@ -94,7 +91,6 @@ size_t RegisterChromeCrashKeys() { |
| #endif |
| { kChannel, kSmallSize }, |
| { kActiveURL, kLargeSize }, |
| - { kNumSwitches, kSmallSize }, |
| { kNumVariations, kSmallSize }, |
| { kVariations, kLargeSize }, |
| { kNumExtensionsCount, kSmallSize }, |
| @@ -154,23 +150,7 @@ size_t RegisterChromeCrashKeys() { |
| std::vector<base::debug::CrashKey> keys( |
| fixed_keys, fixed_keys + arraysize(fixed_keys)); |
| - // Register the switches. |
| - { |
| - // The fixed_keys names are string constants. Use static storage for |
| - // formatted key names as well, since they will persist for the duration of |
| - // the program. |
| - static char formatted_keys[kSwitchesMaxCount][sizeof(kSwitch) + 1] = |
| - {{ 0 }}; |
| - const size_t formatted_key_len = sizeof(formatted_keys[0]); |
| - for (size_t i = 0; i < kSwitchesMaxCount; ++i) { |
| - // Name the keys using 1-based indexing. |
| - int n = base::snprintf( |
| - formatted_keys[i], formatted_key_len, kSwitch, i + 1); |
| - DCHECK_GT(n, 0); |
| - base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; |
| - keys.push_back(crash_key); |
| - } |
| - } |
| + crash_keys::GetCrashKeysForCommandLineSwitches(&keys); |
| // Register the extension IDs. |
| { |
| @@ -272,39 +252,8 @@ void SetSwitchesFromCommandLine(const base::CommandLine* command_line) { |
| DCHECK(command_line); |
| if (!command_line) |
| return; |
| - |
| - const base::CommandLine::StringVector& argv = command_line->argv(); |
| - |
| - // Set the number of switches in case size > kNumSwitches. |
| - base::debug::SetCrashKeyValue(kNumSwitches, |
| - base::StringPrintf("%" PRIuS, argv.size() - 1)); |
| - |
| - size_t key_i = 1; // Key names are 1-indexed. |
| - |
| - // Go through the argv, skipping the exec path. |
| - for (size_t i = 1; i < argv.size(); ++i) { |
| -#if defined(OS_WIN) |
| - std::string switch_str = base::WideToUTF8(argv[i]); |
| -#else |
| - std::string switch_str = argv[i]; |
| -#endif |
| - |
| - // Skip uninteresting switches. |
| - if (IsBoringSwitch(switch_str)) |
| - continue; |
| - |
| - // Stop if there are too many switches. |
| - if (i > crash_keys::kSwitchesMaxCount) |
| - break; |
| - |
| - std::string key = base::StringPrintf(kSwitch, key_i++); |
| - base::debug::SetCrashKeyValue(key, switch_str); |
| - } |
| - |
| - // Clear any remaining switches. |
| - for (; key_i <= kSwitchesMaxCount; ++key_i) { |
| - base::debug::ClearCrashKey(base::StringPrintf(kSwitch, key_i)); |
| - } |
| + return SetSwitchesFromCommandLine(*command_line, |
|
grt (UTC plus 2)
2015/11/27 18:51:21
hmm, the name collision here is a bit confusing. w
Joe Mason
2015/11/27 21:16:47
Done.
|
| + base::Bind(&IsBoringSwitch)); |
| } |
| void SetActiveExtensions(const std::set<std::string>& extensions) { |